* lisp/outline.el (outline-minor-mode-cycle-filter): New defcustom (bug#50679)
(outline-minor-mode-cycle--bind): New helper function.
(outline-minor-mode-cycle-map): Rename from outline-mode-cycle-map.
(outline-mode-map): Revert part of 6458e16f33
to disassociate
keymaps outline-mode-map and outline-minor-mode-cycle-map.
(outline-font-lock-keywords, outline-minor-mode-highlight-buffer):
Use outline-minor-mode-cycle-map instead of outline-mode-cycle-map.
* lisp/help.el (describe-bindings): Rename outline-mode-cycle-map
to outline-minor-mode-cycle-map.
This commit is contained in:
parent
ebe8b8f89e
commit
da50b7ec13
2 changed files with 36 additions and 14 deletions
|
@ -597,7 +597,7 @@ or a buffer name."
|
|||
(let ((inhibit-read-only t))
|
||||
(goto-char (point-min))
|
||||
(insert (substitute-command-keys
|
||||
(concat "\\<outline-mode-cycle-map>Type "
|
||||
(concat "\\<outline-minor-mode-cycle-map>Type "
|
||||
"\\[outline-cycle] or \\[outline-cycle-buffer] "
|
||||
"on headings to cycle their visibility.\n\n")))
|
||||
;; Hide the longest body
|
||||
|
|
|
@ -175,23 +175,45 @@ in the file it applies to.")
|
|||
outline-mode-menu-bar-map))))))
|
||||
map))
|
||||
|
||||
(defvar outline-mode-cycle-map
|
||||
(defcustom outline-minor-mode-cycle-filter nil
|
||||
"Filter out positions on the heading available for cycling."
|
||||
:type '(choice (const :tag "Everywhere" nil)
|
||||
(const :tag "At line beginning" bolp)
|
||||
(const :tag "Not at line beginning"
|
||||
(lambda () (not (bolp))))
|
||||
(const :tag "At line end" eolp)
|
||||
(function :tag "Custom filter"))
|
||||
:version "28.1")
|
||||
|
||||
(defun outline-minor-mode-cycle--bind (map key binding &optional filter)
|
||||
(define-key map key
|
||||
`(menu-item
|
||||
"" ,binding
|
||||
;; Filter out specific positions on the heading.
|
||||
:filter
|
||||
,(or filter
|
||||
(lambda (cmd)
|
||||
(when (or (not (functionp outline-minor-mode-cycle-filter))
|
||||
(funcall outline-minor-mode-cycle-filter))
|
||||
cmd))))))
|
||||
|
||||
(defvar outline-minor-mode-cycle-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(let ((tab-binding `(menu-item
|
||||
"" outline-cycle
|
||||
;; Only takes effect if point is on a heading.
|
||||
:filter ,(lambda (cmd)
|
||||
(when (outline-on-heading-p) cmd)))))
|
||||
(define-key map (kbd "TAB") tab-binding)
|
||||
(define-key map (kbd "<backtab>") #'outline-cycle-buffer))
|
||||
(outline-minor-mode-cycle--bind map (kbd "TAB") #'outline-cycle)
|
||||
(outline-minor-mode-cycle--bind map (kbd "<backtab>") #'outline-cycle-buffer)
|
||||
map)
|
||||
"Keymap used by `outline-mode-map' and `outline-minor-mode-cycle'.")
|
||||
"Keymap used by `outline-minor-mode-cycle'.")
|
||||
|
||||
(defvar outline-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(set-keymap-parent map outline-mode-cycle-map)
|
||||
(define-key map "\C-c" outline-mode-prefix-map)
|
||||
(define-key map [menu-bar] outline-mode-menu-bar-map)
|
||||
;; Only takes effect if point is on a heading.
|
||||
(define-key map (kbd "TAB")
|
||||
`(menu-item "" outline-cycle
|
||||
:filter ,(lambda (cmd)
|
||||
(when (outline-on-heading-p) cmd))))
|
||||
(define-key map (kbd "<backtab>") #'outline-cycle-buffer)
|
||||
map))
|
||||
|
||||
(defvar outline-font-lock-keywords
|
||||
|
@ -202,9 +224,9 @@ in the file it applies to.")
|
|||
(if outline-minor-mode-cycle
|
||||
(if outline-minor-mode-highlight
|
||||
(list 'face (outline-font-lock-face)
|
||||
'keymap outline-mode-cycle-map)
|
||||
'keymap outline-minor-mode-cycle-map)
|
||||
(list 'face nil
|
||||
'keymap outline-mode-cycle-map))
|
||||
'keymap outline-minor-mode-cycle-map))
|
||||
(if outline-minor-mode-highlight
|
||||
(list 'face (outline-font-lock-face))))
|
||||
(outline-font-lock-face))
|
||||
|
@ -367,7 +389,7 @@ faces to major mode's faces."
|
|||
(not (get-text-property (point) 'face))))
|
||||
(overlay-put overlay 'face (outline-font-lock-face)))
|
||||
(when outline-minor-mode-cycle
|
||||
(overlay-put overlay 'keymap outline-mode-cycle-map)))
|
||||
(overlay-put overlay 'keymap outline-minor-mode-cycle-map)))
|
||||
(goto-char (match-end 0))))))
|
||||
|
||||
;;;###autoload
|
||||
|
|
Loading…
Add table
Reference in a new issue