branch: elpa/swift-mode commit a3bcb1982a9ee3a51e06236d8d714e1b31f474ec Merge: c40887e ade8e95 Author: Bozhidar Batsov <bozhidar.bat...@gmail.com> Commit: Bozhidar Batsov <bozhidar.bat...@gmail.com>
Merge pull request #109 from syohex/with-eval-after-load Use with-eval-after-load instead of eval-after-load --- swift-mode.el | 139 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 69 insertions(+), 70 deletions(-) diff --git a/swift-mode.el b/swift-mode.el index 18cbcc6..2833047 100644 --- a/swift-mode.el +++ b/swift-mode.el @@ -629,76 +629,75 @@ We try to constraint those lookups by reasonable number of lines.") ;;; Flycheck -(eval-after-load 'flycheck - (lambda () - (flycheck-def-option-var flycheck-swift-sdk-path nil swift - "A path to the targeted SDK" - :type '(choice (const :tag "Don't link against sdk" nil) - (string :tag "Targeted SDK path")) - :safe #'stringp) - - (flycheck-def-option-var flycheck-swift-linked-sources nil swift - "Source files path to link against. Can be glob, i.e. *.swift" - :type '(choice (const :tag "Don't use linked sources" nil) - (string :tag "Linked Sources")) - :safe #'stringp) - - (flycheck-def-option-var flycheck-swift-framework-search-paths nil swift - "A list of framework search paths" - :type '(repeat (directory :tag "Include directory")) - :safe #'flycheck-string-list-p) - - (flycheck-def-option-var flycheck-swift-cc-include-search-paths nil swift - "A list of include file search paths to pass to the Objective C compiler" - :type '(repeat (directory :tag "Include directory")) - :safe #'flycheck-string-list-p) - - (flycheck-def-option-var flycheck-swift-target "i386-apple-ios8.1" swift - "Target used by swift compiler" - :type '(choice (const :tag "Don't specify target" nil) - (string :tag "Build target")) - :safe #'stringp) - - (flycheck-def-option-var flycheck-swift-import-objc-header nil swift - "Objective C header file to import, if any" - :type '(choice (const :tag "Don't specify objective C bridging header" nil) - (string :tag "Objective C bridging header path")) - :safe #'stringp) - - (flycheck-define-checker swift - "Flycheck plugin for for Apple's Swift programming language." - :command ("swift" - "-frontend" "-parse" - (option "-sdk" flycheck-swift-sdk-path) - (option-list "-F" flycheck-swift-framework-search-paths) - ;; Swift compiler will complain about redeclaration - ;; if we will include original file along with - ;; temporary source file created by flycheck. - ;; We also don't want a hidden emacs interlock files. - (eval - (let (source file) - (when flycheck-swift-linked-sources - (setq source (car (flycheck-substitute-argument 'source 'swift))) - (setq file (file-name-nondirectory source)) - (cl-remove-if-not - #'(lambda (path) - (and - (eq (string-match ".#" path) nil) - (eq (string-match file path) nil))) - (file-expand-wildcards flycheck-swift-linked-sources))))) - (option "-target" flycheck-swift-target) - (option "-import-objc-header" flycheck-swift-import-objc-header) - (eval - (mapcan - #'(lambda (path) (list "-Xcc" (concat "-I" path))) - flycheck-swift-cc-include-search-paths)) - "-primary-file" source) - :error-patterns - ((error line-start (file-name) ":" line ":" column ": " - "error: " (message) line-end) - (warning line-start (file-name) ":" line ":" column ": " - "warning: " (message) line-end)) - :modes swift-mode))) +(with-eval-after-load 'flycheck + (flycheck-def-option-var flycheck-swift-sdk-path nil swift + "A path to the targeted SDK" + :type '(choice (const :tag "Don't link against sdk" nil) + (string :tag "Targeted SDK path")) + :safe #'stringp) + + (flycheck-def-option-var flycheck-swift-linked-sources nil swift + "Source files path to link against. Can be glob, i.e. *.swift" + :type '(choice (const :tag "Don't use linked sources" nil) + (string :tag "Linked Sources")) + :safe #'stringp) + + (flycheck-def-option-var flycheck-swift-framework-search-paths nil swift + "A list of framework search paths" + :type '(repeat (directory :tag "Include directory")) + :safe #'flycheck-string-list-p) + + (flycheck-def-option-var flycheck-swift-cc-include-search-paths nil swift + "A list of include file search paths to pass to the Objective C compiler" + :type '(repeat (directory :tag "Include directory")) + :safe #'flycheck-string-list-p) + + (flycheck-def-option-var flycheck-swift-target "i386-apple-ios8.1" swift + "Target used by swift compiler" + :type '(choice (const :tag "Don't specify target" nil) + (string :tag "Build target")) + :safe #'stringp) + + (flycheck-def-option-var flycheck-swift-import-objc-header nil swift + "Objective C header file to import, if any" + :type '(choice (const :tag "Don't specify objective C bridging header" nil) + (string :tag "Objective C bridging header path")) + :safe #'stringp) + + (flycheck-define-checker swift + "Flycheck plugin for for Apple's Swift programming language." + :command ("swift" + "-frontend" "-parse" + (option "-sdk" flycheck-swift-sdk-path) + (option-list "-F" flycheck-swift-framework-search-paths) + ;; Swift compiler will complain about redeclaration + ;; if we will include original file along with + ;; temporary source file created by flycheck. + ;; We also don't want a hidden emacs interlock files. + (eval + (let (source file) + (when flycheck-swift-linked-sources + (setq source (car (flycheck-substitute-argument 'source 'swift))) + (setq file (file-name-nondirectory source)) + (cl-remove-if-not + #'(lambda (path) + (and + (eq (string-match ".#" path) nil) + (eq (string-match file path) nil))) + (file-expand-wildcards flycheck-swift-linked-sources))))) + (option "-target" flycheck-swift-target) + (option "-import-objc-header" flycheck-swift-import-objc-header) + (eval + (mapcan + #'(lambda (path) (list "-Xcc" (concat "-I" path))) + flycheck-swift-cc-include-search-paths)) + "-primary-file" source) + :error-patterns + ((error line-start (file-name) ":" line ":" column ": " + "error: " (message) line-end) + (warning line-start (file-name) ":" line ":" column ": " + "warning: " (message) line-end)) + :modes swift-mode)) ;;; REPL