diff options
| author | Lars Ingebrigtsen | 2021-02-20 13:44:19 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-02-20 13:44:19 +0100 |
| commit | 825aed11d267f7879ca8915eb2b0d154e0beb2d4 (patch) | |
| tree | 7ac81a68c2a114a4a549220f3ba238b5111ff6b1 | |
| parent | 43703a06b9ea31b86c46bef7cb488ea885569ddc (diff) | |
| download | emacs-825aed11d267f7879ca8915eb2b0d154e0beb2d4.tar.gz emacs-825aed11d267f7879ca8915eb2b0d154e0beb2d4.zip | |
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.
| -rw-r--r-- | doc/lispref/functions.texi | 4 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 2 | ||||
| -rw-r--r-- | lisp/subr.el | 9 |
4 files changed, 17 insertions, 2 deletions
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 1e3da8e3a5d..2a9b57f19f3 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi | |||
| @@ -863,6 +863,10 @@ This function returns @var{argument} and has no side effects. | |||
| 863 | This function ignores any @var{arguments} and returns @code{nil}. | 863 | This function ignores any @var{arguments} and returns @code{nil}. |
| 864 | @end defun | 864 | @end defun |
| 865 | 865 | ||
| 866 | @defun always &rest arguments | ||
| 867 | This function ignores any @var{arguments} and returns @code{t}. | ||
| 868 | @end defun | ||
| 869 | |||
| 866 | Some functions are user-visible @dfn{commands}, which can be called | 870 | Some functions are user-visible @dfn{commands}, which can be called |
| 867 | interactively (usually by a key sequence). It is possible to invoke | 871 | interactively (usually by a key sequence). It is possible to invoke |
| 868 | such a command exactly as though it was called interactively, by using | 872 | such a command exactly as though it was called interactively, by using |
| @@ -2306,6 +2306,10 @@ back in Emacs 23.1. The affected functions are: 'make-obsolete', | |||
| 2306 | * Lisp Changes in Emacs 28.1 | 2306 | * Lisp Changes in Emacs 28.1 |
| 2307 | 2307 | ||
| 2308 | +++ | 2308 | +++ |
| 2309 | ** New function 'always'. | ||
| 2310 | This is identical to 'ignore', but returns t instead. | ||
| 2311 | |||
| 2312 | +++ | ||
| 2309 | ** New forms to declare how completion should happen has been added. | 2313 | ** New forms to declare how completion should happen has been added. |
| 2310 | '(declare (completion PREDICATE))' can be used as a general predicate | 2314 | '(declare (completion PREDICATE))' can be used as a general predicate |
| 2311 | to say whether the command should be present when completing with | 2315 | to say whether the command should be present when completing with |
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index e0feb95a461..9f0ba232a4b 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el | |||
| @@ -1348,7 +1348,7 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.") | |||
| 1348 | window-total-height window-total-width window-use-time window-vscroll | 1348 | window-total-height window-total-width window-use-time window-vscroll |
| 1349 | window-width zerop)) | 1349 | window-width zerop)) |
| 1350 | (side-effect-and-error-free-fns | 1350 | (side-effect-and-error-free-fns |
| 1351 | '(arrayp atom | 1351 | '(always arrayp atom |
| 1352 | bignump bobp bolp bool-vector-p | 1352 | bignump bobp bolp bool-vector-p |
| 1353 | buffer-end buffer-list buffer-size buffer-string bufferp | 1353 | buffer-end buffer-list buffer-size buffer-string bufferp |
| 1354 | car-safe case-table-p cdr-safe char-or-string-p characterp | 1354 | car-safe case-table-p cdr-safe char-or-string-p characterp |
diff --git a/lisp/subr.el b/lisp/subr.el index 490aec93f19..f9bb1bb3ad1 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -373,10 +373,17 @@ PREFIX is a string, and defaults to \"g\"." | |||
| 373 | 373 | ||
| 374 | (defun ignore (&rest _arguments) | 374 | (defun ignore (&rest _arguments) |
| 375 | "Do nothing and return nil. | 375 | "Do nothing and return nil. |
| 376 | This function accepts any number of ARGUMENTS, but ignores them." | 376 | This function accepts any number of ARGUMENTS, but ignores them. |
| 377 | Also see `always'." | ||
| 377 | (interactive) | 378 | (interactive) |
| 378 | nil) | 379 | nil) |
| 379 | 380 | ||
| 381 | (defun always (&rest _arguments) | ||
| 382 | "Do nothing and return t. | ||
| 383 | This function accepts any number of ARGUMENTS, but ignores them. | ||
| 384 | Also see `ignore'." | ||
| 385 | t) | ||
| 386 | |||
| 380 | ;; Signal a compile-error if the first arg is missing. | 387 | ;; Signal a compile-error if the first arg is missing. |
| 381 | (defun error (&rest args) | 388 | (defun error (&rest args) |
| 382 | "Signal an error, making a message by passing ARGS to `format-message'. | 389 | "Signal an error, making a message by passing ARGS to `format-message'. |