aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-02-20 13:44:19 +0100
committerLars Ingebrigtsen2021-02-20 13:44:19 +0100
commit825aed11d267f7879ca8915eb2b0d154e0beb2d4 (patch)
tree7ac81a68c2a114a4a549220f3ba238b5111ff6b1
parent43703a06b9ea31b86c46bef7cb488ea885569ddc (diff)
downloademacs-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.texi4
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/emacs-lisp/byte-opt.el2
-rw-r--r--lisp/subr.el9
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.
863This function ignores any @var{arguments} and returns @code{nil}. 863This function ignores any @var{arguments} and returns @code{nil}.
864@end defun 864@end defun
865 865
866@defun always &rest arguments
867This 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
867interactively (usually by a key sequence). It is possible to invoke 871interactively (usually by a key sequence). It is possible to invoke
868such a command exactly as though it was called interactively, by using 872such a command exactly as though it was called interactively, by using
diff --git a/etc/NEWS b/etc/NEWS
index ee8a68a259d..c0c292aebc8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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'.
2310This 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
2311to say whether the command should be present when completing with 2315to 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.
376This function accepts any number of ARGUMENTS, but ignores them." 376This function accepts any number of ARGUMENTS, but ignores them.
377Also see `always'."
377 (interactive) 378 (interactive)
378 nil) 379 nil)
379 380
381(defun always (&rest _arguments)
382 "Do nothing and return t.
383This function accepts any number of ARGUMENTS, but ignores them.
384Also 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'.