* Changing outline-minor-mode keybindings for texinfo files
@ 2021-05-14 5:47 michael-franzese
2021-05-14 7:28 ` michael-franzese
0 siblings, 1 reply; 27+ messages in thread
From: michael-franzese @ 2021-05-14 5:47 UTC (permalink / raw)
To: Help Gnu Emacs
Have been following the discussion about outline-minor-mode for texinfo.
Would like to know how I can set up different keybindings for outline-hide-sublevels
outline-hide-body, outline-move-subtree-up, outline-move-subtree-down, when I am
in texinfo-mode.
Mic
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 5:47 Changing outline-minor-mode keybindings for texinfo files michael-franzese
@ 2021-05-14 7:28 ` michael-franzese
2021-05-14 9:51 ` Jean Louis
0 siblings, 1 reply; 27+ messages in thread
From: michael-franzese @ 2021-05-14 7:28 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs
Have coded things this way. Then I load a texi file and press "H-q",
but I get "H-q is undefined".
(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) ))
(defun hide-keytrigger ()
"Hides various aspects of outline structure."
(let ( (map texinfo-mode-map) )
(define-key map (kbd "H-c") #'outline-hide-entry)
(define-key map (kbd "H-l") #'outline-hide-leaves)
(define-key map (kbd "H-d") #'outline-hide-subtree)
(define-key map (kbd "H-o") #'outline-hide-other) ))
> Sent: Friday, May 14, 2021 at 5:47 PM
> From: michael-franzese@gmx.com
> To: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Changing outline-minor-mode keybindings for texinfo files
>
> Have been following the discussion about outline-minor-mode for texinfo.
>
> Would like to know how I can set up different keybindings for outline-hide-sublevels
> outline-hide-body, outline-move-subtree-up, outline-move-subtree-down, when I am
> in texinfo-mode.
>
> Mic
>
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 7:28 ` michael-franzese
@ 2021-05-14 9:51 ` Jean Louis
2021-05-14 10:04 ` michael-franzese
0 siblings, 1 reply; 27+ messages in thread
From: Jean Louis @ 2021-05-14 9:51 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs
* michael-franzese@gmx.com <michael-franzese@gmx.com> [2021-05-14 10:29]:
> Have coded things this way. Then I load a texi file and press "H-q",
> but I get "H-q is undefined".
>
> (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)
> ))
You define function but I without giving result out. You copy
texinfo-mode-map to map, and change the map, but after that all
changes are lost in such function that yields with nothing.
--
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/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 9:51 ` Jean Louis
@ 2021-05-14 10:04 ` michael-franzese
2021-05-14 12:24 ` michael-franzese
0 siblings, 1 reply; 27+ messages in thread
From: michael-franzese @ 2021-05-14 10:04 UTC (permalink / raw)
To: Jean Louis; +Cc: Help Gnu Emacs
> Sent: Friday, May 14, 2021 at 9:51 PM
> From: "Jean Louis" <bugs@gnu.support>
> To: michael-franzese@gmx.com
> Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Re: Changing outline-minor-mode keybindings for texinfo files
>
> * michael-franzese@gmx.com <michael-franzese@gmx.com> [2021-05-14 10:29]:
> > Have coded things this way. Then I load a texi file and press "H-q",
> > but I get "H-q is undefined".
> >
> > (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)
> > ))
>
> You define function but I without giving result out. You copy
> texinfo-mode-map to map, and change the map, but after that all
> changes are lost in such function that yields with nothing.
Would I need add-hook of some kind?
> --
> 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/
>
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 10:04 ` michael-franzese
@ 2021-05-14 12:24 ` michael-franzese
2021-05-14 13:31 ` michael-franzese
2021-05-14 13:55 ` Jean Louis
0 siblings, 2 replies; 27+ messages in thread
From: michael-franzese @ 2021-05-14 12:24 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs, Jean Louis
> Sent: Friday, May 14, 2021 at 10:04 PM
> From: michael-franzese@gmx.com
> To: "Jean Louis" <bugs@gnu.support>
> Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Re: Changing outline-minor-mode keybindings for texinfo files
>
> > Sent: Friday, May 14, 2021 at 9:51 PM
> > From: "Jean Louis" <bugs@gnu.support>
> > To: michael-franzese@gmx.com
> > Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> > Subject: Re: Changing outline-minor-mode keybindings for texinfo files
> >
> > * michael-franzese@gmx.com <michael-franzese@gmx.com> [2021-05-14 10:29]:
> > > Have coded things this way. Then I load a texi file and press "H-q",
> > > but I get "H-q is undefined".
> > >
> > > (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)
> > > ))
> >
> > You define function but I without giving result out. You copy
> > texinfo-mode-map to map, and change the map, but after that all
> > changes are lost in such function that yields with nothing.
>
> Would I need add-hook of some kind?
How does one go about this thing of using different keybindings rather than
the long version "C-c @ ..."?
> > --
> > 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/
> >
> >
>
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 12:24 ` michael-franzese
@ 2021-05-14 13:31 ` michael-franzese
2021-05-14 14:03 ` Jean Louis
2021-05-14 16:20 ` Yuri Khan
2021-05-14 13:55 ` Jean Louis
1 sibling, 2 replies; 27+ messages in thread
From: michael-franzese @ 2021-05-14 13:31 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs, Jean Louis
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)
> Sent: Saturday, May 15, 2021 at 12:24 AM
> From: michael-franzese@gmx.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
>
> > Sent: Friday, May 14, 2021 at 10:04 PM
> > From: michael-franzese@gmx.com
> > To: "Jean Louis" <bugs@gnu.support>
> > Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> > Subject: Re: Changing outline-minor-mode keybindings for texinfo files
> >
> > > Sent: Friday, May 14, 2021 at 9:51 PM
> > > From: "Jean Louis" <bugs@gnu.support>
> > > To: michael-franzese@gmx.com
> > > Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> > > Subject: Re: Changing outline-minor-mode keybindings for texinfo files
> > >
> > > * michael-franzese@gmx.com <michael-franzese@gmx.com> [2021-05-14 10:29]:
> > > > Have coded things this way. Then I load a texi file and press "H-q",
> > > > but I get "H-q is undefined".
> > > >
> > > > (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)
> > > > ))
> > >
> > > You define function but I without giving result out. You copy
> > > texinfo-mode-map to map, and change the map, but after that all
> > > changes are lost in such function that yields with nothing.
> >
> > Would I need add-hook of some kind?
>
> How does one go about this thing of using different keybindings rather than
> the long version "C-c @ ..."?
>
> > > --
> > > 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/
> > >
> > >
> >
> >
>
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 12:24 ` michael-franzese
2021-05-14 13:31 ` michael-franzese
@ 2021-05-14 13:55 ` Jean Louis
1 sibling, 0 replies; 27+ messages in thread
From: Jean Louis @ 2021-05-14 13:55 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs
* michael-franzese@gmx.com <michael-franzese@gmx.com> [2021-05-14 15:24]:
> How does one go about this thing of using different keybindings rather than
> the long version "C-c @ ..."?
To change the prefix, you can do:
{M-x customize-variable RET outline-minor-mode-prefix RET}
I have changed to C-c C-d, that way I press CTRL and do action.
--
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/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 13:31 ` michael-franzese
@ 2021-05-14 14:03 ` Jean Louis
2021-05-14 16:00 ` Yuri Khan
2021-05-14 16:20 ` Yuri Khan
1 sibling, 1 reply; 27+ messages in thread
From: Jean Louis @ 2021-05-14 14:03 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs
* 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/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 14:03 ` Jean Louis
@ 2021-05-14 16:00 ` Yuri Khan
2021-05-14 16:19 ` michael-franzese
2021-05-14 18:49 ` Jean Louis
0 siblings, 2 replies; 27+ messages in thread
From: Yuri Khan @ 2021-05-14 16:00 UTC (permalink / raw)
To: michael-franzese, Help Gnu Emacs
On Fri, 14 May 2021 at 21:06, Jean Louis <bugs@gnu.support> wrote:
> > (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'.
No, because ‘map’ is a reference to the same object that
‘texinfo-mode-map’ refers to. Within the functions, they are two names
of the same data structure. Changes made through one name within the
function are then visible through the other name after the function
returns.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Changing outline-minor-mode keybindings for texinfo files
2021-05-14 16:00 ` Yuri Khan
@ 2021-05-14 16:19 ` michael-franzese
2021-05-14 18:49 ` Jean Louis
1 sibling, 0 replies; 27+ messages in thread
From: michael-franzese @ 2021-05-14 16:19 UTC (permalink / raw)
To: Yuri Khan; +Cc: Help Gnu Emacs
> Sent: Saturday, May 15, 2021 at 4:00 AM
> From: "Yuri Khan" <yuri.v.khan@gmail.com>
> To: michael-franzese@gmx.com, "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Re: Changing outline-minor-mode keybindings for texinfo files
>
> On Fri, 14 May 2021 at 21:06, Jean Louis <bugs@gnu.support> wrote:
>
> > > (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'.
>
> No, because ‘map’ is a reference to the same object that
> ‘texinfo-mode-map’ refers to. Within the functions, they are two names
> of the same data structure. Changes made through one name within the
> function are then visible through the other name after the function
> returns.
So it is good?
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 13:31 ` michael-franzese
2021-05-14 14:03 ` Jean Louis
@ 2021-05-14 16:20 ` Yuri Khan
2021-05-14 16:36 ` michael-franzese
2021-05-14 18:13 ` michael-franzese
1 sibling, 2 replies; 27+ messages in thread
From: Yuri Khan @ 2021-05-14 16:20 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs, Jean Louis
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.)
^ permalink raw reply [flat|nested] 27+ messages in thread
* Changing outline-minor-mode keybindings for texinfo files
2021-05-14 16:20 ` Yuri Khan
@ 2021-05-14 16:36 ` michael-franzese
2021-05-14 20:10 ` Yuri Khan
2021-05-14 18:13 ` michael-franzese
1 sibling, 1 reply; 27+ messages in thread
From: michael-franzese @ 2021-05-14 16:36 UTC (permalink / raw)
To: Yuri Khan; +Cc: Help Gnu Emacs, Jean Louis
> 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)
^ permalink raw reply [flat|nested] 27+ messages in thread
* Changing outline-minor-mode keybindings for texinfo files
2021-05-14 16:20 ` Yuri Khan
2021-05-14 16:36 ` michael-franzese
@ 2021-05-14 18:13 ` michael-franzese
1 sibling, 0 replies; 27+ messages in thread
From: michael-franzese @ 2021-05-14 18:13 UTC (permalink / raw)
To: Yuri Khan; +Cc: Help Gnu Emacs, Jean Louis
Can with-eval-after-load be included inside a function?
> 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.)
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 16:00 ` Yuri Khan
2021-05-14 16:19 ` michael-franzese
@ 2021-05-14 18:49 ` Jean Louis
2021-05-15 21:10 ` tomas
1 sibling, 1 reply; 27+ messages in thread
From: Jean Louis @ 2021-05-14 18:49 UTC (permalink / raw)
To: Yuri Khan; +Cc: Help Gnu Emacs, michael-franzese
* Yuri Khan <yuri.v.khan@gmail.com> [2021-05-14 19:25]:
> On Fri, 14 May 2021 at 21:06, Jean Louis <bugs@gnu.support> wrote:
>
> > > (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'.
>
> No, because ‘map’ is a reference to the same object that
> ‘texinfo-mode-map’ refers to. Within the functions, they are two names
> of the same data structure. Changes made through one name within the
> function are then visible through the other name after the function
> returns.
Yes, I see by testing, it works with it as you say.
I was thinking this:
(setq a 1) ⇒ 1
(let ((b a))
(setq b 2)) ⇒ 2
a ⇒ 1
So while I understand it works, I don't know why it works.
--
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/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 16:36 ` michael-franzese
@ 2021-05-14 20:10 ` Yuri Khan
2021-05-15 5:25 ` michael-franzese
2021-05-15 5:59 ` michael-franzese
0 siblings, 2 replies; 27+ messages in thread
From: Yuri Khan @ 2021-05-14 20:10 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs, Jean Louis
On Fri, 14 May 2021 at 23:36, <michael-franzese@gmx.com> wrote:
> > > (add-hook 'texinfo-mode-hook 'vmove-keytrigger)
> > (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))
> Would your comments also mean that I remove the add-hook
>
> (add-hook 'texinfo-mode-hook 'vmove-keytrigger)
Yes.
> Can with-eval-after-load be included inside a function?
Yes if you arrange for that function to be invoked some time before
you actually try pressing those keys while in texinfo-mode.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 20:10 ` Yuri Khan
@ 2021-05-15 5:25 ` michael-franzese
2021-05-15 5:58 ` Yuri Khan
2021-05-15 5:59 ` michael-franzese
1 sibling, 1 reply; 27+ messages in thread
From: michael-franzese @ 2021-05-15 5:25 UTC (permalink / raw)
To: Yuri Khan; +Cc: Help Gnu Emacs, Jean Louis
> Sent: Saturday, May 15, 2021 at 8:10 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 23:36, <michael-franzese@gmx.com> wrote:
>
> > > > (add-hook 'texinfo-mode-hook 'vmove-keytrigger)
>
> > > (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))
>
> > Would your comments also mean that I remove the add-hook
> >
> > (add-hook 'texinfo-mode-hook 'vmove-keytrigger)
>
> Yes.
>
> > Can with-eval-after-load be included inside a function?
>
> Yes if you arrange for that function to be invoked some time before
> you actually try pressing those keys while in texinfo-mode.
I would need some implementation examples about how the function can be
invoked as you describe.
Currently I got the following
(defun show-keytrigger ()
(with-eval-after-load 'texinfo
(define-key texinfo-mode-map
(kbd "H-s") #'outline-show-subtree) ))
(add-hook 'texinfo-mode-hook 'show-keytrigger)
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-15 5:25 ` michael-franzese
@ 2021-05-15 5:58 ` Yuri Khan
2021-05-15 6:07 ` michael-franzese
0 siblings, 1 reply; 27+ messages in thread
From: Yuri Khan @ 2021-05-15 5:58 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs, Jean Louis
On Sat, 15 May 2021 at 12:25, <michael-franzese@gmx.com> wrote:
> I would need some implementation examples about how the function can be
> invoked as you describe.
>
> Currently I got the following
>
> (defun show-keytrigger ()
> (with-eval-after-load 'texinfo
> (define-key texinfo-mode-map
> (kbd "H-s") #'outline-show-subtree) ))
>
> (add-hook 'texinfo-mode-hook 'show-keytrigger)
Again, you are using a hook that runs in each new texinfo-mode buffer,
but it is sufficient to define a key once per session. You can replace
the above with just this:
(with-eval-after-load 'texinfo
(define-key texinfo-mode-map
(kbd "H-s") #'outline-show-subtree))
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 20:10 ` Yuri Khan
2021-05-15 5:25 ` michael-franzese
@ 2021-05-15 5:59 ` michael-franzese
2021-05-15 6:02 ` Yuri Khan
1 sibling, 1 reply; 27+ messages in thread
From: michael-franzese @ 2021-05-15 5:59 UTC (permalink / raw)
To: Yuri Khan; +Cc: Help Gnu Emacs, Jean Louis
Regarding keybindings, I like to have an alias keybinding for "H-o b"
so I can also use "H-b", but only applicable to texinfo-mode.
What can I use?
> Sent: Saturday, May 15, 2021 at 8:10 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 23:36, <michael-franzese@gmx.com> wrote:
>
> > > > (add-hook 'texinfo-mode-hook 'vmove-keytrigger)
>
> > > (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))
>
> > Would your comments also mean that I remove the add-hook
> >
> > (add-hook 'texinfo-mode-hook 'vmove-keytrigger)
>
> Yes.
>
> > Can with-eval-after-load be included inside a function?
>
> Yes if you arrange for that function to be invoked some time before
> you actually try pressing those keys while in texinfo-mode.
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-15 5:59 ` michael-franzese
@ 2021-05-15 6:02 ` Yuri Khan
2021-05-15 6:21 ` michael-franzese
0 siblings, 1 reply; 27+ messages in thread
From: Yuri Khan @ 2021-05-15 6:02 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs, Jean Louis
On Sat, 15 May 2021 at 12:59, <michael-franzese@gmx.com> wrote:
>
> Regarding keybindings, I like to have an alias keybinding for "H-o b"
> so I can also use "H-b", but only applicable to texinfo-mode.
>
> What can I use?
What have you tried?
What is ‘H-o b’ bound to?
^ permalink raw reply [flat|nested] 27+ messages in thread
* Changing outline-minor-mode keybindings for texinfo files
2021-05-15 5:58 ` Yuri Khan
@ 2021-05-15 6:07 ` michael-franzese
2021-05-15 6:35 ` Yuri Khan
0 siblings, 1 reply; 27+ messages in thread
From: michael-franzese @ 2021-05-15 6:07 UTC (permalink / raw)
To: Yuri Khan; +Cc: Help Gnu Emacs, Jean Louis
> Sent: Saturday, May 15, 2021 at 5:58 PM
> 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 Sat, 15 May 2021 at 12:25, <michael-franzese@gmx.com> wrote:
>
> > I would need some implementation examples about how the function can be
> > invoked as you describe.
> >
> > Currently I got the following
> >
> > (defun show-keytrigger ()
> > (with-eval-after-load 'texinfo
> > (define-key texinfo-mode-map
> > (kbd "H-s") #'outline-show-subtree) ))
> >
> > (add-hook 'texinfo-mode-hook 'show-keytrigger)
>
> Again, you are using a hook that runs in each new texinfo-mode buffer,
> but it is sufficient to define a key once per session. You can replace
> the above with just this:
>
> (with-eval-after-load 'texinfo
> (define-key texinfo-mode-map
> (kbd "H-s") #'outline-show-subtree))
My difficulty is to have a function that defines some keybindings, so I can easily
switch them off by commenting the function call.
So the difficulty is how to call the function after texinfo has loaded. Is there
some condition to check? My code automatically assign the major made because I use
auto-mode-alist at the beginning of my init file.
(add-to-list 'auto-mode-alist '("\\.texi\\'" . texinfo-mode))
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-15 6:02 ` Yuri Khan
@ 2021-05-15 6:21 ` michael-franzese
2021-05-15 6:36 ` Yuri Khan
0 siblings, 1 reply; 27+ messages in thread
From: michael-franzese @ 2021-05-15 6:21 UTC (permalink / raw)
To: Yuri Khan; +Cc: Help Gnu Emacs, Jean Louis
I have been long time simply using global-set-key. But with my recent texinfo
work I have started to see how to set up things to apply only when in texinfo-mode.
Am now using "H-o" to define outline commands, so that "H-o b" does outline-hide-body.
Originally I had "H-b" for this but realised a clash with some bifurcating functions
I use.
Customarily, I call
(global-set-key (kbd "H-n") (kbd "H-b"))
But that is for global binding
> Sent: Saturday, May 15, 2021 at 6:02 PM
> 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 Sat, 15 May 2021 at 12:59, <michael-franzese@gmx.com> wrote:
> >
> > Regarding keybindings, I like to have an alias keybinding for "H-o b"
> > so I can also use "H-b", but only applicable to texinfo-mode.
> >
> > What can I use?
>
> What have you tried?
>
> What is ‘H-o b’ bound to?
>
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-15 6:07 ` michael-franzese
@ 2021-05-15 6:35 ` Yuri Khan
0 siblings, 0 replies; 27+ messages in thread
From: Yuri Khan @ 2021-05-15 6:35 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs, Jean Louis
On Sat, 15 May 2021 at 13:07, <michael-franzese@gmx.com> wrote:
> My difficulty is to have a function that defines some keybindings, so I can easily
> switch them off by commenting the function call.
>
> So the difficulty is how to call the function after texinfo has loaded. Is there
> some condition to check?
Are you experimenting, then? In that case, disregard my suggestions. I
was thinking you have settled on a configuration.
When experimenting, do whatever helps you to experiment.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-15 6:21 ` michael-franzese
@ 2021-05-15 6:36 ` Yuri Khan
2021-05-15 8:40 ` michael-franzese
0 siblings, 1 reply; 27+ messages in thread
From: Yuri Khan @ 2021-05-15 6:36 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs, Jean Louis
On Sat, 15 May 2021 at 13:21, <michael-franzese@gmx.com> wrote:
> > > Regarding keybindings, I like to have an alias keybinding for "H-o b"
> > > so I can also use "H-b", but only applicable to texinfo-mode.
> I have been long time simply using global-set-key. But with my recent texinfo
> work I have started to see how to set up things to apply only when in texinfo-mode.
>
> Am now using "H-o" to define outline commands, so that "H-o b" does outline-hide-body.
> Originally I had "H-b" for this but realised a clash with some bifurcating functions
> I use.
>
> Customarily, I call
>
> (global-set-key (kbd "H-n") (kbd "H-b"))
>
> But that is for global binding
I think you can do everything with (define-key 'some-map …) that you
can do with (global-set-key …).
^ permalink raw reply [flat|nested] 27+ messages in thread
* Changing outline-minor-mode keybindings for texinfo files
2021-05-15 6:36 ` Yuri Khan
@ 2021-05-15 8:40 ` michael-franzese
2021-05-15 9:00 ` Yuri Khan
0 siblings, 1 reply; 27+ messages in thread
From: michael-franzese @ 2021-05-15 8:40 UTC (permalink / raw)
To: Yuri Khan; +Cc: Help Gnu Emacs, Jean Louis
Yes, I am experimenting.
I have this solution,
(defun hide-keytrigger
(define-key texinfo-mode-map
(kbd "H-o b") #'outline-hide-body)
(define-key texinfo-mode-map
(kbd "H-o q") #'outline-hide-sublevels) )
(with-eval-after-load 'texinfo #'hide-keytrigger)
This way I hope that the function hide-keytrigger would set the
keybindings after texinfo has loaded.
What do you think about that?
> Sent: Saturday, May 15, 2021 at 6:3
6 PM
> 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 Sat, 15 May 2021 at 13:21, <michael-franzese@gmx.com> wrote:
> > > > Regarding keybindings, I like to have an alias keybinding for "H-o b"
> > > > so I can also use "H-b", but only applicable to texinfo-mode.
>
> > I have been long time simply using global-set-key. But with my recent texinfo
> > work I have started to see how to set up things to apply only when in texinfo-mode.
> >
> > Am now using "H-o" to define outline commands, so that "H-o b" does outline-hide-body.
> > Originally I had "H-b" for this but realised a clash with some bifurcating functions
> > I use.
> >
> > Customarily, I call
> >
> > (global-set-key (kbd "H-n") (kbd "H-b"))
> >
> > But that is for global binding
>
> I think you can do everything with (define-key 'some-map …) that you
> can do with (global-set-key …).
>
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-15 8:40 ` michael-franzese
@ 2021-05-15 9:00 ` Yuri Khan
2021-05-15 10:48 ` michael-franzese
0 siblings, 1 reply; 27+ messages in thread
From: Yuri Khan @ 2021-05-15 9:00 UTC (permalink / raw)
To: michael-franzese; +Cc: Help Gnu Emacs, Jean Louis
On Sat, 15 May 2021 at 15:40, <michael-franzese@gmx.com> wrote:
> Yes, I am experimenting.
>
> I have this solution,
>
> (defun hide-keytrigger
>
> (define-key texinfo-mode-map
> (kbd "H-o b") #'outline-hide-body)
>
> (define-key texinfo-mode-map
> (kbd "H-o q") #'outline-hide-sublevels) )
>
> (with-eval-after-load 'texinfo #'hide-keytrigger)
>
> This way I hope that the function hide-keytrigger would set the
> keybindings after texinfo has loaded.
That function will set the keybindings as soon as you invoke it. And
the syntax of ‘with-eval-after-load’ is different from that of
‘add-hook’. You need to pass a form to it, not a function symbol:
(with-eval-after-load 'texinfo
(hide-keytrigger))
When you do that, ‘with-eval-after-load’ will arrange your function to
be invoked after texinfo.el loads.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Changing outline-minor-mode keybindings for texinfo files
2021-05-15 9:00 ` Yuri Khan
@ 2021-05-15 10:48 ` michael-franzese
0 siblings, 0 replies; 27+ messages in thread
From: michael-franzese @ 2021-05-15 10:48 UTC (permalink / raw)
To: Yuri Khan; +Cc: Help Gnu Emacs, Jean Louis
> Sent: Saturday, May 15, 2021 at 9:00 PM
> 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 Sat, 15 May 2021 at 15:40, <michael-franzese@gmx.com> wrote:
>
> > Yes, I am experimenting.
> >
> > I have this solution,
> >
> > (defun hide-keytrigger
> >
> > (define-key texinfo-mode-map
> > (kbd "H-o b") #'outline-hide-body)
> >
> > (define-key texinfo-mode-map
> > (kbd "H-o q") #'outline-hide-sublevels) )
> >
> > (with-eval-after-load 'texinfo #'hide-keytrigger)
> >
> > This way I hope that the function hide-keytrigger would set the
> > keybindings after texinfo has loaded.
>
> That function will set the keybindings as soon as you invoke it. And
> the syntax of ‘with-eval-after-load’ is different from that of
> ‘add-hook’. You need to pass a form to it, not a function symbol:
>
> (with-eval-after-load 'texinfo
> (hide-keytrigger))
Because it is an evaluation of hide-keytrigger. Things making sense now.
Thank you for the example code and explanation.
> When you do that, ‘with-eval-after-load’ will arrange your function to
> be invoked after texinfo.el loads.
>
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Changing outline-minor-mode keybindings for texinfo files
2021-05-14 18:49 ` Jean Louis
@ 2021-05-15 21:10 ` tomas
0 siblings, 0 replies; 27+ messages in thread
From: tomas @ 2021-05-15 21:10 UTC (permalink / raw)
To: help-gnu-emacs; +Cc: michael-franzese, Yuri Khan
[-- Attachment #1: Type: text/plain, Size: 963 bytes --]
On Fri, May 14, 2021 at 09:49:48PM +0300, Jean Louis wrote:
[...]
> Yes, I see by testing, it works with it as you say.
>
> I was thinking this:
>
> (setq a 1) ⇒ 1
>
> (let ((b a))
> (setq b 2)) ⇒ 2
This is because you set b to the *value* of a, then set b
to something different. You don't change the value of a
(in this case it'd be difficult anyway, because... how do
you change 2? It is immutable.
It becomes different when you have a mutable thing and
mutate it.
Try:
(setq a (list 'apple 'banana 'cranberry))
(setq b a)
a
=> (apple banana cranberry)
; now we mutate b's value, which is the same
; as a's value
(setf (caddr b) 'chives)
a
; a's value has changed!
=> (apple banana chives)
You can do that with keymaps and lists, because they
are mutable objects, but not with 2.
In Lisp, symbols are also immutable. Strings are not.
This depends on the language.
Cheers
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2021-05-15 21:10 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-14 5:47 Changing outline-minor-mode keybindings for texinfo files michael-franzese
2021-05-14 7:28 ` michael-franzese
2021-05-14 9:51 ` Jean Louis
2021-05-14 10:04 ` michael-franzese
2021-05-14 12:24 ` michael-franzese
2021-05-14 13:31 ` michael-franzese
2021-05-14 14:03 ` Jean Louis
2021-05-14 16:00 ` Yuri Khan
2021-05-14 16:19 ` michael-franzese
2021-05-14 18:49 ` Jean Louis
2021-05-15 21:10 ` tomas
2021-05-14 16:20 ` Yuri Khan
2021-05-14 16:36 ` michael-franzese
2021-05-14 20:10 ` Yuri Khan
2021-05-15 5:25 ` michael-franzese
2021-05-15 5:58 ` Yuri Khan
2021-05-15 6:07 ` michael-franzese
2021-05-15 6:35 ` Yuri Khan
2021-05-15 5:59 ` michael-franzese
2021-05-15 6:02 ` Yuri Khan
2021-05-15 6:21 ` michael-franzese
2021-05-15 6:36 ` Yuri Khan
2021-05-15 8:40 ` michael-franzese
2021-05-15 9:00 ` Yuri Khan
2021-05-15 10:48 ` michael-franzese
2021-05-14 18:13 ` michael-franzese
2021-05-14 13:55 ` Jean Louis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).