branch: externals/leaf commit fbe9bfba5ef4c99ee190b259a5e3341dd7a71935 Merge: 39e0359 1ee956d Author: Naoya Yamashita <con...@gmail.com> Commit: GitHub <nore...@github.com>
Merge pull request #468 from Z572/leaf-key-list-mode Let the leaf-key-describe-bindings with a path --- leaf-tests.el | 12 ++++++------ leaf.el | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/leaf-tests.el b/leaf-tests.el index ff4f92d..998694a 100644 --- a/leaf-tests.el +++ b/leaf-tests.el @@ -2270,37 +2270,37 @@ Example: (cort-deftest-with-macroexpand leaf/leaf-key '(((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)))) + (value `(global-map "C-M-i" flyspell-correct-wrapper ,(and old (not (numberp old)) old) nil))) (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)))) + (value `(global-map "<remap> <backward-sentence>" sh-beginning-of-command ,(and old (not (numberp old)) old) nil))) (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)))) + (value `(c-mode-map "C-M-i" flyspell-correct-wrapper ,(and old (not (numberp old)) old) nil))) (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)))) + (value `(shell-mode-map "<remap> <backward-sentence>" sh-beginning-of-command ,(and old (not (numberp old)) old) nil))) (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 (vector 'key-chord 105 106))) - (value `(global-map "<key-chord> i j" undo ,(and old (not (numberp old)) old)))) + (value `(global-map "<key-chord> i j" undo ,(and old (not (numberp old)) old) nil))) (push value leaf-key-bindlist) (define-key global-map (vector '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)))) + (value `(global-map "C-x C-f" undo ,(and old (not (numberp old)) old) nil))) (push value leaf-key-bindlist) (define-key global-map [(control 120) (control 102)] 'undo)))))) diff --git a/leaf.el b/leaf.el index 933194b..ff45cd1 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.3.8 +;; Version: 4.3.9 ;; URL: https://github.com/conao3/leaf.el ;; Package-Requires: ((emacs "24.1")) @@ -619,6 +619,12 @@ see `alist-get'." (when load-file-name (format " at `%s'" load-file-name)))) +(defun leaf-this-file () + "Return path to this file." + (or load-file-name + (and (boundp 'byte-compile-current-file) byte-compile-current-file) + buffer-file-name)) + ;;;; General functions for leaf @@ -788,7 +794,7 @@ see `alist-get'." (defvar leaf-key-bindlist nil "List of bindings performed by `leaf-key'. -Elements have the form (MAP KEY CMD ORIGINAL-CMD)") +Elements have the form (MAP KEY CMD ORIGINAL-CMD PATH)") (defmacro leaf-key (key command &optional keymap) "Bind KEY to COMMAND in KEYMAP (`global-map' if not passed). @@ -817,10 +823,11 @@ For example: (keymap* (eval keymap)) (mmap (or keymap* 'global-map)) (vecp (vectorp key*)) + (path (leaf-this-file)) (_mvec (if (vectorp key*) key* (read-kbd-macro key*))) (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))))) + (value ,(list '\` `(,mmap ,mstr ,command* ,',(and old (not (numberp old)) old) ,path)))) (push value leaf-key-bindlist) (define-key ,mmap ,(if vecp key `(kbd ,key)) ',command*)))) @@ -909,7 +916,8 @@ BIND must not contain :{{map}}." (setq tabulated-list-format [("Map" 20 t) ("Key" 20 t) ("Command" 40 t) - ("Before Command" 0 t)]) + ("Before Command" 40 t) + ("Path" 0 t)]) (setq tabulated-list-entries (let ((id 0) (formatfn (lambda (elm) @@ -922,7 +930,8 @@ BIND must not contain :{{map}}." (push `(,id [,(funcall formatfn (nth 0 elm)) ,(funcall formatfn (nth 1 elm)) ,(funcall formatfn (nth 2 elm)) - ,(funcall formatfn (nth 3 elm))]) + ,(funcall formatfn (nth 3 elm)) + ,(funcall formatfn (nth 4 elm))]) res)) (nreverse res))) (setq tabulated-list-sort-key '("Map" . nil))