[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 825aed1: Add the `always' function
From: |
Lars Ingebrigtsen |
Subject: |
master 825aed1: Add the `always' function |
Date: |
Sat, 20 Feb 2021 07:48:25 -0500 (EST) |
branch: master
commit 825aed11d267f7879ca8915eb2b0d154e0beb2d4
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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 1e3da8e..2a9b57f 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.
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
interactively (usually by a key sequence). It is possible to invoke
such a command exactly as though it was called interactively, by using
diff --git a/etc/NEWS b/etc/NEWS
index ee8a68a..c0c292a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2306,6 +2306,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
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 e0feb95..9f0ba23 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 490aec9..f9bb1bb 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'.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 825aed1: Add the `always' function,
Lars Ingebrigtsen <=