OSDN Git Service

update define-minor-mode for Emacs 28.1
authorHiraoka <khi@users.osdn.me>
Tue, 28 Dec 2021 11:45:35 +0000 (20:45 +0900)
committerHiraoka <khi@users.osdn.me>
Tue, 28 Dec 2021 11:45:35 +0000 (20:45 +0900)
ChangeLog
action-lock.el
howm-mode.el
illusion.el

index fd7c95d..aedb103 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2021-04-29  HIRAOKA Kazuyuki  <khi@users.osdn.me>
+
+       * 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  <khi@users.osdn.me>
 
        * howm-view.el (howm-view-summary-mode): add TAB and M-TAB to docstring
 2021-04-28  HIRAOKA Kazuyuki  <khi@users.osdn.me>
 
        * howm-view.el (howm-view-summary-mode): add TAB and M-TAB to docstring
index 091a5e7..283158a 100644 (file)
 (defvar action-lock-switch-default '("{ }" "{*}" "{-}"))  ;; any number
 (defvar action-lock-date-default '("{_}" "[%Y-%m-%d %H:%M]"))  ;; before after
 
 (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
 "
   "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)
 
 (defvar action-lock-rules nil)
 (defvar action-lock-original-font-lock-keywords nil)
index e856199..daae8b4 100644 (file)
@@ -249,7 +249,7 @@ in `howm-template'. %s is replaced with name of last file. See `format'.")
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Definitions
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; 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.
   "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
 "
 \\[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)
 
 (defun howm-set-keymap ()
   (mapc (lambda (entry)
index dbe2501..f8eb6db 100644 (file)
@@ -52,7 +52,7 @@ It must return non-nil value for successful case.")
   (goto-char (point-min))
   (set-buffer-modified-p nil))
 
   (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.
   "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
 "
 ---    -------
 \\[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.
 ;;; Example
 
 ;; M-x yarot13-find-file to open rot13ed file.