branch: externals/leaf commit 1274e355f463defa31a6fc337d92110c01019869 Merge: 8a78547 eb8ce41 Author: Naoya Yamashita <con...@gmail.com> Commit: Naoya Yamashita <con...@gmail.com>
Merge remote-tracking branch 'origin/master' into fix-leaf-find-in-embedded-leaf-block --- leaf-tests.el | 12 ++++++------ leaf.el | 32 +++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/leaf-tests.el b/leaf-tests.el index f786db0..3a8e607 100644 --- a/leaf-tests.el +++ b/leaf-tests.el @@ -2409,37 +2409,37 @@ Example: '(((leaf-key "C-M-i" 'flyspell-correct-wrapper) (let* ((old (lookup-key global-map (kbd "C-M-i"))) (value `(global-map "C-M-i" flyspell-correct-wrapper ,(and old (not (numberp old)) old) nil))) - (push value leaf-key-bindlist) + (leaf-safe-push value leaf-key-bindlist) (define-key global-map (kbd "C-M-i") 'flyspell-correct-wrapper))) ((leaf-key [remap backward-sentence] 'sh-beginning-of-command) (let* ((old (lookup-key global-map [remap backward-sentence])) (value `(global-map "<remap> <backward-sentence>" sh-beginning-of-command ,(and old (not (numberp old)) old) nil))) - (push value leaf-key-bindlist) + (leaf-safe-push value leaf-key-bindlist) (define-key global-map [remap backward-sentence] 'sh-beginning-of-command))) ((leaf-key "C-M-i" 'flyspell-correct-wrapper 'c-mode-map) (let* ((old (lookup-key c-mode-map (kbd "C-M-i"))) (value `(c-mode-map "C-M-i" flyspell-correct-wrapper ,(and old (not (numberp old)) old) nil))) - (push value leaf-key-bindlist) + (leaf-safe-push value leaf-key-bindlist) (define-key c-mode-map (kbd "C-M-i") 'flyspell-correct-wrapper))) ((leaf-key [remap backward-sentence] 'sh-beginning-of-command 'shell-mode-map) (let* ((old (lookup-key shell-mode-map [remap backward-sentence])) (value `(shell-mode-map "<remap> <backward-sentence>" sh-beginning-of-command ,(and old (not (numberp old)) old) nil))) - (push value leaf-key-bindlist) + (leaf-safe-push value leaf-key-bindlist) (define-key shell-mode-map [remap backward-sentence] 'sh-beginning-of-command))) ((leaf-key (vector 'key-chord ?i ?j) 'undo nil) (let* ((old (lookup-key global-map [key-chord 105 106])) (value `(global-map "<key-chord> i j" undo ,(and old (not (numberp old)) old) nil))) - (push value leaf-key-bindlist) + (leaf-safe-push value leaf-key-bindlist) (define-key global-map [key-chord 105 106] 'undo))) ((leaf-key [(control ?x) (control ?f)] 'undo) (let* ((old (lookup-key global-map [(control 120) (control 102)])) (value `(global-map "C-x C-f" undo ,(and old (not (numberp old)) old) nil))) - (push value leaf-key-bindlist) + (leaf-safe-push value leaf-key-bindlist) (define-key global-map [(control 120) (control 102)] 'undo)))))) (when (version< "24.0" emacs-version) diff --git a/leaf.el b/leaf.el index ee9eaef..ce62eda 100644 --- a/leaf.el +++ b/leaf.el @@ -5,7 +5,7 @@ ;; Author: Naoya Yamashita <con...@gmail.com> ;; Maintainer: Naoya Yamashita <con...@gmail.com> ;; Keywords: lisp settings -;; Version: 4.4.4 +;; Version: 4.4.6 ;; URL: https://github.com/conao3/leaf.el ;; Package-Requires: ((emacs "24.1")) @@ -362,15 +362,21 @@ Sort by `leaf-sort-leaf--values-plist' in this order.") (defcustom leaf-defaults '() "The value that are interpreted as specified for all `leaf' blocks." - :type 'sexp + :type '(plist :key-type (choice (const :leaf-autoload) + (const :leaf-defer) + (const :leaf-protect) + (const :leaf-defun) + (const :leaf-defvar) + (const :leaf-path) + (symbol :tag "A keyword in `M-x leaf-available-keywords`")) + :value-type (choice boolean + (sexp :tag "Default value of the keyword"))) :group 'leaf) -(defcustom leaf-system-defaults (leaf-list - :leaf-autoload t :leaf-defer t :leaf-protect t - :leaf-defun t :leaf-defvar t :leaf-path t) - "The value for all `leaf' blocks for leaf system." - :type 'sexp - :group 'leaf) +(defvar leaf-system-defaults (list + :leaf-autoload t :leaf-defer t :leaf-protect t + :leaf-defun t :leaf-defvar t :leaf-path t) + "The value for all `leaf' blocks for leaf system.") (defcustom leaf-defer-keywords (list :bind :bind* @@ -768,6 +774,14 @@ see `alist-get'." (indent-region (point-min) (point-max)) (display-buffer buf)))) +(defmacro leaf-safe-push (newelt place) + "Safely add NEWELT to the list stored in the generalized variable PLACE. +This is equivalent to `push' if PLACE is bound, otherwise, `setq' +is used to define a new list." + `(if (boundp ',place) + (push ,newelt ,place) + (setq ,place (list ,newelt)))) + ;;;; find-function @@ -840,7 +854,7 @@ For example: (mstr (if (stringp key*) key* (key-description key*)))) `(let* ((old (lookup-key ,mmap ,(if vecp key* `(kbd ,key*)))) (value ,(list '\` `(,mmap ,mstr ,command* ,',(and old (not (numberp old)) old) ,path)))) - (push value leaf-key-bindlist) + (leaf-safe-push value leaf-key-bindlist) (define-key ,mmap ,(if vecp key* `(kbd ,key*)) ',command*)))) (defmacro leaf-key* (key command)