From: Hiraoka Date: Tue, 28 Dec 2021 11:45:35 +0000 (+0900) Subject: update define-minor-mode for Emacs 28.1 X-Git-Url: http://git.osdn.net/view?p=howm%2Fhowm.git;a=commitdiff_plain;h=9fa0ebdc66cff933118e69fdb52424c7aa8c4993 update define-minor-mode for Emacs 28.1 --- diff --git a/ChangeLog b/ChangeLog index fd7c95d..aedb103 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2021-04-29 HIRAOKA Kazuyuki + + * howm-mode.el (howm-mode): update define-minor-mode for emacs 28.1 + thx > U5948U5e7eU4e43 + https://twitter.com/U5948U5e7eU4e43/status/1387373441582387209 + http://git.savannah.gnu.org/cgit/emacs.git/commit/etc/NEWS?id=2fb271ca35ff96540c0940b0ea5281bdaac953ec + + * action-lock.el (action-lock-mode): ditto. + + * illusion.el (illusion-mode): ditto. + 2021-04-28 HIRAOKA Kazuyuki * howm-view.el (howm-view-summary-mode): add TAB and M-TAB to docstring diff --git a/action-lock.el b/action-lock.el index 091a5e7..283158a 100644 --- a/action-lock.el +++ b/action-lock.el @@ -61,22 +61,21 @@ (defvar action-lock-switch-default '("{ }" "{*}" "{-}")) ;; any number (defvar action-lock-date-default '("{_}" "[%Y-%m-%d %H:%M]")) ;; before after -(easy-mmode-define-minor-mode action-lock-mode +(define-minor-mode action-lock-mode "With no argument, this command toggles the mode. Non-null prefix argument turns on the mode. Null prefix argument turns off the mode. \\[action-lock-magic-return] Envoke the action on the field " - nil ;; default = off - action-lock-lighter ;; mode-line - `( - (,action-lock-magic-return-key . action-lock-magic-return) - )) - -;; emacs20's easy-mmode-define-minor-mode can't have body. sigh... -(add-hook 'action-lock-mode-on-hook 'action-lock-initialize-buffer) -(add-hook 'action-lock-mode-off-hook 'action-lock-restore-buffer) + :init-value nil ;; default = off + :lighter action-lock-lighter ;; mode-line + :keymap `( + (,action-lock-magic-return-key . action-lock-magic-return) + ) + (if action-lock-mode + (action-lock-initialize-buffer) + (action-lock-restore-buffer))) (defvar action-lock-rules nil) (defvar action-lock-original-font-lock-keywords nil) diff --git a/howm-mode.el b/howm-mode.el index e856199..daae8b4 100644 --- a/howm-mode.el +++ b/howm-mode.el @@ -249,7 +249,7 @@ in `howm-template'. %s is replaced with name of last file. See `format'.") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Definitions -(easy-mmode-define-minor-mode howm-mode +(define-minor-mode howm-mode "With no argument, this command toggles the mode. Non-null prefix argument turns on the mode. Null prefix argument turns off the mode. @@ -280,18 +280,16 @@ key binding \\[howm-create-interactively] Create new file interactively (not recommended) \\[howm-random-walk] Browse random entries automtically " - nil ;; default = off - howm-lighter ;; mode-line - (mapcar (lambda (entry) - (let ((k (car entry)) - (f (cadr entry))) - (cons (concat howm-prefix k) f))) - howm-default-key-table) - ) - -;; emacs20's easy-mmode-define-minor-mode can't have body. sigh... -(add-hook 'howm-mode-on-hook 'howm-initialize-buffer) -(add-hook 'howm-mode-off-hook 'howm-restore-buffer) + :init-value nil ;; default = off + :lighter howm-lighter ;; mode-line + :keymap (mapcar (lambda (entry) + (let ((k (car entry)) + (f (cadr entry))) + (cons (concat howm-prefix k) f))) + howm-default-key-table) + (if howm-mode + (howm-initialize-buffer) + (howm-restore-buffer))) (defun howm-set-keymap () (mapc (lambda (entry) diff --git a/illusion.el b/illusion.el index dbe2501..f8eb6db 100644 --- a/illusion.el +++ b/illusion.el @@ -52,7 +52,7 @@ It must return non-nil value for successful case.") (goto-char (point-min)) (set-buffer-modified-p nil)) -(easy-mmode-define-minor-mode illusion-mode +(define-minor-mode illusion-mode "With no argument, this command toggles the mode. Non-null prefix argument turns on the mode. Null prefix argument turns off the mode. @@ -64,17 +64,14 @@ key binding --- ------- \\[illusion-submit] Submit changes " - nil ;; default = off - illusion-lighter ;; mode-line - `( - (,illusion-submit-key . illusion-submit) - ) + :init-value nil ;; default = off + :lighter illusion-lighter ;; mode-line + :keymap `( + (,illusion-submit-key . illusion-submit) + ) + (use-local-map illusion-mode-map) ) -;; emacs20's easy-mmode-define-minor-mode can't have body. sigh... -(add-hook 'illusion-mode-on-hook - (lambda () (use-local-map illusion-mode-map))) - ;;; Example ;; M-x yarot13-find-file to open rot13ed file.