diff --git a/README.md b/README.md index ba66ff9d..349a5614 100644 --- a/README.md +++ b/README.md @@ -925,7 +925,7 @@ Modules can be individually commented out if needed: ;; Themes ;; Note: use "export TERM=xterm-256color" for emacs -nw (setq custom-theme-directory exordium-themes-dir) -(exordium-require 'init-progress-bar nil) +(exordium-require 'init-progress-bar) (when exordium-nw (set-face-background 'highlight nil)) diff --git a/init.el b/init.el index 966ef62b..712eedc6 100644 --- a/init.el +++ b/init.el @@ -382,7 +382,7 @@ after it's been byte compiled." ;; Themes ;; Note: use "export TERM=xterm-256color" for emacs -nw (setq custom-theme-directory exordium-themes-dir) -(exordium-require 'init-progress-bar nil) +(exordium-require 'init-progress-bar) (when exordium-nw (set-face-background 'highlight nil)) @@ -454,8 +454,8 @@ after it's been byte compiled." (exordium-require 'init-gdb) ;; RTags -(exordium-require 'init-rtags nil - :functions (rtags-auto-complete)) +(exordium-require 'init-rtags + :functions (rtags-auto-complete)) (when (and (eq exordium-complete-mode :auto-complete) exordium-rtags-auto-complete) (rtags-auto-complete)) diff --git a/modules/init-clojure.el b/modules/init-clojure.el index 0666879b..4e5048c9 100644 --- a/modules/init-clojure.el +++ b/modules/init-clojure.el @@ -34,7 +34,7 @@ :config (exec-path-from-shell-initialize))) -(exordium-require 'clojure "extensions") +(exordium-require 'clojure :location "extensions") ;;; Hippie expand - don't try to complete with file names (setq hippie-expand-try-functions-list diff --git a/modules/init-require.el b/modules/init-require.el index 74adbdfa..fccbd186 100644 --- a/modules/init-require.el +++ b/modules/init-require.el @@ -22,7 +22,8 @@ ;; and `defvars' forms, should the compiler not infer them from the loaded ;; module. For example, the folllowing expression: ;; -;; (exordium-require 'init-foo "foo-dir" +;; (exordium-require 'init-foo +;; :location "foo-dir" ;; :functions (foo-simple (foo-args . (arg1 arg2))) ;; :defines (foo-var)) ;; @@ -187,32 +188,37 @@ for `exordium-require', which see." (load file nomessage)))) ;;;###autoload -(defmacro exordium-require (feature &optional location &rest declarations) - "If FEATURE is not already loaded, load it from Exordium LOCATION. -Like `require', but concatenate LOCATION, that is relative in -Exordium project, with printname of FEATURE as FILE passed to -`load' (which see). Default LOCATION is \"modules\". +(defmacro exordium-require (feature &rest options) + "If FEATURE is not already loaded, load it from Exordium modules directory. +OPTIONS is a plist, with up to three properties: `:location', +`:functions', and `:defines'. -To suppress compiler warnings use DECLARATIONS which is a plist -with two properties: `:functions' and `:defines'. The `:functions' -is a list where each element either is a function FN or is a -cons (FN ARGLIST) that are passed to `declare-function' (which -see). Note that `declare-function' forms has FILE argument set -to nil. The `:defines' is a list where each element is a SYMBOL -that is passed to `defvar' (which see). +Like `require', but concatenate :location, that is relative in +Exordium project, with printname of FEATURE as a FILE argument passed to +`load' (which see). Default :location is \"modules\". + +To suppress compiler warnings use `:functions' and `:defines' +keywords in OPTIONS argument. The `:functions' is a list where +each element either is a function FN or is a cons (FN ARGLIST) +that are passed to `declare-function' (which see). Note that +`declare-function' forms has FILE argument set to nil. The +`:defines' is a list where each element is a SYMBOL that is +passed to `defvar' (which see). Please see Commentary in init-require.el for more details." - (declare (debug t) (indent 2)) + (declare (debug t) (indent 1)) (when-let* (((if (and (consp feature) (eq #'quote (car feature)) (consp (cdr feature)) (symbolp (cadr feature)) (not (keywordp (cadr feature))) (not (cddr feature))) - ;; 'symbol is a (cons #'quote (cons symbol nil)) - t (error "Wrong type argument: symbolp, %S" feature))) + ;; 'symbol is a (cons #'quote (cons symbol nil)) + t (error "Wrong type argument: symbolp, %S" feature))) - ((if (or (stringp location) (and (symbolp location) (not location))) - ;; "string" is a string, nil is a symbol - t (error "Wrong type argument: stringp or nil, %S" location))) + ((let ((location (plist-get options :location))) + (if (or (and (stringp location) (< 0 (length location))) + (and (symbolp location) (not location))) + ;; "string" is a string, nil is a symbol + t (error "Wrong type argument: stringp or nil, %S" location)))) (declare-forms (or (append (mapcar (lambda (fn) @@ -232,13 +238,13 @@ Please see Commentary in init-require.el for more details." (error "Wrong type argument: symbolp or (and (consp) (symbolp car)), %S" fn)))) - (plist-get declarations :functions)) + (plist-get options :functions)) (mapcar (lambda (var) (if (and (symbolp var) (not (memq var '(nil t quote))) (not (string-prefix-p ":" (symbol-name var)))) `(defvar ,var) (error "Wrong type argument: symbolp, %S" var))) - (plist-get declarations :defines))) + (plist-get options :defines))) t))) (append `(progn @@ -265,7 +271,9 @@ Please see Commentary in init-require.el for more details." (with-demoted-errors ,(format "(exordium-require) Cannot load %s: %%S" feature) (unless (featurep ,feature) - (exordium--require-load ,feature ,location t)))) + (exordium--require-load ,feature + ,(plist-get options :location) + t)))) ,@(when (listp declare-forms) declare-forms)) ,@(when (bound-and-true-p use-package-compute-statistics) @@ -284,7 +292,8 @@ Please see Commentary in init-require.el for more details." "Recursive `exordium-require' for feature `%s', require-nesting-list: %s" ,feature exordium--require-nesting-list) (push ,feature exordium--require-nesting-list) - (exordium--require-load ,feature ,location) + (exordium--require-load ,feature + ,(plist-get options :location)) (if (featurep ,feature) ,feature (if-let* ((file (caar load-history))) diff --git a/modules/init-require.t.el b/modules/init-require.t.el index d39ec549..319850bc 100644 --- a/modules/init-require.t.el +++ b/modules/init-require.t.el @@ -106,7 +106,8 @@ Recursion is in order: FORM, (car FORM), (cdr FORM)." ;; delay `exordium-require' macro expansion to test execution (ignore-errors (unload-feature 'init-require.t-dummy)) (should (eq 'init-require.t-dummy - (eval '(exordium-require 'init-require.t-dummy "modules")))) + (eval '(exordium-require 'init-require.t-dummy + :location "modules")))) (should (featurep 'init-require.t-dummy))) (ert-deftest exordium-require-with-location-and-declarations () @@ -116,7 +117,7 @@ Recursion is in order: FORM, (car FORM), (cdr FORM)." (eq 'init-require.t-dummy (eval '(exordium-require 'init-require.t-dummy - "modules" + :location "modules" :functions (require.t-dummy-1 (require.t-dummy-2 . (arg1 arg2))) :defines (require.t-dummy-3))))) @@ -142,7 +143,8 @@ Recursion is in order: FORM, (car FORM), (cdr FORM)." (ignore-errors (unload-feature 'init-require.t-dummy)) (let* ((debug-on-error nil)) (should-not (eq 'init-require.t-dummy - (eval '(exordium-require 'init-require.t-dummy "themes"))))) + (eval '(exordium-require 'init-require.t-dummy + :location "themes"))))) (should-not (featurep 'init-require.t-dummy))) (ert-deftest exordium-require-signals-error-with-non-existing-location-while-debug () @@ -168,126 +170,107 @@ Recursion is in order: FORM, (car FORM), (cdr FORM)." init-require.t-dummy))))) (ert-deftest exordium-require-signals-error-with-wrong-location-type () - (should-error (eval '(exordium-require 'init-require.t-dummy t))) - (should-error (eval '(exordium-require 'init-require.t-dummy 42))) - (should-error (eval '(exordium-require 'init-require.t-dummy ? ))) - (should-error (eval '(exordium-require 'init-require.t-dummy 'modules))) - (should-error (eval '(exordium-require 'init-require.t-dummy :modules))) - (should-error (eval '(exordium-require 'init-require.t-dummy modules))) - (should-error (eval '(exordium-require - 'init-require.t-dummy - (if t "modules" "themes"))))) + (should-error (eval '(exordium-require 'init-require.t-dummy + :location ""))) + (should-error (eval '(exordium-require 'init-require.t-dummy + :location t))) + (should-error (eval '(exordium-require 'init-require.t-dummy + :location 42))) + (should-error (eval '(exordium-require 'init-require.t-dummy + :location ? ))) + (should-error (eval '(exordium-require 'init-require.t-dummy + :location 'modules))) + (should-error (eval '(exordium-require 'init-require.t-dummy + :location :modules))) + (should-error (eval '(exordium-require 'init-require.t-dummy + :location modules))) + (should-error (eval '(exordium-require 'init-require.t-dummy + :location (if t "modules" "themes"))))) (ert-deftest exordium-require-signals-error-with-wrong-defines-type () (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :defines (nil)))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :defines (t)))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :defines (42)))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :defines ("var")))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :defines ('var)))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :defines (:var)))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :defines ((if t 'var 'var)))))) (ert-deftest exordium-require-signals-error-with-wrong-functions-type () ;; invalid function without args (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions (nil)))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions (t)))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions (42)))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ("fn")))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ('fn)))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions (:fn)))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ((nil . (arg)))))) ;; invalid function with valid arg (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ((t . (arg)))))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ((42 . (arg)))))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions (("fn" . (arg)))))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions (('fn . (arg)))))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ((:fn . (arg)))))) ;; valid function with invalid arg (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ((fn . (nil)))))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ((fn . (t)))))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ((fn . (42)))))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ((fn . ("arg")))))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ((fn . ('arg)))))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ((fn . (:arg)))))) (should-error (eval '(exordium-require 'init-require.t-dummy - "modules" :functions ((fn . '(arg))))))) (provide 'init-require.t) diff --git a/themes/atom-one-theme.el b/themes/atom-one-theme.el index f4c37724..6ecd6aca 100644 --- a/themes/atom-one-theme.el +++ b/themes/atom-one-theme.el @@ -7,7 +7,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-atom-one "themes" define-atom-one-theme) +(exordium-require 'color-theme-atom-one :location "themes") (define-atom-one-theme) diff --git a/themes/github-modern-theme.el b/themes/github-modern-theme.el index 140ae22f..74c5cada 100644 --- a/themes/github-modern-theme.el +++ b/themes/github-modern-theme.el @@ -8,7 +8,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-github-modern "themes" define-github-modern-theme) +(exordium-require 'color-theme-github-modern :location "themes") (define-github-modern-theme) diff --git a/themes/material-theme.el b/themes/material-theme.el index c7f09a7c..2be1bead 100644 --- a/themes/material-theme.el +++ b/themes/material-theme.el @@ -7,7 +7,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-material "themes" define-material-theme) +(exordium-require 'color-theme-material :location "themes") (define-material-theme) diff --git a/themes/monokai-theme.el b/themes/monokai-theme.el index 4e54b9f2..c7a3760b 100644 --- a/themes/monokai-theme.el +++ b/themes/monokai-theme.el @@ -8,7 +8,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-monokai "themes" define-monokai-theme) +(exordium-require 'color-theme-monokai :location "themes") (define-monokai-theme) diff --git a/themes/solarized-dark-theme.el b/themes/solarized-dark-theme.el index 8180dd0c..893a0ff1 100644 --- a/themes/solarized-dark-theme.el +++ b/themes/solarized-dark-theme.el @@ -8,7 +8,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-solarized "themes") +(exordium-require 'color-theme-solarized :location "themes") (define-solarized-theme dark) diff --git a/themes/solarized-light-theme.el b/themes/solarized-light-theme.el index b3aafa1b..b59bba49 100644 --- a/themes/solarized-light-theme.el +++ b/themes/solarized-light-theme.el @@ -7,7 +7,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-solarized "themes") +(exordium-require 'color-theme-solarized :location "themes") (define-solarized-theme light) diff --git a/themes/tomorrow-day-theme.el b/themes/tomorrow-day-theme.el index 8ed5a7fd..a22839fa 100644 --- a/themes/tomorrow-day-theme.el +++ b/themes/tomorrow-day-theme.el @@ -8,7 +8,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-tomorrow "themes") +(exordium-require 'color-theme-tomorrow :location "themes") (define-tomorrow-theme day) diff --git a/themes/tomorrow-night-blue-theme.el b/themes/tomorrow-night-blue-theme.el index d3df9664..972b36b8 100644 --- a/themes/tomorrow-night-blue-theme.el +++ b/themes/tomorrow-night-blue-theme.el @@ -8,7 +8,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-tomorrow "themes") +(exordium-require 'color-theme-tomorrow :location "themes") (define-tomorrow-theme night-blue) diff --git a/themes/tomorrow-night-bright-theme.el b/themes/tomorrow-night-bright-theme.el index 1faa4c1b..8acca60b 100644 --- a/themes/tomorrow-night-bright-theme.el +++ b/themes/tomorrow-night-bright-theme.el @@ -8,7 +8,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-tomorrow "themes") +(exordium-require 'color-theme-tomorrow :location "themes") (define-tomorrow-theme night-bright) diff --git a/themes/tomorrow-night-eighties-theme.el b/themes/tomorrow-night-eighties-theme.el index c9898f29..a42cf66c 100644 --- a/themes/tomorrow-night-eighties-theme.el +++ b/themes/tomorrow-night-eighties-theme.el @@ -8,7 +8,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-tomorrow "themes") +(exordium-require 'color-theme-tomorrow :location "themes") (define-tomorrow-theme night-eighties) diff --git a/themes/tomorrow-night-theme.el b/themes/tomorrow-night-theme.el index cdec0c35..71ceed55 100644 --- a/themes/tomorrow-night-theme.el +++ b/themes/tomorrow-night-theme.el @@ -8,7 +8,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-tomorrow "themes") +(exordium-require 'color-theme-tomorrow :location "themes") (define-tomorrow-theme night) diff --git a/themes/zenburn-theme.el b/themes/zenburn-theme.el index 135552af..06099a6c 100644 --- a/themes/zenburn-theme.el +++ b/themes/zenburn-theme.el @@ -8,7 +8,7 @@ (unless (featurep 'init-require) (load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) -(exordium-require 'color-theme-zenburn "themes" define-zenburn-theme) +(exordium-require 'color-theme-zenburn :location "themes") (define-zenburn-theme)