* Arguing for a nilp function and where to put it
@ 2023-04-01 5:37 Pedro Andres Aranda Gutierrez
2023-04-01 6:01 ` tomas
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Pedro Andres Aranda Gutierrez @ 2023-04-01 5:37 UTC (permalink / raw)
To: emacs-devel
Use case for a nilp function:
I have a buffer-local variable with a default value, and I want to
allow to (silently) set it to nil (and only to nil) from
.dir-locals.el or Local Variables.
Currently I have
(defun nilp(v) (unless v t))
and I use it with
(put '<variable> 'safe-local-variable #'nilp)
which is much cleaner than
(put '<variable> 'safe-local-variable (lambda (p) (unless p t)))
every time I need it. I think other people may benefit from having
this simple function as part of Emacs and I'm not sure whether the
elisp form would be better than something more lower level like
integerp and in which file it would reside best.
/PA
--
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler
Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should
run a leader-deposed hook here, but we can't yet
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-01 5:37 Arguing for a nilp function and where to put it Pedro Andres Aranda Gutierrez
@ 2023-04-01 6:01 ` tomas
2023-04-01 6:07 ` Michael Albinus
2023-04-01 6:10 ` Eli Zaretskii
2 siblings, 0 replies; 13+ messages in thread
From: tomas @ 2023-04-01 6:01 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 629 bytes --]
On Sat, Apr 01, 2023 at 07:37:44AM +0200, Pedro Andres Aranda Gutierrez wrote:
> Use case for a nilp function:
>
> I have a buffer-local variable with a default value, and I want to
> allow to (silently) set it to nil (and only to nil) from
> .dir-locals.el or Local Variables.
>
> Currently I have
>
> (defun nilp(v) (unless v t))
If I understand your needs correctly, the function you are
looking for is called `null'.
Yes, it breaks the convention for predicates (i.e. that they
should end in -p), but I think it's just because it has been
there for so long, like an old olive tree :-)
Cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-01 5:37 Arguing for a nilp function and where to put it Pedro Andres Aranda Gutierrez
2023-04-01 6:01 ` tomas
@ 2023-04-01 6:07 ` Michael Albinus
2023-04-01 6:10 ` Eli Zaretskii
2 siblings, 0 replies; 13+ messages in thread
From: Michael Albinus @ 2023-04-01 6:07 UTC (permalink / raw)
To: Pedro Andres Aranda Gutierrez; +Cc: emacs-devel
Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:
Hi Pedro,
> Use case for a nilp function:
>
> I have a buffer-local variable with a default value, and I want to
> allow to (silently) set it to nil (and only to nil) from
> .dir-locals.el or Local Variables.
>
> Currently I have
>
> (defun nilp(v) (unless v t))
>
> and I use it with
>
> (put '<variable> 'safe-local-variable #'nilp)
>
> which is much cleaner than
>
> (put '<variable> 'safe-local-variable (lambda (p) (unless p t)))
>
> every time I need it. I think other people may benefit from having
> this simple function as part of Emacs and I'm not sure whether the
> elisp form would be better than something more lower level like
> integerp and in which file it would reside best.
There is the `null' function, which is what you need.
> /PA
Best regards, Michael.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-01 5:37 Arguing for a nilp function and where to put it Pedro Andres Aranda Gutierrez
2023-04-01 6:01 ` tomas
2023-04-01 6:07 ` Michael Albinus
@ 2023-04-01 6:10 ` Eli Zaretskii
2023-04-01 7:09 ` Pedro Andres Aranda Gutierrez
2 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2023-04-01 6:10 UTC (permalink / raw)
To: Pedro Andres Aranda Gutierrez; +Cc: emacs-devel
> From: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>
> Date: Sat, 1 Apr 2023 07:37:44 +0200
>
> Use case for a nilp function:
>
> I have a buffer-local variable with a default value, and I want to
> allow to (silently) set it to nil (and only to nil) from
> .dir-locals.el or Local Variables.
>
> Currently I have
>
> (defun nilp(v) (unless v t))
>
> and I use it with
>
> (put '<variable> 'safe-local-variable #'nilp)
>
> which is much cleaner than
>
> (put '<variable> 'safe-local-variable (lambda (p) (unless p t)))
>
> every time I need it. I think other people may benefit from having
> this simple function as part of Emacs and I'm not sure whether the
> elisp form would be better than something more lower level like
> integerp and in which file it would reside best.
Why cannot you use the existing function 'null'?
If 'null' doesn't fit the bill, please explain why.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-01 6:10 ` Eli Zaretskii
@ 2023-04-01 7:09 ` Pedro Andres Aranda Gutierrez
2023-04-02 21:28 ` Roland Winkler
2023-04-03 3:02 ` Richard Stallman
0 siblings, 2 replies; 13+ messages in thread
From: Pedro Andres Aranda Gutierrez @ 2023-04-01 7:09 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
Hi Eli,
it might be that sometimes I'd like a bit more of logic...
When you want to check if a variable is an integer, you use integerp,
when you want to check if a variable is a string, you use stringp, etc.
so I was expecting, in pure logic and in the frenzy of real life, that
when you want to check if a variable is nil, you use nilp
So, null is an outlier... no problem, can live with that... intuition
failed me <blush>RTFM</blush>...
Anyway, thx
/PA
On Sat, 1 Apr 2023 at 08:09, Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>
> > Date: Sat, 1 Apr 2023 07:37:44 +0200
> >
> > Use case for a nilp function:
> >
> > I have a buffer-local variable with a default value, and I want to
> > allow to (silently) set it to nil (and only to nil) from
> > .dir-locals.el or Local Variables.
> >
> > Currently I have
> >
> > (defun nilp(v) (unless v t))
> >
> > and I use it with
> >
> > (put '<variable> 'safe-local-variable #'nilp)
> >
> > which is much cleaner than
> >
> > (put '<variable> 'safe-local-variable (lambda (p) (unless p t)))
> >
> > every time I need it. I think other people may benefit from having
> > this simple function as part of Emacs and I'm not sure whether the
> > elisp form would be better than something more lower level like
> > integerp and in which file it would reside best.
>
> Why cannot you use the existing function 'null'?
>
> If 'null' doesn't fit the bill, please explain why.
--
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler
Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should
run a leader-deposed hook here, but we can't yet
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-01 7:09 ` Pedro Andres Aranda Gutierrez
@ 2023-04-02 21:28 ` Roland Winkler
2023-04-03 3:02 ` Richard Stallman
1 sibling, 0 replies; 13+ messages in thread
From: Roland Winkler @ 2023-04-02 21:28 UTC (permalink / raw)
To: emacs-devel
On Sat, Apr 01 2023, Pedro Andres Aranda Gutierrez wrote:
> So, null is an outlier... no problem, can live with that... intuition
> failed me <blush>RTFM</blush>...
I normally do not look at emacs' C code. I was amused that all the
built-in function `null' does is call NILP.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-01 7:09 ` Pedro Andres Aranda Gutierrez
2023-04-02 21:28 ` Roland Winkler
@ 2023-04-03 3:02 ` Richard Stallman
2023-04-03 3:34 ` Emanuel Berg
1 sibling, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2023-04-03 3:02 UTC (permalink / raw)
To: Pedro Andres Aranda Gutierrez; +Cc: eliz, emacs-devel
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
I think `null' was among the first Lisp functions to be imagined and
given a name, at the very start of the invention of Lisp, before there
was an implementation -- along with `car', `cdr' and `cons'. The
convention of naming predicates to end in `p' must have come after
that.
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-03 3:02 ` Richard Stallman
@ 2023-04-03 3:34 ` Emanuel Berg
2023-04-03 12:46 ` Andreas Schwab
2023-04-03 18:48 ` Roland Winkler
0 siblings, 2 replies; 13+ messages in thread
From: Emanuel Berg @ 2023-04-03 3:34 UTC (permalink / raw)
To: emacs-devel
Richard Stallman wrote:
> I think `null' was among the first Lisp functions to be
> imagined and given a name, at the very start of the
> invention of Lisp, before there was an implementation --
> along with `car', `cdr' and `cons'. The convention of naming
> predicates to end in `p' must have come after that.
As you know, but it's interesting to those who don't ...
(info "(eintr) Strange Names")
The name of the cons function is not unreasonable: it is an
abbreviation of the word "construct". The origins of the
names for car and cdr, on the other hand, are esoteric: car
is an acronym from the phrase "Contents of the Address part
of the Register"; and cdr (pronounced "could-er") is an
acronym from the phrase "Contents of the Decrement part of
the Register". These phrases refer to specific pieces of
hardware on the very early computer on which the original
Lisp was developed.
Hm ... That was in 1958? What kind of machine was that?
https://www.gnu.org/software/emacs/manual/html_node/eintr/Strange-Names.html
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-03 3:34 ` Emanuel Berg
@ 2023-04-03 12:46 ` Andreas Schwab
2023-04-03 18:48 ` Roland Winkler
1 sibling, 0 replies; 13+ messages in thread
From: Andreas Schwab @ 2023-04-03 12:46 UTC (permalink / raw)
To: emacs-devel
On Apr 03 2023, Emanuel Berg wrote:
> Hm ... That was in 1958? What kind of machine was that?
According to Wikipedia, IBM 704.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-03 3:34 ` Emanuel Berg
2023-04-03 12:46 ` Andreas Schwab
@ 2023-04-03 18:48 ` Roland Winkler
2023-04-03 23:44 ` Emanuel Berg
2023-04-04 2:56 ` Richard Stallman
1 sibling, 2 replies; 13+ messages in thread
From: Roland Winkler @ 2023-04-03 18:48 UTC (permalink / raw)
To: emacs-devel
On Mon, Apr 03 2023, Emanuel Berg wrote:
> As you know, but it's interesting to those who don't ...
>
> (info "(eintr) Strange Names")
>
> The name of the cons function is not unreasonable: it is an
> abbreviation of the word "construct". The origins of the
> names for car and cdr, on the other hand, are esoteric: car
> is an acronym from the phrase "Contents of the Address part
> of the Register"; and cdr (pronounced "could-er") is an
> acronym from the phrase "Contents of the Decrement part of
> the Register". These phrases refer to specific pieces of
> hardware on the very early computer on which the original
> Lisp was developed.
>
> Hm ... That was in 1958? What kind of machine was that?
But (info "(eintr) Strange Names") goes on:
Besides being obsolete, the phrases have been completely irrelevant
for more than 25 years to anyone thinking about Lisp.
When was this written? Maybe 25 years ago? Maybe the number should be
updated.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-03 18:48 ` Roland Winkler
@ 2023-04-03 23:44 ` Emanuel Berg
2023-04-04 2:56 ` Richard Stallman
1 sibling, 0 replies; 13+ messages in thread
From: Emanuel Berg @ 2023-04-03 23:44 UTC (permalink / raw)
To: emacs-devel
Roland Winkler wrote:
>> As you know, but it's interesting to those who don't ...
>>
>> (info "(eintr) Strange Names")
>>
>> The name of the cons function is not unreasonable: it is
>> an abbreviation of the word "construct". The origins of
>> the names for car and cdr, on the other hand, are
>> esoteric: car is an acronym from the phrase "Contents of
>> the Address part of the Register"; and cdr (pronounced
>> "could-er") is an acronym from the phrase "Contents of
>> the Decrement part of the Register". These phrases refer
>> to specific pieces of hardware on the very early computer
>> on which the original Lisp was developed.
>>
>> Hm ... That was in 1958? What kind of machine was that?
>
> But (info "(eintr) Strange Names") goes on:
>
> Besides being obsolete, the phrases have been completely
> irrelevant for more than 25 years to anyone thinking
> about Lisp.
>
> When was this written? Maybe 25 years ago? Maybe the number
> should be updated.
But that way, in 25 years, it has to be updated again.
Damn!
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-03 18:48 ` Roland Winkler
2023-04-03 23:44 ` Emanuel Berg
@ 2023-04-04 2:56 ` Richard Stallman
2023-04-05 7:24 ` Emanuel Berg
1 sibling, 1 reply; 13+ messages in thread
From: Richard Stallman @ 2023-04-04 2:56 UTC (permalink / raw)
To: Roland Winkler; +Cc: emacs-devel
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> But (info "(eintr) Strange Names") goes on:
> Besides being obsolete, the phrases have been completely irrelevant
> for more than 25 years to anyone thinking about Lisp.
I think that statement is too strong. The origins of things may cease
to be crucial, but that doesn't make them "completely irrelevant" to
the present.
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Arguing for a nilp function and where to put it
2023-04-04 2:56 ` Richard Stallman
@ 2023-04-05 7:24 ` Emanuel Berg
0 siblings, 0 replies; 13+ messages in thread
From: Emanuel Berg @ 2023-04-05 7:24 UTC (permalink / raw)
To: emacs-devel
Richard Stallman wrote:
>> But (info "(eintr) Strange Names") goes on:
>>
>> Besides being obsolete, the phrases have been completely irrelevant
>> for more than 25 years to anyone thinking about Lisp.
>
> I think that statement is too strong. The origins of things
> may cease to be crucial, but that doesn't make them
> "completely irrelevant" to the present.
One would think not ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-04-05 7:24 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-01 5:37 Arguing for a nilp function and where to put it Pedro Andres Aranda Gutierrez
2023-04-01 6:01 ` tomas
2023-04-01 6:07 ` Michael Albinus
2023-04-01 6:10 ` Eli Zaretskii
2023-04-01 7:09 ` Pedro Andres Aranda Gutierrez
2023-04-02 21:28 ` Roland Winkler
2023-04-03 3:02 ` Richard Stallman
2023-04-03 3:34 ` Emanuel Berg
2023-04-03 12:46 ` Andreas Schwab
2023-04-03 18:48 ` Roland Winkler
2023-04-03 23:44 ` Emanuel Berg
2023-04-04 2:56 ` Richard Stallman
2023-04-05 7:24 ` Emanuel Berg
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).