~pkal/setup

9782c22ada83623915ca5c696a13a675d4782b30 — Philip Kaludercic 7 months ago 84bff3e
Check for symbol properties to improve context guessing

The symbol properties `setup-mode', `setup-hook' and `setup-map' can
be assigned to feature names and mode definitions. This could allow
package maintainers to improve the usability of their packages with
setup, in case their naming doesn't fit the usual conventions.
1 files changed, 13 insertions(+), 5 deletions(-)

M setup.el
M setup.el => setup.el +13 -5
@@ 49,6 49,8 @@
;;;; Version 1.2.0
;;
;; - Remove `setup-wrap-to-demote-errors' from `setup-modifier-list'
;; - Let `:with-feature' and `:with-mode' check symbol properties to
;;   improve context-setting guesses.

;;; Code:



@@ 325,9 327,13 @@ and VAL into one s-expression."
                                     feature
                                   (intern (format "%s-mode" feature))))
                           (setup-opts `((feature . ,feature)
                                         (mode . ,mode)
                                         (hook . ,(intern (format "%s-hook" mode)))
                                         (map . ,(intern (format "%s-map" mode)))
                                         (mode . ,(or (get features 'setup-mode) mode))
                                         (hook . ,(or (get features 'setup-hook)
                                                      (get mode 'setup-hook)
                                                      (intern (format "%s-hook" mode))))
                                         (map . ,(or (get features 'setup-map)
                                                     (get mode 'setup-map)
                                                     (intern (format "%s-map" mode))))
                                         ,@setup-opts)))
                      (setup-expand body))
                  body)


@@ 345,8 351,10 @@ If FEATURE is a list, apply BODY to all elements of FEATURE."
      (let (bodies)
        (dolist (mode (if (listp modes) modes (list modes)))
          (push (let ((setup-opts `((mode . ,mode)
                                    (hook . ,(intern (format "%s-hook" mode)))
                                    (map . ,(intern (format "%s-map" mode)))
                                    (hook . ,(or (get mode 'setup-hook)
                                                 (intern (format "%s-hook" mode))))
                                    (map . ,(or (get mode 'setup-map)
                                                (intern (format "%s-map" mode))))
                                    ,@setup-opts)))
                  (setup-expand body))
                bodies))