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

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

Re: Changing outline-minor-mode keybindings for texinfo files


From: Jean Louis
Subject: Re: Changing outline-minor-mode keybindings for texinfo files
Date: Fri, 14 May 2021 17:03:25 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* michael-franzese@gmx.com <michael-franzese@gmx.com> [2021-05-14 16:32]:
> 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."
> 
>    (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) ))
> 
> (add-hook 'texinfo-mode-hook 'vmove-keytrigger)

In my opinion that hook, when it runs, internally get that all
defined, but once function finishes, nothing yields out of it, because
it is within `let' enclosure and because you are working on a
temporary variable `map'.

(let ((a 1))
     (setq a 10)) ⇒ 10

Immediately thereafter:

a - Symbol’s value as variable is void: a

because `a' variable was defined within `let' enclosure, it will not
survive after the `let' enclosure get executed.

Instead:

(defvar my-mode-map
  (let ((map (make-sparse-keymap)))
    (set-keymap-parent map  texinfo-mode-map)
    (define-key map (kbd "d") #'my-function)
    (keep-defining)
    (keep-defining)
    map) ;; return `map' here
  "Describe your map")

;; Define your derived mode 
(define-derived-mode my-mode texinfo-mode-map "My mode name" "Documentatio")

(defun my-function ()
  (interactive)
  (my-mode)
  (use-local-map my-mode-map))

add hook to my-function or run it interactively




-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
https://rms-support-letter.github.io/




reply via email to

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