* Does defvar-local has same effect as make-variable-buffer-local?
@ 2021-05-15 20:14 Jean Louis
2021-05-15 20:49 ` [External] : " Drew Adams
2021-05-16 4:11 ` Eli Zaretskii
0 siblings, 2 replies; 12+ messages in thread
From: Jean Louis @ 2021-05-15 20:14 UTC (permalink / raw)
To: Help GNU Emacs
I did read the documentation, yet I need assurance on this subject.
For this below:
(defvar rcd-current-hash nil)
(make-variable-buffer-local 'rcd-current-hash)
Is the above totally equivalent to this below?
(defvar-local rcd-current-hash nil)
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] 12+ messages in thread
* RE: [External] : Does defvar-local has same effect as make-variable-buffer-local?
2021-05-15 20:14 Does defvar-local has same effect as make-variable-buffer-local? Jean Louis
@ 2021-05-15 20:49 ` Drew Adams
2021-05-15 21:01 ` Drew Adams
2021-05-16 4:11 ` Eli Zaretskii
1 sibling, 1 reply; 12+ messages in thread
From: Drew Adams @ 2021-05-15 20:49 UTC (permalink / raw)
To: Jean Louis, Help GNU Emacs
> (defvar rcd-current-hash nil)
> (make-variable-buffer-local 'rcd-current-hash)
>
> Is the above totally equivalent to this below?
>
> (defvar-local rcd-current-hash nil)
Ask Emacs.
`C-h f defvar-local', then click link `subr.el':
(defmacro defvar-local (var val &optional docstring)
"..."
;; Can't use backquote here, it's too early in the bootstrap.
(list 'progn (list 'defvar var val docstring)
(list 'make-variable-buffer-local (list 'quote var))))
So yes. Without the fiddling for presence in `subr.el'
that would be just:
(defmacro defvar-local (var val &optional docstring)
`(progn (defvar ,var ,val docstring)
(make-variable-buffer-local ',val)))
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [External] : Does defvar-local has same effect as make-variable-buffer-local?
2021-05-15 20:49 ` [External] : " Drew Adams
@ 2021-05-15 21:01 ` Drew Adams
2021-05-15 21:41 ` Jean Louis
0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2021-05-15 21:01 UTC (permalink / raw)
To: Jean Louis, Help GNU Emacs
> (defmacro defvar-local (var val &optional docstring)
> `(progn (defvar ,var ,val docstring)
> (make-variable-buffer-local ',val)))
Sorry, `docstring' too should have a comma in front of it:
(defmacro defvar-local (var val &optional docstring)
`(progn (defvar ,var ,val ,docstring)
(make-variable-buffer-local ',val)))
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Does defvar-local has same effect as make-variable-buffer-local?
2021-05-15 21:01 ` Drew Adams
@ 2021-05-15 21:41 ` Jean Louis
2021-05-15 22:16 ` Drew Adams
0 siblings, 1 reply; 12+ messages in thread
From: Jean Louis @ 2021-05-15 21:41 UTC (permalink / raw)
To: Drew Adams; +Cc: Help GNU Emacs
* Drew Adams <drew.adams@oracle.com> [2021-05-16 00:02]:
> > (defmacro defvar-local (var val &optional docstring)
> > `(progn (defvar ,var ,val docstring)
> > (make-variable-buffer-local ',val)))
>
> Sorry, `docstring' too should have a comma in front of it:
>
> (defmacro defvar-local (var val &optional docstring)
> `(progn (defvar ,var ,val ,docstring)
> (make-variable-buffer-local ',val)))
Oh yes, I missed what you explained, thanks.
--
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] 12+ messages in thread
* RE: [External] : Does defvar-local has same effect as make-variable-buffer-local?
2021-05-15 21:41 ` Jean Louis
@ 2021-05-15 22:16 ` Drew Adams
2021-05-15 22:21 ` Jean Louis
0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2021-05-15 22:16 UTC (permalink / raw)
To: Jean Louis; +Cc: Help GNU Emacs
> Oh yes, I missed what you explained, thanks.
The main point was that you can learn better by asking
Emacs such things. Use the Source, Luc. Things like
`defvar-local' are defined in Lisp, and it's easy to
get to their definitions. In this case, the definition
is simple. Sometimes, of course, that's not the case.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Does defvar-local has same effect as make-variable-buffer-local?
2021-05-15 22:16 ` Drew Adams
@ 2021-05-15 22:21 ` Jean Louis
0 siblings, 0 replies; 12+ messages in thread
From: Jean Louis @ 2021-05-15 22:21 UTC (permalink / raw)
To: Drew Adams; +Cc: Help GNU Emacs
* Drew Adams <drew.adams@oracle.com> [2021-05-16 01:17]:
> > Oh yes, I missed what you explained, thanks.
>
> The main point was that you can learn better by asking
> Emacs such things. Use the Source, Luc. Things like
> `defvar-local' are defined in Lisp, and it's easy to
> get to their definitions. In this case, the definition
> is simple. Sometimes, of course, that's not the case.
If it would be just asking... I wish so.
Sure, I do use all the help commands. It is not finished by reading
documentation. Sometimes I read code of other people and that is where
questions arise that may be surprising and require clarification from
others.
--
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] 12+ messages in thread
* Re: Does defvar-local has same effect as make-variable-buffer-local?
2021-05-15 20:14 Does defvar-local has same effect as make-variable-buffer-local? Jean Louis
2021-05-15 20:49 ` [External] : " Drew Adams
@ 2021-05-16 4:11 ` Eli Zaretskii
2021-05-16 8:09 ` Jean Louis
1 sibling, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2021-05-16 4:11 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Sat, 15 May 2021 23:14:38 +0300
> From: Jean Louis <bugs@gnu.support>
>
> I did read the documentation, yet I need assurance on this subject.
Why not look at the source? Then you could be absolutely sure.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does defvar-local has same effect as make-variable-buffer-local?
2021-05-16 4:11 ` Eli Zaretskii
@ 2021-05-16 8:09 ` Jean Louis
2021-05-16 8:52 ` Yuri Khan
2021-05-16 8:55 ` Eli Zaretskii
0 siblings, 2 replies; 12+ messages in thread
From: Jean Louis @ 2021-05-16 8:09 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
* Eli Zaretskii <eliz@gnu.org> [2021-05-16 07:12]:
> > Date: Sat, 15 May 2021 23:14:38 +0300
> > From: Jean Louis <bugs@gnu.support>
> >
> > I did read the documentation, yet I need assurance on this subject.
>
> Why not look at the source? Then you could be absolutely sure.
Because I read the other sources (not source of definition) I get
confused, example in simple.el:
(defvar minibuffer-history-isearch-message-overlay)
(make-variable-buffer-local 'minibuffer-history-isearch-message-overlay)
Then I ask myself why did not author straight write like:
(defvar-local minibuffer-history-isearch-message-overlay)
I ask myself why that, what is the difference... then I need
assistance in clarification.
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] 12+ messages in thread
* Re: Does defvar-local has same effect as make-variable-buffer-local?
2021-05-16 8:09 ` Jean Louis
@ 2021-05-16 8:52 ` Yuri Khan
2021-05-16 16:53 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-16 8:55 ` Eli Zaretskii
1 sibling, 1 reply; 12+ messages in thread
From: Yuri Khan @ 2021-05-16 8:52 UTC (permalink / raw)
To: Eli Zaretskii, help-gnu-emacs
On Sun, 16 May 2021 at 15:32, Jean Louis <bugs@gnu.support> wrote:
> > Why not look at the source? Then you could be absolutely sure.
>
> Because I read the other sources (not source of definition) I get
> confused, example in simple.el:
>
> (defvar minibuffer-history-isearch-message-overlay)
> (make-variable-buffer-local 'minibuffer-history-isearch-message-overlay)
>
> Then I ask myself why did not author straight write like:
>
> (defvar-local minibuffer-history-isearch-message-overlay)
>
> I ask myself why that, what is the difference... then I need
> assistance in clarification.
Why not look at the history? ;)
$ git blame subr.el
shows that defvar-local was introduced on May 4, 2012. On the other hand,
$ git blame simple.el
shows minibuffer-history-isearch-message-overlay was added July 23,
2007. Its author could not have used defvar-local at the time, because
it had not yet been invented.
This leaves us with the question “why didn’t the author of
defvar-local immediately convert all code to use it”, to which a
possible answer is “because he wasn’t sure it makes a big difference”.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does defvar-local has same effect as make-variable-buffer-local?
2021-05-16 8:52 ` Yuri Khan
@ 2021-05-16 16:53 ` Stefan Monnier via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-05-16 16:53 UTC (permalink / raw)
To: help-gnu-emacs
> This leaves us with the question “why didn’t the author of
> defvar-local immediately convert all code to use it”, to which a
> possible answer is “because he wasn’t sure it makes a big difference”.
I can't speak for the author of `defvar-local`, who must have been
a pretty confused individual, but there's generally a reluctance to make
such cosmetic changes in code unless we're also changing something more
substantial in that same code at the same time (the reason being to
avoid spurious merge conflicts for people managing branches).
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Does defvar-local has same effect as make-variable-buffer-local?
2021-05-16 8:09 ` Jean Louis
2021-05-16 8:52 ` Yuri Khan
@ 2021-05-16 8:55 ` Eli Zaretskii
2021-05-16 11:26 ` Jean Louis
1 sibling, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2021-05-16 8:55 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Sun, 16 May 2021 11:09:02 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
>
> * Eli Zaretskii <eliz@gnu.org> [2021-05-16 07:12]:
> > > Date: Sat, 15 May 2021 23:14:38 +0300
> > > From: Jean Louis <bugs@gnu.support>
> > >
> > > I did read the documentation, yet I need assurance on this subject.
> >
> > Why not look at the source? Then you could be absolutely sure.
>
> Because I read the other sources (not source of definition) I get
> confused, example in simple.el:
>
> (defvar minibuffer-history-isearch-message-overlay)
> (make-variable-buffer-local 'minibuffer-history-isearch-message-overlay)
>
> Then I ask myself why did not author straight write like:
>
> (defvar-local minibuffer-history-isearch-message-overlay)
>
> I ask myself why that, what is the difference... then I need
> assistance in clarification.
The doc string of defvar-local answers that question as well:
(defvar-local VAR VAL &optional DOCSTRING)
Probably introduced at or before Emacs version 24.3.
^^^^^^^^^^^^
So code written before that version couldn't use defvar-local.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-05-16 16:53 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-15 20:14 Does defvar-local has same effect as make-variable-buffer-local? Jean Louis
2021-05-15 20:49 ` [External] : " Drew Adams
2021-05-15 21:01 ` Drew Adams
2021-05-15 21:41 ` Jean Louis
2021-05-15 22:16 ` Drew Adams
2021-05-15 22:21 ` Jean Louis
2021-05-16 4:11 ` Eli Zaretskii
2021-05-16 8:09 ` Jean Louis
2021-05-16 8:52 ` Yuri Khan
2021-05-16 16:53 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-16 8:55 ` Eli Zaretskii
2021-05-16 11:26 ` Jean Louis
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.