From: Stefan Kangas Date: Tue, 9 Aug 2022 13:46:54 +0000 (+0200) Subject: Make ibuffer-awhen obsolete in favor of when-let X-Git-Tag: emacs-29.0.90~1447^2~282^2~1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=accb1d1132ad467304a909aa2e01993e0b5ff0f9;p=emacs.git Make ibuffer-awhen obsolete in favor of when-let * lisp/ibuf-macs.el (ibuffer-awhen): Make obsolete in favor of 'when-let'. Update callers. --- diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 3fa17e583d2..621e648a2dd 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -48,7 +48,7 @@ ;;; Utility functions (defun ibuffer-remove-alist (key alist) "Remove all entries in ALIST that have a key equal to KEY." - (while (ibuffer-awhen (assoc key alist) + (while (when-let ((it (assoc key alist))) (setq alist (remove it alist)) it)) alist) @@ -1313,7 +1313,7 @@ For example, for a buffer associated with file '/a/b/c.d', this matches against '/a/b/c.d'." (:description "full file name" :reader (read-from-minibuffer "Filter by full file name (regexp): ")) - (ibuffer-awhen (with-current-buffer buf (ibuffer-buffer-file-name)) + (when-let ((it (with-current-buffer buf (ibuffer-buffer-file-name)))) (string-match qualifier it))) ;;;###autoload (autoload 'ibuffer-filter-by-basename "ibuf-ext") @@ -1325,7 +1325,7 @@ matches against `c.d'." (:description "file basename" :reader (read-from-minibuffer "Filter by file name, without directory part (regex): ")) - (ibuffer-awhen (with-current-buffer buf (ibuffer-buffer-file-name)) + (when-let ((it (with-current-buffer buf (ibuffer-buffer-file-name)))) (string-match qualifier (file-name-nondirectory it)))) ;;;###autoload (autoload 'ibuffer-filter-by-file-extension "ibuf-ext") @@ -1338,7 +1338,7 @@ pattern. For example, for a buffer associated with file (:description "filename extension" :reader (read-from-minibuffer "Filter by filename extension without separator (regex): ")) - (ibuffer-awhen (with-current-buffer buf (ibuffer-buffer-file-name)) + (when-let ((it (with-current-buffer buf (ibuffer-buffer-file-name)))) (string-match qualifier (or (file-name-extension it) "")))) ;;;###autoload (autoload 'ibuffer-filter-by-directory "ibuf-ext") diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el index 51b206d7c48..718b779a921 100644 --- a/lisp/ibuf-macs.el +++ b/lisp/ibuf-macs.el @@ -47,10 +47,9 @@ Compare with `if'." (defmacro ibuffer-awhen (test &rest body) "Evaluate BODY if TEST returns non-nil. During evaluation of body, bind `it' to the value returned by TEST." - (declare (indent 1)) - `(ibuffer-aif ,test - (progn ,@body) - nil)) + (declare (indent 1) (obsolete when-let "29.1")) + `(when-let ((it ,test)) + ,@body)) (defmacro ibuffer-save-marks (&rest body) "Save the marked status of the buffers and execute BODY; restore marks." diff --git a/test/lisp/ibuffer-tests.el b/test/lisp/ibuffer-tests.el index 343e2ae50b1..d54718e297a 100644 --- a/test/lisp/ibuffer-tests.el +++ b/test/lisp/ibuffer-tests.el @@ -132,7 +132,7 @@ (ibuffer-switch-to-saved-filter-groups "saved-filters") (should (assoc "Elisp" (cdar ibuffer-saved-filter-groups)))) (setq ibuffer-saved-filter-groups orig-filters) - (ibuffer-awhen (get-buffer "*Ibuffer*") + (when-let ((it (get-buffer "*Ibuffer*"))) (and (buffer-live-p it) (kill-buffer it))))))