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

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

Changing outline-minor-mode keybindings for texinfo files


From: michael-franzese
Subject: Changing outline-minor-mode keybindings for texinfo files
Date: Fri, 14 May 2021 18:36:08 +0200


> Sent: Saturday, May 15, 2021 at 4:20 AM
> From: "Yuri Khan" <yuri.v.khan@gmail.com>
> To: michael-franzese@gmx.com
> Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>, "Jean Louis" <bugs@gnu.support>
> Subject: Re: Changing outline-minor-mode keybindings for texinfo files
>
> On Fri, 14 May 2021 at 20:33, <michael-franzese@gmx.com> wrote:
> 
> > Have wade to following adaptation which seems to work.  Still I would value
> > comments and points of view.
> >
> > (defun vmove-keytrigger ()
> >    "Visualises outline and moves texinfo code."
> 
> This docstring is inaccurate, and uses the wrong grammatical form.
> (Docstrings, by convention, use the imperative form.) Better:
> 
> "Set up keys for use in texinfo-mode."
> 
> >    (let ( (map texinfo-mode-map) )
> >      (define-key map (kbd "H-q") #'outline-hide-sublevels)
> >      (define-key map (kbd "H-b") #'outline-hide-body)
> >      (define-key map (kbd "H-<up>") #'outline-move-subtree-up)
> >      (define-key map (kbd "H-<down>") #'outline-move-subtree-down) ))
> 
> The let binding is redundant, you could call ‘define-key’ directly on
> ‘texinfo-mode-map’:
> 
> (defun vmove-keytrigger ()
>    "Set up keys for use in texinfo-mode."
>    (define-key texinfo-mode-map (kbd "H-q") #'outline-hide-sublevels)
>    (define-key texinfo-mode-map (kbd "H-b") #'outline-hide-body)
>    (define-key texinfo-mode-map (kbd "H-<up>") #'outline-move-subtree-up)
>    (define-key texinfo-mode-map (kbd "H-<down>") #'outline-move-subtree-down) 
> ))
> 
> 
> > (add-hook 'texinfo-mode-hook 'vmove-keytrigger)
> 
> This too is excessive. You redefine these keys each time you open a
> new buffer in texinfo mode, but it is sufficient to define them once
> during an Emacs session. You cannot just put (define-key
> texinfo-mode-map …) in your init file because the variable
> ‘texinfo-mode-map’ is probably not defined at the time of
> initialization, but you can defer that to the time when ‘texinfo’ is
> loaded:
> 
> (with-eval-after-load 'texinfo
>   (define-key texinfo-mode-map (kbd "H-q") #'outline-hide-sublevels)
>   (define-key texinfo-mode-map (kbd "H-b") #'outline-hide-body)
>   (define-key texinfo-mode-map (kbd "H-<up>") #'outline-move-subtree-up)
>   (define-key texinfo-mode-map (kbd "H-<down>") #'outline-move-subtree-down))
> 
> 
> (Note that ‘with-eval-after-load’ is a relatively new macro; on older
> Emacs versions, you might have to use ‘eval-after-load’ which is
> slightly less easy to use.)

Would your comments also mean that I remove the add-hook

  (add-hook 'texinfo-mode-hook 'vmove-keytrigger)



reply via email to

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