Add the `always' function

* doc/lispref/functions.texi (Calling Functions): Document it.
* lisp/subr.el (always): New function.

* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Mark it as
side effect free.
This commit is contained in:
Lars Ingebrigtsen 2021-02-20 13:44:19 +01:00
parent 43703a06b9
commit 825aed11d2
4 changed files with 17 additions and 2 deletions

View file

@ -861,6 +861,10 @@ This function returns @var{argument} and has no side effects.
@defun ignore &rest arguments
This function ignores any @var{arguments} and returns @code{nil}.
@end defun
@defun always &rest arguments
This function ignores any @var{arguments} and returns @code{t}.
@end defun
Some functions are user-visible @dfn{commands}, which can be called

View file

@ -2305,6 +2305,10 @@ back in Emacs 23.1. The affected functions are: 'make-obsolete',
* Lisp Changes in Emacs 28.1
+++
** New function 'always'.
This is identical to 'ignore', but returns t instead.
+++
** New forms to declare how completion should happen has been added.
'(declare (completion PREDICATE))' can be used as a general predicate

View file

@ -1348,7 +1348,7 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.")
window-total-height window-total-width window-use-time window-vscroll
window-width zerop))
(side-effect-and-error-free-fns
'(arrayp atom
'(always arrayp atom
bignump bobp bolp bool-vector-p
buffer-end buffer-list buffer-size buffer-string bufferp
car-safe case-table-p cdr-safe char-or-string-p characterp

View file

@ -373,10 +373,17 @@ PREFIX is a string, and defaults to \"g\"."
(defun ignore (&rest _arguments)
"Do nothing and return nil.
This function accepts any number of ARGUMENTS, but ignores them."
This function accepts any number of ARGUMENTS, but ignores them.
Also see `always'."
(interactive)
nil)
(defun always (&rest _arguments)
"Do nothing and return t.
This function accepts any number of ARGUMENTS, but ignores them.
Also see `ignore'."
t)
;; Signal a compile-error if the first arg is missing.
(defun error (&rest args)
"Signal an error, making a message by passing ARGS to `format-message'.