bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#1598: Please add easy key bindings for outline-(minor-)mode


From: Juri Linkov
Subject: bug#1598: Please add easy key bindings for outline-(minor-)mode
Date: Mon, 19 Jul 2021 18:34:11 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> The default key bindings for outline-mode and outline-minor-mode are
>> difficult to remember and slow to use. I think the main reason is that
>> there are way too many different key-bindings to operate with outlining.
>>
>> I suggest that you make keys like M-<left> and M-<right> to act modally
>> so that they open and close one outline level at the time depending on
>> which levels and bodies are currently visible. In addition to that, and
>> to make outline navigating easy, M-<up> and M-<down> could move the
>> cursor to previous and next visible outline header.
>
> I agree that the outline commands are pretty awkward...  but outline
> minor mode is used in a large number of major modes, and has to be
> consistent throughout all those modes.  So M-<arrows> can't really be
> used for this, I think.

For personal customization of keys in outline-minor-mode
now there is outline-mode-cycle-map.  Currently I'm experimenting
with using M-<arrows>, but still these keys conflict with some modes,
so M-<arrows> can't be bound by default.
Anyway, here is an example of customization:

#+begin_src emacs-lisp
(setq-default
 outline-minor-mode-cycle t
 outline-minor-mode-highlight t)

(let ((map outline-mode-cycle-map)
      (cmds '(("M-<down>"  outline-next-visible-heading)
              ("M-<up>"    outline-previous-visible-heading)
              ;; ("M-<left>"  outline-hide-subtree)
              ;; ("M-<right>" outline-show-subtree)
              )))
  (dolist (command cmds)
    (define-key map (kbd (nth 0 command))
      `(menu-item
        "" ,(nth 1 command)
        ;; Only takes effect if point is on a heading.
        :filter ,(lambda (cmd)
                   (when (and (outline-on-heading-p)
                              ;; Exclude emacs-lisp-mode:
                              ;; outline-minor-mode-highlight
                              ;; BETTER:
                              ;; (buffer-file-name (current-buffer))
                              buffer-read-only
                              )
                     cmd))))))
#+end_src





reply via email to

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