From 825aed11d267f7879ca8915eb2b0d154e0beb2d4 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 20 Feb 2021 13:44:19 +0100 Subject: [PATCH] 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. --- doc/lispref/functions.texi | 4 ++++ etc/NEWS | 4 ++++ lisp/emacs-lisp/byte-opt.el | 2 +- 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 @@ -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 diff --git a/etc/NEWS b/etc/NEWS index ee8a68a259d..c0c292aebc8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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 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.") 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 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\"." (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'. -- 2.39.2