* The function naming convention used by Emacs.
@ 2021-09-26 11:05 Hongyi Zhao
2021-09-26 11:27 ` 2QdxY4RzWzUUiLuE
2021-09-26 11:48 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 2 replies; 11+ messages in thread
From: Hongyi Zhao @ 2021-09-26 11:05 UTC (permalink / raw)
To: help-gnu-emacs
As far as function names are concerned, are there some established
conventions used by Emacs? For example, I noticed that there are so
many functions in Emacs named by the suffix `-p', say,
`file-exists-p', `ht-equal-p', and so on. But I still can't figure out
the meaning of this suffix. Any tips will be appreciated.
Best, HZ
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: The function naming convention used by Emacs.
2021-09-26 11:05 Hongyi Zhao
@ 2021-09-26 11:27 ` 2QdxY4RzWzUUiLuE
2021-09-26 11:49 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-26 11:50 ` Hongyi Zhao
2021-09-26 11:48 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 2 replies; 11+ messages in thread
From: 2QdxY4RzWzUUiLuE @ 2021-09-26 11:27 UTC (permalink / raw)
To: help-gnu-emacs
On 2021-09-26 at 19:05:36 +0800,
Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
> As far as function names are concerned, are there some established
> conventions used by Emacs? For example, I noticed that there are so
> many functions in Emacs named by the suffix `-p', say,
> `file-exists-p', `ht-equal-p', and so on. But I still can't figure out
> the meaning of this suffix. Any tips will be appreciated.
The -p suffix is short for "predicate"; so file-exists-p is true if and
only if the argument names and existing file. I learned of that
convention from Common Lisp; I don't know the entire history.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: The function naming convention used by Emacs.
2021-09-26 11:05 Hongyi Zhao
2021-09-26 11:27 ` 2QdxY4RzWzUUiLuE
@ 2021-09-26 11:48 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-26 12:18 ` Hongyi Zhao
1 sibling, 1 reply; 11+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-09-26 11:48 UTC (permalink / raw)
To: help-gnu-emacs
Hongyi Zhao wrote:
> As far as function names are concerned, are there some
> established conventions used by Emacs? For example,
> I noticed that there are so many functions in Emacs named by
> the suffix `-p', say, `file-exists-p', `ht-equal-p', and so
> on. But I still can't figure out the meaning of this suffix.
> Any tips will be appreciated.
It stands for "predicate", such a function returns t or nil.
there is also the "f" suffix for "function", e.g. `cl-incf'
and `cl-decf' ... and a couple of other conventions I can't
remember right now.
Speaking of CL, the convention for *global-variables* is not
encouraged in Elisp.
Other than that do this
(require 'checkdoc)
(setq checkdoc-permit-comma-termination-flag t)
(defun check-package-style ()
(interactive)
(let ((msg "Style check..."))
(message msg)
(checkdoc-current-buffer t) ; TAKE-NOTES
(message "%sdone" msg) ))
(defalias 'check-style #'check-package-style)
and do byte-compile for more pointers ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: The function naming convention used by Emacs.
2021-09-26 11:27 ` 2QdxY4RzWzUUiLuE
@ 2021-09-26 11:49 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-26 11:50 ` Hongyi Zhao
1 sibling, 0 replies; 11+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-09-26 11:49 UTC (permalink / raw)
To: help-gnu-emacs
2QdxY4RzWzUUiLuE wrote:
>> As far as function names are concerned, are there some
>> established conventions used by Emacs? For example,
>> I noticed that there are so many functions in Emacs named
>> by the suffix `-p', say, `file-exists-p', `ht-equal-p', and
>> so on. But I still can't figure out the meaning of this
>> suffix. Any tips will be appreciated.
>
> The -p suffix is short for "predicate"; so file-exists-p is
> true if and only if the argument names and existing file.
> I learned of that convention from Common Lisp; I don't know
> the entire history.
Me neither :)
But it is from Predicate Logic which is an extension of
Propositional Logic ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: The function naming convention used by Emacs.
2021-09-26 11:27 ` 2QdxY4RzWzUUiLuE
2021-09-26 11:49 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-09-26 11:50 ` Hongyi Zhao
1 sibling, 0 replies; 11+ messages in thread
From: Hongyi Zhao @ 2021-09-26 11:50 UTC (permalink / raw)
To: help-gnu-emacs
On Sun, Sep 26, 2021 at 7:27 PM <2QdxY4RzWzUUiLuE@potatochowder.com> wrote:
[...]
> The -p suffix is short for "predicate"; so file-exists-p is true if and
> only if the argument names and existing file. I learned of that
> convention from Common Lisp; I don't know the entire history.
Thank you for sharing your knowledge with me.
HZ
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: The function naming convention used by Emacs.
2021-09-26 11:48 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-09-26 12:18 ` Hongyi Zhao
2021-09-26 13:34 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 11+ messages in thread
From: Hongyi Zhao @ 2021-09-26 12:18 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs
On Sun, Sep 26, 2021 at 7:49 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > As far as function names are concerned, are there some
> > established conventions used by Emacs? For example,
> > I noticed that there are so many functions in Emacs named by
> > the suffix `-p', say, `file-exists-p', `ht-equal-p', and so
> > on. But I still can't figure out the meaning of this suffix.
> > Any tips will be appreciated.
>
> It stands for "predicate", such a function returns t or nil.
>
> there is also the "f" suffix for "function", e.g. `cl-incf'
> and `cl-decf' ... and a couple of other conventions I can't
> remember right now.
>
> Speaking of CL, the convention for *global-variables* is not
> encouraged in Elisp.
>
> Other than that do this
>
> (require 'checkdoc)
>
> (setq checkdoc-permit-comma-termination-flag t)
>
> (defun check-package-style ()
> (interactive)
> (let ((msg "Style check..."))
> (message msg)
> (checkdoc-current-buffer t) ; TAKE-NOTES
> (message "%sdone" msg) ))
> (defalias 'check-style #'check-package-style)
Do you mean and suggest adding the above code snippets into the init file?
> and do byte-compile for more pointers ...
I now use the `--with-native-compilation' option to configure Emacs
for compilation. So, the thing you mentioned above should have been
done automatically by Emacs.
HZ
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: The function naming convention used by Emacs.
@ 2021-09-26 13:32 Pierpaolo Bernardi
2021-09-26 13:35 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-26 17:26 ` [External] : " Drew Adams
0 siblings, 2 replies; 11+ messages in thread
From: Pierpaolo Bernardi @ 2021-09-26 13:32 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs@gnu org
Il giorno 26 settembre 2021, alle ore 13:49, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> ha scritto:
>there is also the "f" suffix for "function", e.g. `cl-incf'
>and `cl-decf' ...
The "f" in these cases stands for "field".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: The function naming convention used by Emacs.
2021-09-26 12:18 ` Hongyi Zhao
@ 2021-09-26 13:34 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 11+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-09-26 13:34 UTC (permalink / raw)
To: help-gnu-emacs
Hongyi Zhao wrote:
>> Other than that do this
>>
>> (require 'checkdoc)
>>
>> (setq checkdoc-permit-comma-termination-flag t)
>>
>> (defun check-package-style ()
>> (interactive)
>> (let ((msg "Style check..."))
>> (message msg)
>> (checkdoc-current-buffer t) ; TAKE-NOTES
>> (message "%sdone" msg) ))
>> (defalias 'check-style #'check-package-style)
>
> Do you mean and suggest adding the above code snippets into
> the init file?
Yes, if you will. And use it on your code.
>> and do byte-compile for more pointers ...
>
> I now use the `--with-native-compilation' option to
> configure Emacs for compilation. So, the thing you mentioned
> above should have been done automatically by Emacs.
Byte-compile your code after you've written it. Do it again
when you change it. Byte-compiling makes it faster to load and
run, that's the reason to do it. But as a positive
side-effect, the byte-compiler will also output errors and
warnings - so it is a tool to improve you code as well.
Do a Makefile and shell alias to it to run it, so you can
byte-compile fast in terms of the mere interface, but also so
that files you didn't change and have already byte-compiled
will not be byte-compiled again.
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: The function naming convention used by Emacs.
2021-09-26 13:32 The function naming convention used by Emacs Pierpaolo Bernardi
@ 2021-09-26 13:35 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-26 17:26 ` [External] : " Drew Adams
1 sibling, 0 replies; 11+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-09-26 13:35 UTC (permalink / raw)
To: help-gnu-emacs
Pierpaolo Bernardi wrote:
>> there is also the "f" suffix for "function", e.g. `cl-incf'
>> and `cl-decf' ...
>
> The "f" in these cases stands for "field".
That so, OK, thanks.
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [External] : Re: The function naming convention used by Emacs.
2021-09-26 13:32 The function naming convention used by Emacs Pierpaolo Bernardi
2021-09-26 13:35 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-09-26 17:26 ` Drew Adams
2021-09-27 1:54 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 11+ messages in thread
From: Drew Adams @ 2021-09-26 17:26 UTC (permalink / raw)
To: Pierpaolo Bernardi, Emanuel Berg, help-gnu-emacs@gnu org
> >there is also the "f" suffix for "function", e.g. `cl-incf'
> >and `cl-decf' ...
>
> The "f" in these cases stands for "field".
A suffix of `f' can stand for different things.
I think generally it stands loosely for "function".
The general idea is that some sort of function is
used to determine a generalized "place" that gets
updated in some way.
The most obvious and general case is `setf' whose
doc says that the first arg is a "function call
form" or it otherwise generally refers to a function.
And functions that are related to, or based on,
`setf' tend to use the `f' suffix.
Common Lisp uses lots of such "functions" (including
macros etc.) that are named with suffix `f'.
https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node80.html
There are also obvious exceptions where the `f'
isn't really a suffix. E.g. `...aref', `...if',
`...of', `ldiff', `result-of', `svref'.
And less obvious exceptions, which are related
to `setf': `getf', `remf', `incf', `decf',
`rotatef', `shiftf'.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [External] : Re: The function naming convention used by Emacs.
2021-09-26 17:26 ` [External] : " Drew Adams
@ 2021-09-27 1:54 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 11+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-09-27 1:54 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams wrote:
> Common Lisp uses lots of such "functions" (including macros
> etc.) that are named with suffix `f'.
Let's pretend I got it from there ...
Because in Elisp there seems to be the spelled-out "-function"
convention that seems to be the one to use ...
Often it is variables that indicate one is to set it to
a function, e.g.
(setq browse-url-browser-function #'w3m-browse-url)
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-09-27 1:54 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-26 13:32 The function naming convention used by Emacs Pierpaolo Bernardi
2021-09-26 13:35 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-26 17:26 ` [External] : " Drew Adams
2021-09-27 1:54 ` Emanuel Berg via Users list for the GNU Emacs text editor
-- strict thread matches above, loose matches on Subject: below --
2021-09-26 11:05 Hongyi Zhao
2021-09-26 11:27 ` 2QdxY4RzWzUUiLuE
2021-09-26 11:49 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-26 11:50 ` Hongyi Zhao
2021-09-26 11:48 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-26 12:18 ` Hongyi Zhao
2021-09-26 13:34 ` Emanuel Berg via Users list for the GNU Emacs text editor
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).