all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Generality of defvar
@ 2022-07-26 20:35 carlmarcos--- via Users list for the GNU Emacs text editor
  2022-07-26 23:01 ` Philip Kaludercic
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-26 20:35 UTC (permalink / raw)
  To: Help Gnu Emacs

Have been looking into defvar and noticed the generality of its use

(defvar aname t)
(defvar bname nil)
(defvar cname 1)
(defvar dname "text")

Then I can do

(when aname (setq debug-on-error t))
(when bname (setq debug-on-error nil))

Is this correct?






^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-26 20:35 Generality of defvar carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-26 23:01 ` Philip Kaludercic
       [not found] ` <87r127h40s.fsf@posteo.net-N7wjq17--3-2>
  2022-07-26 23:16 ` Emanuel Berg
  2 siblings, 0 replies; 27+ messages in thread
From: Philip Kaludercic @ 2022-07-26 23:01 UTC (permalink / raw)
  To: carlmarcos--- via Users list for the GNU Emacs text editor; +Cc: carlmarcos

carlmarcos--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> Have been looking into defvar and noticed the generality of its use
>
> (defvar aname t)
> (defvar bname nil)
> (defvar cname 1)
> (defvar dname "text")
>
> Then I can do
>
> (when aname (setq debug-on-error t))
> (when bname (setq debug-on-error nil))
>
> Is this correct?

You can /do/ it, but what do you /want/ to archive?



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
       [not found] ` <87r127h40s.fsf@posteo.net-N7wjq17--3-2>
@ 2022-07-26 23:10   ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-07-27  7:29     ` Thibaut Verron
       [not found]     ` <CAFsi02SEVCEjGNoQ6vPZvMw7d5F39JZAAPCR5VOUnzQDUERkQA@mail.gmail.com-N7yZ2U2----2>
  0 siblings, 2 replies; 27+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-26 23:10 UTC (permalink / raw)
  To: Philip Kaludercic
  Cc: carlmarcos--- via Users list for the GNU Emacs text editor

Jul 26, 2022, 23:01 by philipk@posteo.net:

> carlmarcos--- via Users list for the GNU Emacs text editor
> <help-gnu-emacs@gnu.org> writes:
>
>> Have been looking into defvar and noticed the generality of its use
>>
>> (defvar aname t)
>> (defvar bname nil)
>> (defvar cname 1)
>> (defvar dname "text")
>>
>> Then I can do
>>
>> (when aname (setq debug-on-error t))
>> (when bname (setq debug-on-error nil))
>>
>> Is this correct?
>>
>
> You can /do/ it, but what do you /want/ to archive?
>
Want to use a defvar to enable or disable some functionality using `when', such as enabling error diagnostics with the command  

(when myopt (setq debug-on-error t))






^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-26 20:35 Generality of defvar carlmarcos--- via Users list for the GNU Emacs text editor
  2022-07-26 23:01 ` Philip Kaludercic
       [not found] ` <87r127h40s.fsf@posteo.net-N7wjq17--3-2>
@ 2022-07-26 23:16 ` Emanuel Berg
  2022-07-26 23:23   ` Emanuel Berg
                     ` (2 more replies)
  2 siblings, 3 replies; 27+ messages in thread
From: Emanuel Berg @ 2022-07-26 23:16 UTC (permalink / raw)
  To: help-gnu-emacs

carlmarcos--- via Users list for the GNU Emacs text editor wrote:

> Have been looking into defvar and noticed the generality of
> its use
>
> (defvar aname t)
> (defvar bname nil)
> (defvar cname 1)
> (defvar dname "text")

For practical reasons it can be better to do

(defvar var-name)
(setq var-name 'var-value)

instead because if you do something with that and want to
reset it, it's enough to evaluate the second line, whereas if
you just have the first line you tend to evaluate that one and
if/because the variable is already set at that point then
nothing will happen ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-26 23:16 ` Emanuel Berg
@ 2022-07-26 23:23   ` Emanuel Berg
  2022-07-26 23:36   ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-07-27  4:57   ` Yuri Khan
  2 siblings, 0 replies; 27+ messages in thread
From: Emanuel Berg @ 2022-07-26 23:23 UTC (permalink / raw)
  To: help-gnu-emacs

>> (defvar aname t) [...]
>
> For practical reasons it can be better to do
>
> (defvar var-name)
> (setq var-name 'var-value)

Here `defvar' only tells the byte-compiler that you intend to
use a variable with that name. It doesn't create such
a variable.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-26 23:16 ` Emanuel Berg
  2022-07-26 23:23   ` Emanuel Berg
@ 2022-07-26 23:36   ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-07-27  4:57   ` Yuri Khan
  2 siblings, 0 replies; 27+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-26 23:36 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs


Jul 26, 2022, 23:16 by incal@dataswamp.org:

> carlmarcos--- via Users list for the GNU Emacs text editor wrote:
>
>> Have been looking into defvar and noticed the generality of
>> its use
>>
>> (defvar aname t)
>> (defvar bname nil)
>> (defvar cname 1)
>> (defvar dname "text")
>>
>
> For practical reasons it can be better to do
>
> (defvar var-name)
> (setq var-name 'var-value)
>
> instead because if you do something with that and want to
> reset it, it's enough to evaluate the second line, whereas if
> you just have the first line you tend to evaluate that one and
> if/because the variable is already set at that point then
> nothing will happen ...
>

I cannot follow what you are trying to say.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-26 23:16 ` Emanuel Berg
  2022-07-26 23:23   ` Emanuel Berg
  2022-07-26 23:36   ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-27  4:57   ` Yuri Khan
  2022-07-27  6:59     ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-07-29 15:56     ` Emanuel Berg
  2 siblings, 2 replies; 27+ messages in thread
From: Yuri Khan @ 2022-07-27  4:57 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, 27 Jul 2022 at 06:17, Emanuel Berg <incal@dataswamp.org> wrote:

> For practical reasons it can be better to do
>
> (defvar var-name)
> (setq var-name 'var-value)
>
> instead because if you do something with that and want to
> reset it, it's enough to evaluate the second line, whereas if
> you just have the first line you tend to evaluate that one and
> if/because the variable is already set at that point then
> nothing will happen ...

Yes, but you can press C-M-x on a (defvar var-name 'var-value) and it
will get re-set to the new value even if the variable is already
defined.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-27  4:57   ` Yuri Khan
@ 2022-07-27  6:59     ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-07-29 15:56     ` Emanuel Berg
  1 sibling, 0 replies; 27+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-27  6:59 UTC (permalink / raw)
  To: Yuri Khan; +Cc: help-gnu-emacs


Jul 27, 2022, 04:57 by yuri.v.khan@gmail.com:

> On Wed, 27 Jul 2022 at 06:17, Emanuel Berg <incal@dataswamp.org> wrote:
>
>> For practical reasons it can be better to do
>>
>> (defvar var-name)
>> (setq var-name 'var-value)
>>
>> instead because if you do something with that and want to
>> reset it, it's enough to evaluate the second line, whereas if
>> you just have the first line you tend to evaluate that one and
>> if/because the variable is already set at that point then
>> nothing will happen ...
>>
>
> Yes, but you can press C-M-x on a (defvar var-name 'var-value) and it
> will get re-set to the new value even if the variable is already
> defined.
>
So I can keep it (defvar var-name t) or (defvar var-name nil)



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-26 23:10   ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-27  7:29     ` Thibaut Verron
       [not found]     ` <CAFsi02SEVCEjGNoQ6vPZvMw7d5F39JZAAPCR5VOUnzQDUERkQA@mail.gmail.com-N7yZ2U2----2>
  1 sibling, 0 replies; 27+ messages in thread
From: Thibaut Verron @ 2022-07-27  7:29 UTC (permalink / raw)
  To: carlmarcos
  Cc: Philip Kaludercic,
	carlmarcos--- via Users list for the GNU Emacs text editor

Le mer. 27 juil. 2022 à 01:11, carlmarcos--- via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> a écrit :

> Jul 26, 2022, 23:01 by philipk@posteo.net:
>
> > carlmarcos--- via Users list for the GNU Emacs text editor
> > <help-gnu-emacs@gnu.org> writes:
> >
> >> Have been looking into defvar and noticed the generality of its use
> >>
> >> (defvar aname t)
> >> (defvar bname nil)
> >> (defvar cname 1)
> >> (defvar dname "text")
> >>
> >> Then I can do
> >>
> >> (when aname (setq debug-on-error t))
> >> (when bname (setq debug-on-error nil))
> >>
> >> Is this correct?
> >>
> >
> > You can /do/ it, but what do you /want/ to archive?
> >
> Want to use a defvar to enable or disable some functionality using `when',
> such as enabling error diagnostics with the command
>
> (when myopt (setq debug-on-error t))
>

In principle yes, but for this example there already is a variable for that
purpose, debug-on-error.
So you might as well just use it as your control variable, and use
conditionals like (when debug-on-error ...) or (unless debug-on-error ...)
if you want to do more things.

Also, those lines:

(when aname (setq debug-on-error t))
(when bname (setq debug-on-error nil))

are equivalent to

(setq debug-on-error (and aname (not bname)))

I don't really see the point of having two variables hold opposite values.
Wouldn't

(if aname
   (setq debug-on-error t)
   (setq debug-on-error nil))

or equivalently

(setq debug-on-error aname)

be more what you want?


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
       [not found]     ` <CAFsi02SEVCEjGNoQ6vPZvMw7d5F39JZAAPCR5VOUnzQDUERkQA@mail.gmail.com-N7yZ2U2----2>
@ 2022-07-27 12:18       ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-07-27 12:34         ` Emanuel Berg
  0 siblings, 1 reply; 27+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-27 12:18 UTC (permalink / raw)
  To: Thibaut Verron
  Cc: Philip Kaludercic,
	carlmarcos--- via Users list for the GNU Emacs text editor

Jul 27, 2022, 07:29 by thibaut.verron@gmail.com:

> Le mer. 27 juil. 2022 à 01:11, carlmarcos--- via Users list for the GNU
> Emacs text editor <help-gnu-emacs@gnu.org> a écrit :
>
>> Jul 26, 2022, 23:01 by philipk@posteo.net:
>>
>> > carlmarcos--- via Users list for the GNU Emacs text editor
>> > <help-gnu-emacs@gnu.org> writes:
>> >
>> >> Have been looking into defvar and noticed the generality of its use
>> >>
>> >> (defvar aname t)
>> >> (defvar bname nil)
>> >> (defvar cname 1)
>> >> (defvar dname "text")
>> >>
>> >> Then I can do
>> >>
>> >> (when aname (setq debug-on-error t))
>> >> (when bname (setq debug-on-error nil))
>> >>
>> >> Is this correct?
>> >>
>> >
>> > You can /do/ it, but what do you /want/ to archive?
>> >
>> Want to use a defvar to enable or disable some functionality using `when',
>> such as enabling error diagnostics with the command
>>
>> (when myopt (setq debug-on-error t))
>>
>
> In principle yes, but for this example there already is a variable for that
> purpose, debug-on-error.
> So you might as well just use it as your control variable, and use
> conditionals like (when debug-on-error ...) or (unless debug-on-error ...)
> if you want to do more things.
>
> Also, those lines:
>
> (when aname (setq debug-on-error t))
> (when bname (setq debug-on-error nil))
>
> are equivalent to
>
> (setq debug-on-error (and aname (not bname)))
>
> I don't really see the point of having two variables hold opposite values.
> Wouldn't
>
> (if aname
>  (setq debug-on-error t)
>  (setq debug-on-error nil))
>
> or equivalently
>
> (setq debug-on-error aname)
>
> be more what you want?
>
Thank you very much for your elaboration.  

This is what I got right now

(defvar error-diagnostics t
  "Enable error diagnostics if non-nil.")

(defun enable-error-diagnostics ()
  "Enable error diagnostics with backtrace buffer.
One can exit the debugger with the q command."

  (setq debug-on-error t)
  (setq debug-ignored-errors t))

(when error-diagnostics (enable-error-diagnostics))







^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-27 12:18       ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-27 12:34         ` Emanuel Berg
  2022-07-27 12:52           ` carlmarcos--- via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 27+ messages in thread
From: Emanuel Berg @ 2022-07-27 12:34 UTC (permalink / raw)
  To: help-gnu-emacs

carlmarcos--- via Users list for the GNU Emacs text editor wrote:

> (defun enable-error-diagnostics ()
>   "Enable error diagnostics with backtrace buffer.
> One can exit the debugger with the q command."

You can refer to keys in docstrings like this:

  \\[forward-word]

That way, it isn't hardcoded so if later changed/configured
it'll still show the right key.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-27 12:34         ` Emanuel Berg
@ 2022-07-27 12:52           ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-07-27 13:21             ` Thibaut Verron
  0 siblings, 1 reply; 27+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-27 12:52 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs



-- 
 Sent with Tutanota, enjoy secure & ad-free emails. 



Jul 27, 2022, 12:34 by incal@dataswamp.org:

> carlmarcos--- via Users list for the GNU Emacs text editor wrote:
>
>> (defun enable-error-diagnostics ()
>>  "Enable error diagnostics with backtrace buffer.
>> One can exit the debugger with the q command."
>>
>
> You can refer to keys in docstrings like this:
>
>  \\[forward-word]
>
> That way, it isn't hardcoded so if later changed/configured
> it'll still show the right key.
>
How can I figure out what key to use in the docstring for exiting the backtrace buffer?




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-27 12:52           ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-27 13:21             ` Thibaut Verron
  2022-07-27 13:24               ` carlmarcos--- via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 27+ messages in thread
From: Thibaut Verron @ 2022-07-27 13:21 UTC (permalink / raw)
  To: carlmarcos; +Cc: Emanuel Berg, help-gnu-emacs

Le mer. 27 juil. 2022 à 14:52, carlmarcos--- via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> a écrit :

>
>
> --
>  Sent with Tutanota, enjoy secure & ad-free emails.
>
>
>
> Jul 27, 2022, 12:34 by incal@dataswamp.org:
>
> > carlmarcos--- via Users list for the GNU Emacs text editor wrote:
> >
> >> (defun enable-error-diagnostics ()
> >>  "Enable error diagnostics with backtrace buffer.
> >> One can exit the debugger with the q command."
> >>
> >
> > You can refer to keys in docstrings like this:
> >
> >  \\[forward-word]
> >
> > That way, it isn't hardcoded so if later changed/configured
> > it'll still show the right key.
> >
> How can I figure out what key to use in the docstring for exiting the
> backtrace buffer?
>

The function bound to 'q' is quit-window. But since this function doesn't
have a global binding, you need to tell the docstring to use the
appropriate keymap to look the binding up.

Something like

  "Enable error diagnostics with backtrace buffer.

\\<backtrace-mode-map> (note: this is the part telling emacs where to look
for the key)
One can exit the debugger with the `quit-window' command (bound to
\\[quit-window])."


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-27 13:21             ` Thibaut Verron
@ 2022-07-27 13:24               ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-07-27 13:47                 ` Thibaut Verron
  0 siblings, 1 reply; 27+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-27 13:24 UTC (permalink / raw)
  To: Thibaut Verron; +Cc: Emanuel Berg, help-gnu-emacs


Jul 27, 2022, 13:21 by thibaut.verron@gmail.com:

> Le mer. 27 juil. 2022 à 14:52, carlmarcos--- via Users list for the GNU Emacs text editor <> help-gnu-emacs@gnu.org> > a écrit :
>
>>  
>>  
>>  Jul 27, 2022, 12:34 by >> incal@dataswamp.org>> :
>>  
>>  > carlmarcos--- via Users list for the GNU Emacs text editor wrote:
>>  >
>>  >> (defun enable-error-diagnostics ()
>>  >>  "Enable error diagnostics with backtrace buffer.
>>  >> One can exit the debugger with the q command."
>>  >>
>>  >
>>  > You can refer to keys in docstrings like this:
>>  >
>>  >  \\[forward-word]
>>  >
>>  > That way, it isn't hardcoded so if later changed/configured
>>  > it'll still show the right key.
>>  >
>>  How can I figure out what key to use in the docstring for exiting the backtrace buffer?
>>
>
> The function bound to 'q' is quit-window. But since this function doesn't have a global binding, you need to tell the docstring to use the appropriate keymap to look the binding up.
>
> Something like
>
>   "Enable error diagnostics with backtrace buffer.
>
> \\<backtrace-mode-map> (note: this is the part telling emacs where to look for the key)
> One can exit the debugger with the `quit-window' command (bound to \\[quit-window])."
>
>
Although quit-window is bound to q, the command \\[quit-window] just inserts 
M-x quit-window, rather than q.





^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-27 13:24               ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-27 13:47                 ` Thibaut Verron
  2022-07-27 16:29                   ` Christopher Dimech
  0 siblings, 1 reply; 27+ messages in thread
From: Thibaut Verron @ 2022-07-27 13:47 UTC (permalink / raw)
  To: carlmarcos; +Cc: Emanuel Berg, help-gnu-emacs

Le mer. 27 juil. 2022 à 15:24, <carlmarcos@tutanota.com> a écrit :

>
> Jul 27, 2022, 13:21 by thibaut.verron@gmail.com:
>
> > Le mer. 27 juil. 2022 à 14:52, carlmarcos--- via Users list for the GNU
> Emacs text editor <> help-gnu-emacs@gnu.org> > a écrit :
> >
> >>
> >>
> >>  Jul 27, 2022, 12:34 by >> incal@dataswamp.org>> :
> >>
> >>  > carlmarcos--- via Users list for the GNU Emacs text editor wrote:
> >>  >
> >>  >> (defun enable-error-diagnostics ()
> >>  >>  "Enable error diagnostics with backtrace buffer.
> >>  >> One can exit the debugger with the q command."
> >>  >>
> >>  >
> >>  > You can refer to keys in docstrings like this:
> >>  >
> >>  >  \\[forward-word]
> >>  >
> >>  > That way, it isn't hardcoded so if later changed/configured
> >>  > it'll still show the right key.
> >>  >
> >>  How can I figure out what key to use in the docstring for exiting the
> backtrace buffer?
> >>
> >
> > The function bound to 'q' is quit-window. But since this function
> doesn't have a global binding, you need to tell the docstring to use the
> appropriate keymap to look the binding up.
> >
> > Something like
> >
> >   "Enable error diagnostics with backtrace buffer.
> >
> > \\<backtrace-mode-map> (note: this is the part telling emacs where to
> look for the key)
> > One can exit the debugger with the `quit-window' command (bound to
> \\[quit-window])."
> >
> >
> Although quit-window is bound to q, the command \\[quit-window] just
> inserts
> M-x quit-window, rather than q.
>

Yes, that's precisely because quit-window doesn't have a global binding.
You need to add \\<backtrace-mode-map> somewhere in the docstring to tell
emacs to show bindings for the backtrace buffers, rather than global
bindings.

Best wishes,
Thibaut


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-27 13:47                 ` Thibaut Verron
@ 2022-07-27 16:29                   ` Christopher Dimech
  2022-07-27 16:39                     ` Thibaut Verron
  0 siblings, 1 reply; 27+ messages in thread
From: Christopher Dimech @ 2022-07-27 16:29 UTC (permalink / raw)
  To: thibaut.verron; +Cc: carlmarcos, Emanuel Berg, help-gnu-emacs



> Sent: Thursday, July 28, 2022 at 1:47 AM
> From: "Thibaut Verron" <thibaut.verron@gmail.com>
> To: carlmarcos@tutanota.com
> Cc: "Emanuel Berg" <incal@dataswamp.org>, "help-gnu-emacs" <help-gnu-emacs@gnu.org>
> Subject: Re: Generality of defvar
>
> Le mer. 27 juil. 2022 à 15:24, <carlmarcos@tutanota.com> a écrit :
> 
> >
> > Jul 27, 2022, 13:21 by thibaut.verron@gmail.com:
> >
> > > Le mer. 27 juil. 2022 à 14:52, carlmarcos--- via Users list for the GNU
> > Emacs text editor <> help-gnu-emacs@gnu.org> > a écrit :
> > >
> > >>
> > >>
> > >>  Jul 27, 2022, 12:34 by >> incal@dataswamp.org>> :
> > >>
> > >>  > carlmarcos--- via Users list for the GNU Emacs text editor wrote:
> > >>  >
> > >>  >> (defun enable-error-diagnostics ()
> > >>  >>  "Enable error diagnostics with backtrace buffer.
> > >>  >> One can exit the debugger with the q command."
> > >>  >>
> > >>  >
> > >>  > You can refer to keys in docstrings like this:
> > >>  >
> > >>  >  \\[forward-word]
> > >>  >
> > >>  > That way, it isn't hardcoded so if later changed/configured
> > >>  > it'll still show the right key.
> > >>  >
> > >>  How can I figure out what key to use in the docstring for exiting the
> > backtrace buffer?
> > >>
> > >
> > > The function bound to 'q' is quit-window. But since this function
> > doesn't have a global binding, you need to tell the docstring to use the
> > appropriate keymap to look the binding up.
> > >
> > > Something like
> > >
> > >   "Enable error diagnostics with backtrace buffer.
> > >
> > > \\<backtrace-mode-map> (note: this is the part telling emacs where to
> > look for the key)
> > > One can exit the debugger with the `quit-window' command (bound to
> > \\[quit-window])."
> > >
> > >
> > Although quit-window is bound to q, the command \\[quit-window] just
> > inserts
> > M-x quit-window, rather than q.
> >
> 
> Yes, that's precisely because quit-window doesn't have a global binding.
> You need to add \\<backtrace-mode-map> somewhere in the docstring to tell
> emacs to show bindings for the backtrace buffers, rather than global
> bindings.
> 
> Best wishes,
> Thibaut

Sounds good advice, but the result could be

Uses keymap ‘backtrace-mode-map’, which is not currently defined.






^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-27 16:29                   ` Christopher Dimech
@ 2022-07-27 16:39                     ` Thibaut Verron
  2022-07-28  6:42                       ` Christopher Dimech
  0 siblings, 1 reply; 27+ messages in thread
From: Thibaut Verron @ 2022-07-27 16:39 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: carlmarcos, Emanuel Berg, help-gnu-emacs

Le mer. 27 juil. 2022 à 18:29, Christopher Dimech <dimech@gmx.com> a écrit :

>
>
> > Sent: Thursday, July 28, 2022 at 1:47 AM
> > From: "Thibaut Verron" <thibaut.verron@gmail.com>
> > To: carlmarcos@tutanota.com
> > Cc: "Emanuel Berg" <incal@dataswamp.org>, "help-gnu-emacs" <
> help-gnu-emacs@gnu.org>
> > Subject: Re: Generality of defvar
> >
> > Le mer. 27 juil. 2022 à 15:24, <carlmarcos@tutanota.com> a écrit :
> >
> > >
> > > Jul 27, 2022, 13:21 by thibaut.verron@gmail.com:
> > >
> > > > Le mer. 27 juil. 2022 à 14:52, carlmarcos--- via Users list for the
> GNU
> > > Emacs text editor <> help-gnu-emacs@gnu.org> > a écrit :
> > > >
> > > >>
> > > >>
> > > >>  Jul 27, 2022, 12:34 by >> incal@dataswamp.org>> :
> > > >>
> > > >>  > carlmarcos--- via Users list for the GNU Emacs text editor wrote:
> > > >>  >
> > > >>  >> (defun enable-error-diagnostics ()
> > > >>  >>  "Enable error diagnostics with backtrace buffer.
> > > >>  >> One can exit the debugger with the q command."
> > > >>  >>
> > > >>  >
> > > >>  > You can refer to keys in docstrings like this:
> > > >>  >
> > > >>  >  \\[forward-word]
> > > >>  >
> > > >>  > That way, it isn't hardcoded so if later changed/configured
> > > >>  > it'll still show the right key.
> > > >>  >
> > > >>  How can I figure out what key to use in the docstring for exiting
> the
> > > backtrace buffer?
> > > >>
> > > >
> > > > The function bound to 'q' is quit-window. But since this function
> > > doesn't have a global binding, you need to tell the docstring to use
> the
> > > appropriate keymap to look the binding up.
> > > >
> > > > Something like
> > > >
> > > >   "Enable error diagnostics with backtrace buffer.
> > > >
> > > > \\<backtrace-mode-map> (note: this is the part telling emacs where to
> > > look for the key)
> > > > One can exit the debugger with the `quit-window' command (bound to
> > > \\[quit-window])."
> > > >
> > > >
> > > Although quit-window is bound to q, the command \\[quit-window] just
> > > inserts
> > > M-x quit-window, rather than q.
> > >
> >
> > Yes, that's precisely because quit-window doesn't have a global binding.
> > You need to add \\<backtrace-mode-map> somewhere in the docstring to tell
> > emacs to show bindings for the backtrace buffers, rather than global
> > bindings.
> >
> > Best wishes,
> > Thibaut
>
> Sounds good advice, but the result could be
>
> Uses keymap ‘backtrace-mode-map’, which is not currently defined.
>

My bad, it should have been debugger-mode-map.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-27 16:39                     ` Thibaut Verron
@ 2022-07-28  6:42                       ` Christopher Dimech
  2022-07-28  7:06                         ` Thibaut Verron
  0 siblings, 1 reply; 27+ messages in thread
From: Christopher Dimech @ 2022-07-28  6:42 UTC (permalink / raw)
  To: thibaut.verron; +Cc: carlmarcos, Emanuel Berg, help-gnu-emacs


   Sent: Thursday, July 28, 2022 at 4:39 AM
   From: "Thibaut Verron" <thibaut.verron@gmail.com>
   To: "Christopher Dimech" <dimech@gmx.com>
   Cc: carlmarcos@tutanota.com, "Emanuel Berg" <incal@dataswamp.org>,
   "help-gnu-emacs" <help-gnu-emacs@gnu.org>
   Subject: Re: Generality of defvar
   Le mer. 27 juil. 2022 à 18:29, Christopher Dimech <[1]dimech@gmx.com> a
   écrit :

     > Sent: Thursday, July 28, 2022 at 1:47 AM
     > From: "Thibaut Verron" <[2]thibaut.verron@gmail.com>
     > To: [3]carlmarcos@tutanota.com
     > Cc: "Emanuel Berg" <[4]incal@dataswamp.org>, "help-gnu-emacs"
     <[5]help-gnu-emacs@gnu.org>
     > Subject: Re: Generality of defvar
     >
     > Le mer. 27 juil. 2022 à 15:24, <[6]carlmarcos@tutanota.com> a
     écrit :
     >
     > >
     > > Jul 27, 2022, 13:21 by [7]thibaut.verron@gmail.com:
     > >
     > > > Le mer. 27 juil. 2022 à 14:52, carlmarcos--- via Users list
     for the GNU
     > > Emacs text editor <> [8]help-gnu-emacs@gnu.org> > a écrit :
     > > >
     > > >>
     > > >>
     > > >>  Jul 27, 2022, 12:34 by >> [9]incal@dataswamp.org>> :
     > > >>
     > > >>  > carlmarcos--- via Users list for the GNU Emacs text editor
     wrote:
     > > >>  >
     > > >>  >> (defun enable-error-diagnostics ()
     > > >>  >>  "Enable error diagnostics with backtrace buffer.
     > > >>  >> One can exit the debugger with the q command."
     > > >>  >>
     > > >>  >
     > > >>  > You can refer to keys in docstrings like this:
     > > >>  >
     > > >>  >  \\[forward-word]
     > > >>  >
     > > >>  > That way, it isn't hardcoded so if later
     changed/configured
     > > >>  > it'll still show the right key.
     > > >>  >
     > > >>  How can I figure out what key to use in the docstring for
     exiting the
     > > backtrace buffer?
     > > >>
     > > >
     > > > The function bound to 'q' is quit-window. But since this
     function
     > > doesn't have a global binding, you need to tell the docstring to
     use the
     > > appropriate keymap to look the binding up.
     > > >
     > > > Something like
     > > >
     > > >   "Enable error diagnostics with backtrace buffer.
     > > >
     > > > \\<backtrace-mode-map> (note: this is the part telling emacs
     where to
     > > look for the key)
     > > > One can exit the debugger with the `quit-window' command
     (bound to
     > > \\[quit-window])."
     > > >
     > > >
     > > Although quit-window is bound to q, the command \\[quit-window]
     just
     > > inserts
     > > M-x quit-window, rather than q.
     > >
     >
     > Yes, that's precisely because quit-window doesn't have a global
     binding.
     > You need to add \\<backtrace-mode-map> somewhere in the docstring
     to tell
     > emacs to show bindings for the backtrace buffers, rather than
     global
     > bindings.
     >
     > Best wishes,
     > Thibaut
     Sounds good advice, but the result could be
     Uses keymap ‘backtrace-mode-map’, which is not currently defined.


   My bad, it should have been debugger-mode-map.


   Not quite right yet.

References

   1. mailto:dimech@gmx.com
   2. mailto:thibaut.verron@gmail.com
   3. mailto:carlmarcos@tutanota.com
   4. mailto:incal@dataswamp.org
   5. mailto:help-gnu-emacs@gnu.org
   6. mailto:carlmarcos@tutanota.com
   7. mailto:thibaut.verron@gmail.com
   8. mailto:help-gnu-emacs@gnu.org
   9. mailto:incal@dataswamp.org


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-28  6:42                       ` Christopher Dimech
@ 2022-07-28  7:06                         ` Thibaut Verron
  2022-07-28  7:34                           ` Christopher Dimech
  0 siblings, 1 reply; 27+ messages in thread
From: Thibaut Verron @ 2022-07-28  7:06 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: carlmarcos, Emanuel Berg, help-gnu-emacs

Le jeu. 28 juil. 2022 à 08:42, Christopher Dimech <dimech@gmx.com> a écrit :

>
> *Sent:* Thursday, July 28, 2022 at 4:39 AM
> *From:* "Thibaut Verron" <thibaut.verron@gmail.com>
> *To:* "Christopher Dimech" <dimech@gmx.com>
> *Cc:* carlmarcos@tutanota.com, "Emanuel Berg" <incal@dataswamp.org>,
> "help-gnu-emacs" <help-gnu-emacs@gnu.org>
> *Subject:* Re: Generality of defvar
> Le mer. 27 juil. 2022 à 18:29, Christopher Dimech <dimech@gmx.com> a
> écrit :
>
>>
>>
>> > Sent: Thursday, July 28, 2022 at 1:47 AM
>> > From: "Thibaut Verron" <thibaut.verron@gmail.com>
>> > To: carlmarcos@tutanota.com
>> > Cc: "Emanuel Berg" <incal@dataswamp.org>, "help-gnu-emacs" <
>> help-gnu-emacs@gnu.org>
>> > Subject: Re: Generality of defvar
>> >
>> > Le mer. 27 juil. 2022 à 15:24, <carlmarcos@tutanota.com> a écrit :
>> >
>> > >
>> > > Jul 27, 2022, 13:21 by thibaut.verron@gmail.com:
>> > >
>> > > > Le mer. 27 juil. 2022 à 14:52, carlmarcos--- via Users list for the
>> GNU
>> > > Emacs text editor <> help-gnu-emacs@gnu.org> > a écrit :
>> > > >
>> > > >>
>> > > >>
>> > > >>  Jul 27, 2022, 12:34 by >> incal@dataswamp.org>> :
>> > > >>
>> > > >>  > carlmarcos--- via Users list for the GNU Emacs text editor
>> wrote:
>> > > >>  >
>> > > >>  >> (defun enable-error-diagnostics ()
>> > > >>  >>  "Enable error diagnostics with backtrace buffer.
>> > > >>  >> One can exit the debugger with the q command."
>> > > >>  >>
>> > > >>  >
>> > > >>  > You can refer to keys in docstrings like this:
>> > > >>  >
>> > > >>  >  \\[forward-word]
>> > > >>  >
>> > > >>  > That way, it isn't hardcoded so if later changed/configured
>> > > >>  > it'll still show the right key.
>> > > >>  >
>> > > >>  How can I figure out what key to use in the docstring for exiting
>> the
>> > > backtrace buffer?
>> > > >>
>> > > >
>> > > > The function bound to 'q' is quit-window. But since this function
>> > > doesn't have a global binding, you need to tell the docstring to use
>> the
>> > > appropriate keymap to look the binding up.
>> > > >
>> > > > Something like
>> > > >
>> > > >   "Enable error diagnostics with backtrace buffer.
>> > > >
>> > > > \\<backtrace-mode-map> (note: this is the part telling emacs where
>> to
>> > > look for the key)
>> > > > One can exit the debugger with the `quit-window' command (bound to
>> > > \\[quit-window])."
>> > > >
>> > > >
>> > > Although quit-window is bound to q, the command \\[quit-window] just
>> > > inserts
>> > > M-x quit-window, rather than q.
>> > >
>> >
>> > Yes, that's precisely because quit-window doesn't have a global binding.
>> > You need to add \\<backtrace-mode-map> somewhere in the docstring to
>> tell
>> > emacs to show bindings for the backtrace buffers, rather than global
>> > bindings.
>> >
>> > Best wishes,
>> > Thibaut
>>
>> Sounds good advice, but the result could be
>>
>> Uses keymap ‘backtrace-mode-map’, which is not currently defined.
>
>
> My bad, it should have been debugger-mode-map.
>
>
> Not quite right yet.
>

I guess one should also put (require 'debug) at some point along with the
function definition?


Best wishes,
Thibaut


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-28  7:06                         ` Thibaut Verron
@ 2022-07-28  7:34                           ` Christopher Dimech
  2022-07-28  9:37                             ` thibaut.verron
  0 siblings, 1 reply; 27+ messages in thread
From: Christopher Dimech @ 2022-07-28  7:34 UTC (permalink / raw)
  To: thibaut.verron; +Cc: carlmarcos, Emanuel Berg, help-gnu-emacs

   Sent: Thursday, July 28, 2022 at 7:06 PM
   From: "Thibaut Verron" <thibaut.verron@gmail.com>
   To: "Christopher Dimech" <dimech@gmx.com>
   Cc: carlmarcos@tutanota.com, "Emanuel Berg" <incal@dataswamp.org>,
   "help-gnu-emacs" <help-gnu-emacs@gnu.org>
   Subject: Re: Generality of defvar
   Le jeu. 28 juil. 2022 à 08:42, Christopher Dimech <[1]dimech@gmx.com> a
   écrit :


   Sent: Thursday, July 28, 2022 at 4:39 AM
   From: "Thibaut Verron" <[2]thibaut.verron@gmail.com>
   To: "Christopher Dimech" <[3]dimech@gmx.com>
   Cc: [4]carlmarcos@tutanota.com, "Emanuel Berg"
   <[5]incal@dataswamp.org>, "help-gnu-emacs" <[6]help-gnu-emacs@gnu.org>
   Subject: Re: Generality of defvar
   Le mer. 27 juil. 2022 à 18:29, Christopher Dimech <[7]dimech@gmx.com> a
   écrit :

     > Sent: Thursday, July 28, 2022 at 1:47 AM
     > From: "Thibaut Verron" <[8]thibaut.verron@gmail.com>
     > To: [9]carlmarcos@tutanota.com
     > Cc: "Emanuel Berg" <[10]incal@dataswamp.org>, "help-gnu-emacs"
     <[11]help-gnu-emacs@gnu.org>
     > Subject: Re: Generality of defvar
     >
     > Le mer. 27 juil. 2022 à 15:24, <[12]carlmarcos@tutanota.com> a
     écrit :
     >
     > >
     > > Jul 27, 2022, 13:21 by [13]thibaut.verron@gmail.com:
     > >
     > > > Le mer. 27 juil. 2022 à 14:52, carlmarcos--- via Users list
     for the GNU
     > > Emacs text editor <> [14]help-gnu-emacs@gnu.org> > a écrit :
     > > >
     > > >>
     > > >>
     > > >>  Jul 27, 2022, 12:34 by >> [15]incal@dataswamp.org>> :
     > > >>
     > > >>  > carlmarcos--- via Users list for the GNU Emacs text editor
     wrote:
     > > >>  >
     > > >>  >> (defun enable-error-diagnostics ()
     > > >>  >>  "Enable error diagnostics with backtrace buffer.
     > > >>  >> One can exit the debugger with the q command."
     > > >>  >>
     > > >>  >
     > > >>  > You can refer to keys in docstrings like this:
     > > >>  >
     > > >>  >  \\[forward-word]
     > > >>  >
     > > >>  > That way, it isn't hardcoded so if later
     changed/configured
     > > >>  > it'll still show the right key.
     > > >>  >
     > > >>  How can I figure out what key to use in the docstring for
     exiting the
     > > backtrace buffer?
     > > >>
     > > >
     > > > The function bound to 'q' is quit-window. But since this
     function
     > > doesn't have a global binding, you need to tell the docstring to
     use the
     > > appropriate keymap to look the binding up.
     > > >
     > > > Something like
     > > >
     > > >   "Enable error diagnostics with backtrace buffer.
     > > >
     > > > \\<backtrace-mode-map> (note: this is the part telling emacs
     where to
     > > look for the key)
     > > > One can exit the debugger with the `quit-window' command
     (bound to
     > > \\[quit-window])."
     > > >
     > > >
     > > Although quit-window is bound to q, the command \\[quit-window]
     just
     > > inserts
     > > M-x quit-window, rather than q.
     > >
     >
     > Yes, that's precisely because quit-window doesn't have a global
     binding.
     > You need to add \\<backtrace-mode-map> somewhere in the docstring
     to tell
     > emacs to show bindings for the backtrace buffers, rather than
     global
     > bindings.
     >
     > Best wishes,
     > Thibaut
     Sounds good advice, but the result could be
     Uses keymap ‘backtrace-mode-map’, which is not currently defined.


   My bad, it should have been debugger-mode-map.


   Not quite right yet.


   I guess one should also put (require 'debug) at some point along with
   the function definition?

   Seems more bother than it solves.  Cannot see how users would be able
   to figure all this complication
   out.

References

   1. mailto:dimech@gmx.com
   2. mailto:thibaut.verron@gmail.com
   3. mailto:dimech@gmx.com
   4. mailto:carlmarcos@tutanota.com
   5. mailto:incal@dataswamp.org
   6. mailto:help-gnu-emacs@gnu.org
   7. mailto:dimech@gmx.com
   8. mailto:thibaut.verron@gmail.com
   9. mailto:carlmarcos@tutanota.com
  10. mailto:incal@dataswamp.org
  11. mailto:help-gnu-emacs@gnu.org
  12. mailto:carlmarcos@tutanota.com
  13. mailto:thibaut.verron@gmail.com
  14. mailto:help-gnu-emacs@gnu.org
  15. mailto:incal@dataswamp.org


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-28  7:34                           ` Christopher Dimech
@ 2022-07-28  9:37                             ` thibaut.verron
  2022-07-28 13:57                               ` Christopher Dimech
  0 siblings, 1 reply; 27+ messages in thread
From: thibaut.verron @ 2022-07-28  9:37 UTC (permalink / raw)
  To: Christopher Dimech, carlmarcos, Emanuel Berg, help-gnu-emacs

On 28/07/2022 09:34, Christopher Dimech <dimech@gmx.com> wrote:
> *Sent:* Thursday, July 28, 2022 at 7:06 PM
> *From:* "Thibaut Verron" <thibaut.verron@gmail.com>
> *To:* "Christopher Dimech" <dimech@gmx.com>
> *Cc:* carlmarcos@tutanota.com, "Emanuel Berg" <incal@dataswamp.org>, 
> "help-gnu-emacs" <help-gnu-emacs@gnu.org>
> *Subject:* Re: Generality of defvar
> Le jeu. 28 juil. 2022 à 08:42, Christopher Dimech <dimech@gmx.com 
> <mailto:dimech@gmx.com>> a écrit :
> 
>     *Sent:* Thursday, July 28, 2022 at 4:39 AM
>     *From:* "Thibaut Verron" <thibaut.verron@gmail.com
>     <mailto:thibaut.verron@gmail.com>>
>     *To:* "Christopher Dimech" <dimech@gmx.com <mailto:dimech@gmx.com>>
>     *Cc:* carlmarcos@tutanota.com <mailto:carlmarcos@tutanota.com>,
>     "Emanuel Berg" <incal@dataswamp.org <mailto:incal@dataswamp.org>>,
>     "help-gnu-emacs" <help-gnu-emacs@gnu.org
>     <mailto:help-gnu-emacs@gnu.org>>
>     *Subject:* Re: Generality of defvar
>     Le mer. 27 juil. 2022 à 18:29, Christopher Dimech <dimech@gmx.com
>     <mailto:dimech@gmx.com>> a écrit :
> 
> 
> 
>          > Sent: Thursday, July 28, 2022 at 1:47 AM
>          > From: "Thibaut Verron" <thibaut.verron@gmail.com
>         <mailto:thibaut.verron@gmail.com>>
>          > To: carlmarcos@tutanota.com <mailto:carlmarcos@tutanota.com>
>          > Cc: "Emanuel Berg" <incal@dataswamp.org
>         <mailto:incal@dataswamp.org>>, "help-gnu-emacs"
>         <help-gnu-emacs@gnu.org <mailto:help-gnu-emacs@gnu.org>>
>          > Subject: Re: Generality of defvar
>          >
>          > Le mer. 27 juil. 2022 à 15:24, <carlmarcos@tutanota.com
>         <mailto:carlmarcos@tutanota.com>> a écrit :
>          >
>          > >
>          > > Jul 27, 2022, 13:21 by thibaut.verron@gmail.com
>         <mailto:thibaut.verron@gmail.com>:
>          > >
>          > > > Le mer. 27 juil. 2022 à 14:52, carlmarcos--- via Users
>         list for the GNU
>          > > Emacs text editor <> help-gnu-emacs@gnu.org
>         <mailto:help-gnu-emacs@gnu.org>> > a écrit :
>          > > >
>          > > >>
>          > > >>
>          > > >>  Jul 27, 2022, 12:34 by >> incal@dataswamp.org
>         <mailto:incal@dataswamp.org>>> :
>          > > >>
>          > > >>  > carlmarcos--- via Users list for the GNU Emacs text
>         editor wrote:
>          > > >>  >
>          > > >>  >> (defun enable-error-diagnostics ()
>          > > >>  >>  "Enable error diagnostics with backtrace buffer.
>          > > >>  >> One can exit the debugger with the q command."
>          > > >>  >>
>          > > >>  >
>          > > >>  > You can refer to keys in docstrings like this:
>          > > >>  >
>          > > >>  >  \\[forward-word]
>          > > >>  >
>          > > >>  > That way, it isn't hardcoded so if later
>         changed/configured
>          > > >>  > it'll still show the right key.
>          > > >>  >
>          > > >>  How can I figure out what key to use in the docstring
>         for exiting the
>          > > backtrace buffer?
>          > > >>
>          > > >
>          > > > The function bound to 'q' is quit-window. But since this
>         function
>          > > doesn't have a global binding, you need to tell the
>         docstring to use the
>          > > appropriate keymap to look the binding up.
>          > > >
>          > > > Something like
>          > > >
>          > > >   "Enable error diagnostics with backtrace buffer.
>          > > >
>          > > > \\<backtrace-mode-map> (note: this is the part telling
>         emacs where to
>          > > look for the key)
>          > > > One can exit the debugger with the `quit-window' command
>         (bound to
>          > > \\[quit-window])."
>          > > >
>          > > >
>          > > Although quit-window is bound to q, the command
>         \\[quit-window] just
>          > > inserts
>          > > M-x quit-window, rather than q.
>          > >
>          >
>          > Yes, that's precisely because quit-window doesn't have a
>         global binding.
>          > You need to add \\<backtrace-mode-map> somewhere in the
>         docstring to tell
>          > emacs to show bindings for the backtrace buffers, rather than
>         global
>          > bindings.
>          >
>          > Best wishes,
>          > Thibaut
> 
>         Sounds good advice, but the result could be
> 
>         Uses keymap ‘backtrace-mode-map’, which is not currently defined.
> 
>     My bad, it should have been debugger-mode-map.
>     Not quite right yet.
> 
> I guess one should also put (require 'debug) at some point along with 
> the function definition?
> Seems more bother than it solves.  Cannot see how users would be able to 
> figure all this complication
> out.

For sure. But it's really a rare situation, and not one that is likely to hit first time users: one has to be writing a function with a docstring, and this docstring has to involve a key bound in a keymap defined in another file, and not loaded by default.

Even for users developing their own packages, usually the keymap will be defined in a file loaded at the same time as the function, completely hiding this subtlety.

Still, I would almost be tempted to consider this case a bug, and to expect that emacs should autoload debug.el to display the relevant information.

Thibaut



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-28  9:37                             ` thibaut.verron
@ 2022-07-28 13:57                               ` Christopher Dimech
  0 siblings, 0 replies; 27+ messages in thread
From: Christopher Dimech @ 2022-07-28 13:57 UTC (permalink / raw)
  To: thibaut.verron; +Cc: carlmarcos, Emanuel Berg, help-gnu-emacs

> Sent: Thursday, July 28, 2022 at 9:37 PM
> From: thibaut.verron@gmail.com
> To: "Christopher Dimech" <dimech@gmx.com>, carlmarcos@tutanota.com, "Emanuel Berg" <incal@dataswamp.org>, "help-gnu-emacs" <help-gnu-emacs@gnu.org>
> Subject: Re: Generality of defvar
>
> On 28/07/2022 09:34, Christopher Dimech <dimech@gmx.com> wrote:
> > *Sent:* Thursday, July 28, 2022 at 7:06 PM
> > *From:* "Thibaut Verron" <thibaut.verron@gmail.com>
> > *To:* "Christopher Dimech" <dimech@gmx.com>
> > *Cc:* carlmarcos@tutanota.com, "Emanuel Berg" <incal@dataswamp.org>, 
> > "help-gnu-emacs" <help-gnu-emacs@gnu.org>
> > *Subject:* Re: Generality of defvar
> > Le jeu. 28 juil. 2022 à 08:42, Christopher Dimech <dimech@gmx.com 
> > <mailto:dimech@gmx.com>> a écrit :
> > 
> >     *Sent:* Thursday, July 28, 2022 at 4:39 AM
> >     *From:* "Thibaut Verron" <thibaut.verron@gmail.com
> >     <mailto:thibaut.verron@gmail.com>>
> >     *To:* "Christopher Dimech" <dimech@gmx.com <mailto:dimech@gmx.com>>
> >     *Cc:* carlmarcos@tutanota.com <mailto:carlmarcos@tutanota.com>,
> >     "Emanuel Berg" <incal@dataswamp.org <mailto:incal@dataswamp.org>>,
> >     "help-gnu-emacs" <help-gnu-emacs@gnu.org
> >     <mailto:help-gnu-emacs@gnu.org>>
> >     *Subject:* Re: Generality of defvar
> >     Le mer. 27 juil. 2022 à 18:29, Christopher Dimech <dimech@gmx.com
> >     <mailto:dimech@gmx.com>> a écrit :
> > 
> > 
> > 
> >          > Sent: Thursday, July 28, 2022 at 1:47 AM
> >          > From: "Thibaut Verron" <thibaut.verron@gmail.com
> >         <mailto:thibaut.verron@gmail.com>>
> >          > To: carlmarcos@tutanota.com <mailto:carlmarcos@tutanota.com>
> >          > Cc: "Emanuel Berg" <incal@dataswamp.org
> >         <mailto:incal@dataswamp.org>>, "help-gnu-emacs"
> >         <help-gnu-emacs@gnu.org <mailto:help-gnu-emacs@gnu.org>>
> >          > Subject: Re: Generality of defvar
> >          >
> >          > Le mer. 27 juil. 2022 à 15:24, <carlmarcos@tutanota.com
> >         <mailto:carlmarcos@tutanota.com>> a écrit :
> >          >
> >          > >
> >          > > Jul 27, 2022, 13:21 by thibaut.verron@gmail.com
> >         <mailto:thibaut.verron@gmail.com>:
> >          > >
> >          > > > Le mer. 27 juil. 2022 à 14:52, carlmarcos--- via Users
> >         list for the GNU
> >          > > Emacs text editor <> help-gnu-emacs@gnu.org
> >         <mailto:help-gnu-emacs@gnu.org>> > a écrit :
> >          > > >
> >          > > >>
> >          > > >>
> >          > > >>  Jul 27, 2022, 12:34 by >> incal@dataswamp.org
> >         <mailto:incal@dataswamp.org>>> :
> >          > > >>
> >          > > >>  > carlmarcos--- via Users list for the GNU Emacs text
> >         editor wrote:
> >          > > >>  >
> >          > > >>  >> (defun enable-error-diagnostics ()
> >          > > >>  >>  "Enable error diagnostics with backtrace buffer.
> >          > > >>  >> One can exit the debugger with the q command."
> >          > > >>  >>
> >          > > >>  >
> >          > > >>  > You can refer to keys in docstrings like this:
> >          > > >>  >
> >          > > >>  >  \\[forward-word]
> >          > > >>  >
> >          > > >>  > That way, it isn't hardcoded so if later
> >         changed/configured
> >          > > >>  > it'll still show the right key.
> >          > > >>  >
> >          > > >>  How can I figure out what key to use in the docstring
> >         for exiting the
> >          > > backtrace buffer?
> >          > > >>
> >          > > >
> >          > > > The function bound to 'q' is quit-window. But since this
> >         function
> >          > > doesn't have a global binding, you need to tell the
> >         docstring to use the
> >          > > appropriate keymap to look the binding up.
> >          > > >
> >          > > > Something like
> >          > > >
> >          > > >   "Enable error diagnostics with backtrace buffer.
> >          > > >
> >          > > > \\<backtrace-mode-map> (note: this is the part telling
> >         emacs where to
> >          > > look for the key)
> >          > > > One can exit the debugger with the `quit-window' command
> >         (bound to
> >          > > \\[quit-window])."
> >          > > >
> >          > > >
> >          > > Although quit-window is bound to q, the command
> >         \\[quit-window] just
> >          > > inserts
> >          > > M-x quit-window, rather than q.
> >          > >
> >          >
> >          > Yes, that's precisely because quit-window doesn't have a
> >         global binding.
> >          > You need to add \\<backtrace-mode-map> somewhere in the
> >         docstring to tell
> >          > emacs to show bindings for the backtrace buffers, rather than
> >         global
> >          > bindings.
> >          >
> >          > Best wishes,
> >          > Thibaut
> > 
> >         Sounds good advice, but the result could be
> > 
> >         Uses keymap ‘backtrace-mode-map’, which is not currently defined.
> > 
> >     My bad, it should have been debugger-mode-map.
> >     Not quite right yet.
> > 
> > I guess one should also put (require 'debug) at some point along with 
> > the function definition?
> > Seems more bother than it solves.  Cannot see how users would be able to 
> > figure all this complication
> > out.
> 
> For sure. But it's really a rare situation, and not one that is likely to hit first time users: one has to be writing a function with a docstring, and this docstring has to involve a key bound in a keymap defined in another file, and not loaded by default.
> 
> Even for users developing their own packages, usually the keymap will be defined in a file loaded at the same time as the function, completely hiding this subtlety.
> 
> Still, I would almost be tempted to consider this case a bug, and to expect that emacs should autoload debug.el to display the relevant information.
> 
> Thibaut

I concur Thibaut.  Do send a report as you suggest.  




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Generality of defvar
  2022-07-27  4:57   ` Yuri Khan
  2022-07-27  6:59     ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-29 15:56     ` Emanuel Berg
  2022-07-29 16:25       ` [External] : " Drew Adams
  1 sibling, 1 reply; 27+ messages in thread
From: Emanuel Berg @ 2022-07-29 15:56 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

>> (defvar var-name)
>> (setq var-name 'var-value)
>>
>> instead because if you do something with that and want to
>> reset it, it's enough to evaluate the second line, whereas
>> if you just have the first line you tend to evaluate that
>> one and if/because the variable is already set at that
>> point then nothing will happen ...
>
> Yes, but you can press C-M-x on a (defvar var-name
> 'var-value) and it will get re-set to the new value even if
> the variable is already defined.

So you can! I just tested and you are right. Did they change
that recently? Okay then, I guess there is no point in doing

  (defvar var-name)
  (setq var-name 'var-value)

anymore.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 27+ messages in thread

* RE: [External] : Re: Generality of defvar
  2022-07-29 15:56     ` Emanuel Berg
@ 2022-07-29 16:25       ` Drew Adams
  2022-07-30  3:56         ` Emanuel Berg
  0 siblings, 1 reply; 27+ messages in thread
From: Drew Adams @ 2022-07-29 16:25 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs@gnu.org

> > Yes, but you can press C-M-x on a (defvar var-name
> > 'var-value) and it will get re-set to the new value even if
> > the variable is already defined.
> 
> So you can! I just tested and you are right. Did they change
> that recently?

80s? 70s?




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [External] : Re: Generality of defvar
  2022-07-29 16:25       ` [External] : " Drew Adams
@ 2022-07-30  3:56         ` Emanuel Berg
  2022-07-30 19:36           ` Drew Adams
  0 siblings, 1 reply; 27+ messages in thread
From: Emanuel Berg @ 2022-07-30  3:56 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

>>> Yes, but you can press C-M-x on a (defvar var-name
>>> 'var-value) and it will get re-set to the new value even
>>> if the variable is already defined.
>> 
>> So you can! I just tested and you are right. Did they
>> change that recently?
>
> 80s? 70s?

Haha :)

Nevermind then.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 27+ messages in thread

* RE: [External] : Re: Generality of defvar
  2022-07-30  3:56         ` Emanuel Berg
@ 2022-07-30 19:36           ` Drew Adams
  2022-08-01  3:24             ` Emanuel Berg
  0 siblings, 1 reply; 27+ messages in thread
From: Drew Adams @ 2022-07-30 19:36 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs@gnu.org

> >>> Yes, but you can press C-M-x on a (defvar var-name
> >>> 'var-value) and it will get re-set to the new value even
> >>> if the variable is already defined.
> >>
> >> So you can! I just tested and you are right. Did they
> >> change that recently?
> >
> > 80s? 70s?
> 
> Haha :)
> 
> Nevermind then.

Sorry, I guess that might have sounded a bit snarky.

Dunno when this behavior was defined for Elisp
`defvar' (and some others), but it's been there as
long as I can remember, which probably goes back to
Emacs 18, in the early 80s.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [External] : Re: Generality of defvar
  2022-07-30 19:36           ` Drew Adams
@ 2022-08-01  3:24             ` Emanuel Berg
  0 siblings, 0 replies; 27+ messages in thread
From: Emanuel Berg @ 2022-08-01  3:24 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

>>>>> Yes, but you can press C-M-x on a (defvar var-name
>>>>> 'var-value) and it will get re-set to the new value even
>>>>> if the variable is already defined.
>>>>
>>>> So you can! I just tested and you are right. Did they
>>>> change that recently?
>>>
>>> 80s? 70s?
>> 
>> Haha :)
>> 
>> Nevermind then.
>
> Sorry, I guess that might have sounded a bit snarky.

No, I like the old-school parts of me. The parts of me that
I consider old-school ...

> Dunno when this behavior was defined for Elisp `defvar' (and
> some others), but it's been there as long as I can remember,
> which probably goes back to Emacs 18, in the early 80s.

Yeah, must have picked that up from some old manual.


-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2022-08-01  3:24 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-26 20:35 Generality of defvar carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-26 23:01 ` Philip Kaludercic
     [not found] ` <87r127h40s.fsf@posteo.net-N7wjq17--3-2>
2022-07-26 23:10   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-27  7:29     ` Thibaut Verron
     [not found]     ` <CAFsi02SEVCEjGNoQ6vPZvMw7d5F39JZAAPCR5VOUnzQDUERkQA@mail.gmail.com-N7yZ2U2----2>
2022-07-27 12:18       ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-27 12:34         ` Emanuel Berg
2022-07-27 12:52           ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-27 13:21             ` Thibaut Verron
2022-07-27 13:24               ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-27 13:47                 ` Thibaut Verron
2022-07-27 16:29                   ` Christopher Dimech
2022-07-27 16:39                     ` Thibaut Verron
2022-07-28  6:42                       ` Christopher Dimech
2022-07-28  7:06                         ` Thibaut Verron
2022-07-28  7:34                           ` Christopher Dimech
2022-07-28  9:37                             ` thibaut.verron
2022-07-28 13:57                               ` Christopher Dimech
2022-07-26 23:16 ` Emanuel Berg
2022-07-26 23:23   ` Emanuel Berg
2022-07-26 23:36   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-27  4:57   ` Yuri Khan
2022-07-27  6:59     ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-29 15:56     ` Emanuel Berg
2022-07-29 16:25       ` [External] : " Drew Adams
2022-07-30  3:56         ` Emanuel Berg
2022-07-30 19:36           ` Drew Adams
2022-08-01  3:24             ` Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.