diff --git a/etc/NEWS b/etc/NEWS index a28f5c9a65a..6ae79e6cebc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -350,6 +350,15 @@ next button, even if the mode has bound it to something else. This also means that 'TAB' on a button in an 'outline-minor-mode' heading will move point instead of collapsing the outline. +--- +** 'outline-minor-mode-cycle-map' is now parent of 'outline-minor-mode'. +Instead of adding font-lock text property 'keymap' with +'outline-minor-mode-cycle' on outline headings in 'outline-minor-mode', +the keymap 'outline-minor-mode-cycle' is now active in the whole buffer. +But keybindings in 'outline-minor-mode-cycle' are still take effect +only on outline headings because they are bound with the help of +'outline-minor-mode-cycle--bind' that checks if point is on a heading. + --- ** 'Info-default-directory-list' is no longer populated at Emacs startup. If you have code in your init file that removes directories from diff --git a/lisp/outline.el b/lisp/outline.el index 91f6040687b..26e41735a01 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -210,7 +210,12 @@ outline-minor-mode-cycle-filter (defvar outline-minor-mode-cycle) (defun outline-minor-mode-cycle--bind (map key binding &optional filter) - (define-key map key + "Define KEY as BINDING in MAP using FILTER. +The key takes effect only on the following conditions: +`outline-minor-mode-cycle' is non-nil, point is located on the heading line, +FILTER or `outline-minor-mode-cycle-filter' is nil or returns non-nil. +The argument MAP is optional and defaults to `outline-minor-mode-cycle-map'." + (define-key (or map outline-minor-mode-cycle-map) key `(menu-item "" ,binding ;; Filter out specific positions on the heading. @@ -227,8 +232,16 @@ outline-minor-mode-cycle-map (let ((map (make-sparse-keymap))) (outline-minor-mode-cycle--bind map (kbd "TAB") #'outline-cycle) (outline-minor-mode-cycle--bind map (kbd "") #'outline-cycle-buffer) + (keymap-set map " " 'outline-cycle) + (keymap-set map " " 'outline-cycle) + (keymap-set map " S-" 'outline-cycle-buffer) + (keymap-set map " S-" 'outline-cycle-buffer) map) - "Keymap used by `outline-minor-mode-cycle'.") + "Keymap used as a parent of the `outline-minor-mode' keymap. +It contains key bindings that can be used to cycle visibility. +The recommended way to bind keys is with `outline-minor-mode-cycle--bind' +when the key should be enabled only when `outline-minor-mode-cycle' is +non-nil and point is located on the heading line.") (defvar outline-mode-map (let ((map (make-sparse-keymap))) @@ -518,10 +532,6 @@ outline-minor-mode :keymap (define-keymap :parent outline-minor-mode-cycle-map "" outline-minor-mode-menu-bar-map - " " 'outline-cycle - " " 'outline-cycle - " S-" 'outline-cycle-buffer - " S-" 'outline-cycle-buffer (key-description outline-minor-mode-prefix) outline-mode-prefix-map) (if outline-minor-mode (progn