emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs-29 4a8891a462: * etc/NEWS: Mention incompatible changes in 'ou


From: Robert Pluim
Subject: Re: emacs-29 4a8891a462: * etc/NEWS: Mention incompatible changes in 'outline-minor-mode-cycle-map'.
Date: Mon, 16 Jan 2023 20:02:34 +0100

>>>>> On Mon, 16 Jan 2023 20:26:14 +0200, Eli Zaretskii <eliz@gnu.org> said:

    >> From: Juri Linkov <juri@linkov.net>
    >> Cc: Eli Zaretskii <eliz@gnu.org>,  emacs-devel@gnu.org
    >> Date: Mon, 16 Jan 2023 19:43:10 +0200
    >> 
    >> >     Eli> Ah, okay.  Fine with me if Juri (or someone else) doesn't 
object.
    >> >
    >> >     >> (and what I really want to do is add 'n' and 'p' into that map, 
which
    >> >     >> improves the speed at which I can proofread NEWS.)
    >> >
    >> >     Eli> On master or emacs-29?
    >> >
    >> > On master. Iʼm assuming adding bindings would not fall under 'bug
    >> > fixes only'.
    >> 
    >> But maybe Eli will agree to install it on emacs-29?

    Eli> Maybe.  Robert didn't really explain what are his plans in that
    Eli> regard.

Hereʼs the complete patch (minus doc changes). I was thinking putting
the outline.el bits in emacs-29, to make it easier for everybody to
change the bindings, and then changing the bindings in news-mode in
master.

Or we could just stick the whole thing in master.

Robert
-- 

diff --git c/lisp/outline.el i/lisp/outline.el
index 91f6040687b..6fb9281f61e 100644
--- c/lisp/outline.el
+++ i/lisp/outline.el
@@ -1766,6 +1766,20 @@ outline-cycle-buffer

 ;;; Button/margin indicators
 
+(defvar-keymap outline-button-icon-map
+  "<mouse-2>" #'outline-cycle
+  ;; Need to override the global binding
+  ;; `mouse-appearance-menu' with <down->:
+  "S-<down-mouse-1>" #'ignore
+  "S-<mouse-1>" #'outline-cycle-buffer)
+
+(defvar-keymap outline-overlay-button-map
+  "RET" #'outline-cycle)
+
+(defvar-keymap outline-inserted-button-map
+  :parent (make-composed-keymap outline-button-icon-map
+                                outline-overlay-button-map))
+
 (defun outline--create-button-icons ()
   (pcase outline-minor-mode-use-buttons
     ('in-margins
@@ -1798,12 +1812,7 @@ outline--create-button-icons
         (propertize (icon-string icon-name)
                     'mouse-face 'default
                     'follow-link 'mouse-face
-                    'keymap (define-keymap
-                              "<mouse-2>" #'outline-cycle
-                              ;; Need to override the global binding
-                              ;; `mouse-appearance-menu' with <down->:
-                              "S-<down-mouse-1>" #'ignore
-                              "S-<mouse-1>" #'outline-cycle-buffer)))
+                    'keymap outline-button-icon-map))
       (list 'outline-open
             (if outline--use-rtl 'outline-close-rtl 'outline-close))))))
 
@@ -1829,19 +1838,13 @@ outline--insert-button
            (overlay-put o 'face (plist-get icon 'face))
            (overlay-put o 'follow-link 'mouse-face)
            (overlay-put o 'mouse-face 'highlight)
-           (overlay-put o 'keymap (define-keymap
-                                    "RET" #'outline-cycle
-                                    "<mouse-2>" #'outline-cycle
-                                    ;; Need to override the global binding
-                                    ;; `mouse-appearance-menu' with <down->:
-                                    "S-<down-mouse-1>" #'ignore
-                                    "S-<mouse-1>" #'outline-cycle-buffer)))
+           (overlay-put o 'keymap outline-inserted-button-map))
           ('in-margins
            (overlay-put o 'before-string icon)
-           (overlay-put o 'keymap (define-keymap "RET" #'outline-cycle)))
+           (overlay-put o 'keymap outline-overlay-button-map))
           (_
            (overlay-put o 'before-string icon)
-           (overlay-put o 'keymap (define-keymap "RET" #'outline-cycle))))))))
+           (overlay-put o 'keymap outline-overlay-button-map)))))))
 
 (defun outline--fix-up-all-buttons (&optional from to)
   (when outline-minor-mode-use-buttons
diff --git c/lisp/textmodes/emacs-news-mode.el 
i/lisp/textmodes/emacs-news-mode.el
index b844955e1be..31410176181 100644
--- c/lisp/textmodes/emacs-news-mode.el
+++ i/lisp/textmodes/emacs-news-mode.el
@@ -60,6 +60,11 @@ emacs-news-mode-map
   "C-x C-q" #'emacs-news-view-mode
   "<remap> <open-line>" #'emacs-news-open-line)
 
+(defvar-keymap emacs-news-heading-map
+  :parent outline-overlay-button-map
+  "n" #'outline-next-visible-heading
+  "p" #'outline-previous-visible-heading)
+
 (defvar emacs-news-view-mode-map
   ;; This is defined this way instead of inheriting because we're
   ;; deriving the mode from `special-mode' and want the keys from there.
@@ -75,7 +80,8 @@ emacs-news--mode-common
   (setq-local font-lock-defaults '(emacs-news-mode-font-lock-keywords t))
   (setq-local outline-minor-mode-cycle t
               outline-minor-mode-highlight 'append
-              outline-minor-mode-use-buttons 'in-margins)
+              outline-minor-mode-use-buttons 'in-margins
+              outline-overlay-button-map emacs-news-heading-map)
   (outline-minor-mode)
   (setq-local imenu-generic-expression outline-imenu-generic-expression)
   (emacs-etc--hide-local-variables))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]