gv.el: Allow use of ignore as a place (bug#81217)

* lisp/emacs-lisp/gv.el (error): Delete redundant `gv-expander` definition.
(ignore): Add a setter.
* doc/lispref/functions.texi (Calling Functions): Document `ignore`
as a place.
* lisp/xdg.el (xdg-mime-collect-associations): Silence compiler warning.
This commit is contained in:
Stefan Monnier 2026-06-19 16:06:16 -04:00
parent 4797eef57a
commit c7b156dce3
4 changed files with 14 additions and 14 deletions

View file

@ -1131,6 +1131,8 @@ This function returns @var{argument} and has no side effects.
@defun ignore &rest arguments
This function ignores any @var{arguments} and returns @code{nil}.
When used as a place (@pxref{Generalized Variables}), the assignment has
simply no effect.
@end defun
@defun always &rest arguments

View file

@ -171,6 +171,10 @@ To install the grammars, use 'M-x markdown-ts-mode-install-parsers'.
* Lisp Changes in Emacs 32.1
+++
** 'ignore' is now also a place, acting as a "blackhole" like /dev/null.
E.g. (push (new-elem) (pcase (foo) (0 var1) (1 var2) (_ (ignore))))
+++
** 'kill-all-local-variables' can kill locals silently and reset the buffer.
This function's KILL-PERMANENT argument now accepts the value

View file

@ -576,11 +576,6 @@ See also `incf'."
(funcall do `(funcall (car ,gv))
(lambda (v) `(funcall (cdr ,gv) ,v)))))))
(put 'error 'gv-expander
(lambda (do &rest args)
(funcall do `(error . ,args)
(lambda (v) `(progn ,v (error . ,args))))))
(defun gv-synthetic-place (getter setter)
"Special place described by its setter and getter.
GETTER and SETTER (typically obtained via `gv-letplace') get and
@ -683,11 +678,9 @@ REF must have been previously obtained with `gv-ref'."
;;; Generalized variables.
;; You'd think no one would write `(setf (error ...) ..)' but it
;; appears naturally as the result of macroexpansion of things like
;; (setf (pcase-exhaustive ...)).
;; We could generalize this to `throw' and `signal', but it seems
;; preferable to wait until there's a concrete need.
;; `error' and `ignore' places come in handy in the default branch
;; of `cond/pcase' places.
(gv-define-setter ignore (store &rest _args) store) ;; A kind of >/dev/null
(gv-define-expander error (lambda (_do &rest args) `(error . ,args)))
;; Some Emacs-related place types.

View file

@ -346,10 +346,11 @@ which is expected to be ordered by priority as in
(forward-line)
(dolist (str (xdg-desktop-strings (match-string 1)))
(cl-pushnew str
(cond ((eq sec ?D) defaults)
((eq sec ?A) added)
((eq sec ?R) removed)
((eq sec ?M) cached))
(pcase-exhaustive sec
(?D defaults)
(?A added)
(?R removed)
(?M cached))
:test #'equal))
(while (and (zerop (forward-line))
(/= (following-char) ?\[)))))))