diff options
| author | Phil Sainty | 2019-11-16 15:48:44 +1300 |
|---|---|---|
| committer | Phil Sainty | 2019-11-18 21:25:36 +1300 |
| commit | 33676820bdb0fac8ebd43ab098ad13d8098f3586 (patch) | |
| tree | a4e00fdc443747599ed042e863756a81f331bd64 /lisp | |
| parent | 83c50cc6efacf701ba64c2f4175ece7ebff9b338 (diff) | |
| download | emacs-33676820bdb0fac8ebd43ab098ad13d8098f3586.tar.gz emacs-33676820bdb0fac8ebd43ab098ad13d8098f3586.zip | |
lisp/so-long.el: Refactor menu action commands
* lisp/so-long.el (so-long-menu): Call `so-long' with an ACTION
argument instead of using `so-long-menu-item-replace-action'.
(so-long-menu-item-replace-action): Remove the deprecated function.
* test/lisp/so-long-tests/so-long-tests.el
(so-long-tests-so-long-menu-item-replace-action): Update the test.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/so-long.el | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/lisp/so-long.el b/lisp/so-long.el index e80abc76a53..33b7155d044 100644 --- a/lisp/so-long.el +++ b/lisp/so-long.el | |||
| @@ -902,14 +902,19 @@ If RESET is non-nil, remove any existing values before storing the new ones." | |||
| 902 | `(menu-item | 902 | `(menu-item |
| 903 | ,label | 903 | ,label |
| 904 | ,(let ((sym (make-symbol "so-long-menu-item-replace-action"))) | 904 | ,(let ((sym (make-symbol "so-long-menu-item-replace-action"))) |
| 905 | ;; Using a symbol here, so that `describe-key' on the menu item | 905 | ;; We make a symbol so that `describe-key' on the menu item |
| 906 | ;; produces the `so-long-menu-item-replace-action' documentation. | 906 | ;; produces something more descriptive than byte code. There is |
| 907 | (defalias sym | 907 | ;; no interned `so-long-menu-item-replace-action' which might |
| 908 | (apply-partially #'so-long-menu-item-replace-action item) | 908 | ;; make this slightly confusing -- but only in the rare situation |
| 909 | (documentation #'so-long-menu-item-replace-action)) | 909 | ;; when someone uses `describe-key' on one of these menu items, |
| 910 | (put sym 'interactive-form '(interactive "@")) | 910 | ;; and then wants to find more information. We mitigate this by |
| 911 | ;; We use "@" as commands in the mode-line menu may be | 911 | ;; making the following docstring very clear. |
| 912 | ;; triggered by mouse when some other window is selected. | 912 | (defalias sym (lambda () (interactive "@") (so-long key)) |
| 913 | ;; We use "@" as commands in the mode-line menu may be | ||
| 914 | ;; triggered by mouse when some other window is selected. | ||
| 915 | "Revert the current action and invoke the chosen replacement. | ||
| 916 | |||
| 917 | This commmand calls `so-long' with the selected action as an argument.") | ||
| 913 | sym) | 918 | sym) |
| 914 | :enable (not (and so-long--active | 919 | :enable (not (and so-long--active |
| 915 | (eq ',actionfunc so-long-function) | 920 | (eq ',actionfunc so-long-function) |
| @@ -925,20 +930,6 @@ If RESET is non-nil, remove any existing values before storing the new ones." | |||
| 925 | '(menu-item "Customize" so-long-customize)) | 930 | '(menu-item "Customize" so-long-customize)) |
| 926 | map)) | 931 | map)) |
| 927 | 932 | ||
| 928 | (defun so-long-menu-item-replace-action (replacement) | ||
| 929 | "Revert the current action and invoke the specified replacement. | ||
| 930 | |||
| 931 | REPLACEMENT is a `so-long-action-alist' item." | ||
| 932 | (interactive) | ||
| 933 | (when so-long--active | ||
| 934 | (so-long-revert)) | ||
| 935 | (cl-destructuring-bind (_key _label actionfunc revertfunc) | ||
| 936 | replacement | ||
| 937 | (setq so-long-function actionfunc) | ||
| 938 | (setq so-long-revert-function revertfunc) | ||
| 939 | (setq this-command 'so-long) | ||
| 940 | (so-long))) | ||
| 941 | |||
| 942 | ;;;###autoload | 933 | ;;;###autoload |
| 943 | (defun so-long-commentary () | 934 | (defun so-long-commentary () |
| 944 | "View the so-long documentation in `outline-mode'." | 935 | "View the so-long documentation in `outline-mode'." |