Skip to content

Commit 858fa84

Browse files
committed
cdr . assoc -> assoc-default
1 parent d1c4a59 commit 858fa84

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

swift-mode-repl.el

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -306,31 +306,31 @@ Return a JSON object."
306306
The manifest file is searched from the PROJECT-DIRECTORY, defaults to
307307
`default-directory', or its ancestors."
308308
(let* ((description (swift-mode:describe-package project-directory))
309-
(modules (cdr (assoc 'targets description))))
309+
(modules (assoc-default 'targets description)))
310310
(seq-find
311-
(lambda (module) (not (equal "test" (cdr (assoc 'type module)))))
311+
(lambda (module) (not (equal "test" (assoc-default 'type module))))
312312
modules)))
313313

314314
(defun swift-mode:read-package-name (project-directory)
315315
"Read the package name from the manifest file Package.swift.
316316
317317
The manifest file is searched from the PROJECT-DIRECTORY, defaults to
318318
`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)))
320320

321321
(defun swift-mode:read-c99-name (project-directory)
322322
"Read the C99 name from the manifest file Package.swift.
323323
324324
The manifest file is searched from the PROJECT-DIRECTORY, defaults to
325325
`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)))
327327

328328
(defun swift-mode:read-module-type (project-directory)
329329
"Read the module type from the manifest file Package.swift.
330330
331331
The manifest file is searched from the PROJECT-DIRECTORY, defaults to
332332
`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)))
334334

335335
(defun swift-mode:join-path (directory &rest components)
336336
"Make path string for DIRECTORY followed by COMPONENTS."
@@ -440,11 +440,11 @@ or its ancestors."
440440
(defun swift-mode:list-ios-simulator-devices ()
441441
"List available iOS simulator devices."
442442
(let* ((json (swift-mode:list-ios-simulators))
443-
(devices (cdr (assoc 'devices json)))
443+
(devices (assoc-default 'devices json))
444444
(flattened (apply #'seq-concatenate 'list (seq-map #'cdr devices)))
445445
(available-devices
446446
(seq-filter
447-
(lambda (device) (cdr (assoc 'isAvailable device)))
447+
(lambda (device) (assoc-default 'isAvailable device))
448448
flattened)))
449449
available-devices))
450450

@@ -455,8 +455,8 @@ or its ancestors."
455455
swift-mode:ios-local-device-identifier))
456456
(seq-map
457457
(lambda (device)
458-
(cons (cdr (assoc 'name device))
459-
(cdr (assoc 'udid device))))
458+
(cons (assoc-default 'name device)
459+
(assoc-default 'udid device)))
460460
devices))))
461461
(widget-choose "Choose a device" items)))
462462

@@ -511,9 +511,9 @@ passed as a destination to xcodebuild."
511511
512512
xcodebuild is executed in PROJECT-DIRECTORY."
513513
(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))
517517
(choices (seq-map
518518
(lambda (scheme) (cons scheme scheme))
519519
schemes)))
@@ -768,8 +768,8 @@ Return nil otherwise."
768768
(while (null (seq-find
769769
(lambda (device)
770770
(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")))
773773
(swift-mode:list-ios-simulator-devices)))
774774
(sit-for 0.5)))
775775

@@ -854,15 +854,15 @@ in Xcode build settings."
854854
(target-device
855855
(seq-find
856856
(lambda (device)
857-
(string-equal (cdr (assoc 'udid device)) device-identifier))
857+
(string-equal (assoc-default 'udid device) device-identifier))
858858
devices))
859859
(active-devices
860860
(seq-filter
861861
(lambda (device)
862-
(string-equal (cdr (assoc 'state device)) "Booted"))
862+
(string-equal (assoc-default 'state device) "Booted"))
863863
devices))
864864
(target-booted
865-
(string-equal (cdr (assoc 'state target-device)) "Booted"))
865+
(string-equal (assoc-default 'state target-device) "Booted"))
866866
(simulator-running (consp active-devices))
867867
(progress-reporter
868868
(make-progress-reporter "Waiting for simulator...")))
@@ -959,9 +959,9 @@ the value of `swift-mode:ios-project-scheme' is used."
959959
sdk
960960
device-identifier))
961961
(codesigning-folder-path
962-
(cdr (assoc "CODESIGNING_FOLDER_PATH" build-settings)))
962+
(assoc-default "CODESIGNING_FOLDER_PATH" build-settings))
963963
(product-bundle-identifier
964-
(cdr (assoc "PRODUCT_BUNDLE_IDENTIFIER" build-settings))))
964+
(assoc-default "PRODUCT_BUNDLE_IDENTIFIER" build-settings)))
965965
(unless codesigning-folder-path
966966
(error "Cannot get codesigning folder path"))
967967
(unless product-bundle-identifier
@@ -1019,22 +1019,23 @@ The manifest file is searched from the PROJECT-DIRECTORY, defaults to
10191019
10201020
If TARGET is non-nil, return only sources of that target."
10211021
(let* ((description (swift-mode:describe-package project-directory))
1022-
(targets (cdr (assoc 'targets description)))
1022+
(targets (assoc-default 'targets description))
10231023
(test-targets (seq-filter
10241024
(lambda (module)
1025-
(and (equal "test" (cdr (assoc 'type module)))
1025+
(and (equal "test" (assoc-default 'type module))
10261026
(or (null target)
1027-
(equal target (cdr (assoc 'name module))))))
1027+
(equal target
1028+
(assoc-default 'name module)))))
10281029
targets))
1029-
(project-path (cdr (assoc 'path description)))
1030+
(project-path (assoc-default 'path description))
10301031
target-path)
10311032
(seq-mapcat
10321033
(lambda (target)
10331034
(setq target-path
1034-
(expand-file-name (cdr (assoc 'path target)) project-path))
1035+
(expand-file-name (assoc-default 'path target) project-path))
10351036
(mapcar (lambda (source)
10361037
(expand-file-name source target-path))
1037-
(cdr (assoc 'sources target))))
1038+
(assoc-default 'sources target)))
10381039
test-targets)))
10391040

10401041
(defun swift-mode:resolve-swift-test-file (file)

0 commit comments

Comments
 (0)