@@ -306,31 +306,31 @@ Return a JSON object."
306
306
The manifest file is searched from the PROJECT-DIRECTORY, defaults to
307
307
`default-directory' , or its ancestors."
308
308
(let* ((description (swift-mode:describe-package project-directory))
309
- (modules (cdr ( assoc 'targets description) )))
309
+ (modules (assoc-default 'targets description)))
310
310
(seq-find
311
- (lambda (module ) (not (equal " test" (cdr ( assoc 'type module) ))))
311
+ (lambda (module ) (not (equal " test" (assoc-default 'type module))))
312
312
modules)))
313
313
314
314
(defun swift-mode:read-package-name (project-directory )
315
315
" Read the package name from the manifest file Package.swift.
316
316
317
317
The manifest file is searched from the PROJECT-DIRECTORY, defaults to
318
318
`default-directory' , or its ancestors."
319
- (cdr ( assoc 'name (swift-mode:read-main-module project-directory) )))
319
+ (assoc-default 'name (swift-mode:read-main-module project-directory)))
320
320
321
321
(defun swift-mode:read-c99-name (project-directory )
322
322
" Read the C99 name from the manifest file Package.swift.
323
323
324
324
The manifest file is searched from the PROJECT-DIRECTORY, defaults to
325
325
`default-directory' , or its ancestors."
326
- (cdr ( assoc 'c99name (swift-mode:read-main-module project-directory) )))
326
+ (assoc-default 'c99name (swift-mode:read-main-module project-directory)))
327
327
328
328
(defun swift-mode:read-module-type (project-directory )
329
329
" Read the module type from the manifest file Package.swift.
330
330
331
331
The manifest file is searched from the PROJECT-DIRECTORY, defaults to
332
332
`default-directory' , or its ancestors."
333
- (cdr ( assoc 'type (swift-mode:read-main-module project-directory) )))
333
+ (assoc-default 'type (swift-mode:read-main-module project-directory)))
334
334
335
335
(defun swift-mode:join-path (directory &rest components )
336
336
" Make path string for DIRECTORY followed by COMPONENTS."
@@ -440,11 +440,11 @@ or its ancestors."
440
440
(defun swift-mode:list-ios-simulator-devices ()
441
441
" List available iOS simulator devices."
442
442
(let* ((json (swift-mode:list-ios-simulators))
443
- (devices (cdr ( assoc 'devices json) ))
443
+ (devices (assoc-default 'devices json))
444
444
(flattened (apply #'seq-concatenate 'list (seq-map #'cdr devices)))
445
445
(available-devices
446
446
(seq-filter
447
- (lambda (device ) (cdr ( assoc 'isAvailable device) ))
447
+ (lambda (device ) (assoc-default 'isAvailable device))
448
448
flattened)))
449
449
available-devices))
450
450
@@ -455,8 +455,8 @@ or its ancestors."
455
455
swift-mode:ios-local-device-identifier))
456
456
(seq-map
457
457
(lambda (device )
458
- (cons (cdr ( assoc 'name device) )
459
- (cdr ( assoc 'udid device) )))
458
+ (cons (assoc-default 'name device)
459
+ (assoc-default 'udid device)))
460
460
devices))))
461
461
(widget-choose " Choose a device" items)))
462
462
@@ -511,9 +511,9 @@ passed as a destination to xcodebuild."
511
511
512
512
xcodebuild is executed in PROJECT-DIRECTORY."
513
513
(let* ((json (swift-mode:xcodebuild-list project-directory))
514
- (project (or (cdr ( assoc 'project json) )
515
- (cdr ( assoc 'workspace json) )))
516
- (schemes (cdr ( assoc 'schemes project) ))
514
+ (project (or (assoc-default 'project json)
515
+ (assoc-default 'workspace json)))
516
+ (schemes (assoc-default 'schemes project))
517
517
(choices (seq-map
518
518
(lambda (scheme ) (cons scheme scheme))
519
519
schemes)))
@@ -768,8 +768,8 @@ Return nil otherwise."
768
768
(while (null (seq-find
769
769
(lambda (device )
770
770
(and
771
- (string-equal (cdr ( assoc 'udid device) ) device-identifier)
772
- (string-equal (cdr ( assoc 'state device) ) " Booted" )))
771
+ (string-equal (assoc-default 'udid device) device-identifier)
772
+ (string-equal (assoc-default 'state device) " Booted" )))
773
773
(swift-mode:list-ios-simulator-devices)))
774
774
(sit-for 0.5 )))
775
775
@@ -854,15 +854,15 @@ in Xcode build settings."
854
854
(target-device
855
855
(seq-find
856
856
(lambda (device )
857
- (string-equal (cdr ( assoc 'udid device) ) device-identifier))
857
+ (string-equal (assoc-default 'udid device) device-identifier))
858
858
devices))
859
859
(active-devices
860
860
(seq-filter
861
861
(lambda (device )
862
- (string-equal (cdr ( assoc 'state device) ) " Booted" ))
862
+ (string-equal (assoc-default 'state device) " Booted" ))
863
863
devices))
864
864
(target-booted
865
- (string-equal (cdr ( assoc 'state target-device) ) " Booted" ))
865
+ (string-equal (assoc-default 'state target-device) " Booted" ))
866
866
(simulator-running (consp active-devices))
867
867
(progress-reporter
868
868
(make-progress-reporter " Waiting for simulator..." )))
@@ -959,9 +959,9 @@ the value of `swift-mode:ios-project-scheme' is used."
959
959
sdk
960
960
device-identifier))
961
961
(codesigning-folder-path
962
- (cdr ( assoc " CODESIGNING_FOLDER_PATH" build-settings) ))
962
+ (assoc-default " CODESIGNING_FOLDER_PATH" build-settings))
963
963
(product-bundle-identifier
964
- (cdr ( assoc " PRODUCT_BUNDLE_IDENTIFIER" build-settings) )))
964
+ (assoc-default " PRODUCT_BUNDLE_IDENTIFIER" build-settings)))
965
965
(unless codesigning-folder-path
966
966
(error " Cannot get codesigning folder path " ))
967
967
(unless product-bundle-identifier
@@ -1019,22 +1019,23 @@ The manifest file is searched from the PROJECT-DIRECTORY, defaults to
1019
1019
1020
1020
If TARGET is non-nil, return only sources of that target."
1021
1021
(let* ((description (swift-mode:describe-package project-directory))
1022
- (targets (cdr ( assoc 'targets description) ))
1022
+ (targets (assoc-default 'targets description))
1023
1023
(test-targets (seq-filter
1024
1024
(lambda (module )
1025
- (and (equal " test" (cdr ( assoc 'type module) ))
1025
+ (and (equal " test" (assoc-default 'type module))
1026
1026
(or (null target)
1027
- (equal target (cdr (assoc 'name module))))))
1027
+ (equal target
1028
+ (assoc-default 'name module)))))
1028
1029
targets))
1029
- (project-path (cdr ( assoc 'path description) ))
1030
+ (project-path (assoc-default 'path description))
1030
1031
target-path)
1031
1032
(seq-mapcat
1032
1033
(lambda (target )
1033
1034
(setq target-path
1034
- (expand-file-name (cdr ( assoc 'path target) ) project-path))
1035
+ (expand-file-name (assoc-default 'path target) project-path))
1035
1036
(mapcar (lambda (source )
1036
1037
(expand-file-name source target-path))
1037
- (cdr ( assoc 'sources target) )))
1038
+ (assoc-default 'sources target)))
1038
1039
test-targets)))
1039
1040
1040
1041
(defun swift-mode:resolve-swift-test-file (file )
0 commit comments