1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-10 08:52:40 -07:00

Make ibuffer-aif obsolete in favor of if-let

* lisp/ibuf-macs.el (ibuffer-aif): Make obsolete in favor of 'if-let'.
* lisp/ibuffer.el (ibuffer-mouse-toggle-mark)
(ibuffer-mark-interactive, ibuffer-compile-format, process):
Prefer 'if-let' to above obsolete macro.
(ibuffer-toggle-marks, ibuffer-map-lines): Prefer 'when-let'
to above obsolete macro.
This commit is contained in:
Stefan Kangas 2022-08-09 18:15:56 +02:00
parent b0653b27e2
commit 3ef18c7a21
3 changed files with 24 additions and 25 deletions

View file

@ -865,7 +865,7 @@ specification, with the same structure as an element of the list
"Move point to the filter group whose name is NAME."
(interactive
(list (ibuffer-read-filter-group-name "Jump to filter group: ")))
(ibuffer-aif (assoc name (ibuffer-current-filter-groups-with-position))
(if-let ((it (assoc name (ibuffer-current-filter-groups-with-position))))
(goto-char (cdr it))
(error "No filter group with name %s" name)))
@ -876,7 +876,7 @@ The group will be added to `ibuffer-filter-group-kill-ring'."
(interactive (list (ibuffer-read-filter-group-name "Kill filter group: " t)))
(when (equal name "Default")
(error "Can't kill default filter group"))
(ibuffer-aif (assoc name ibuffer-filter-groups)
(if-let ((it (assoc name ibuffer-filter-groups)))
(progn
(push (copy-tree it) ibuffer-filter-group-kill-ring)
(setq ibuffer-filter-groups (ibuffer-remove-alist
@ -891,13 +891,12 @@ The group will be added to `ibuffer-filter-group-kill-ring'."
"Kill the filter group at point.
See also `ibuffer-kill-filter-group'."
(interactive "P\np")
(ibuffer-aif (save-excursion
(ibuffer-forward-line 0)
(get-text-property (point) 'ibuffer-filter-group-name))
(progn
(ibuffer-kill-filter-group it))
(funcall (if interactive-p #'call-interactively #'funcall)
#'kill-line arg)))
(if-let ((it (save-excursion
(ibuffer-forward-line 0)
(get-text-property (point) 'ibuffer-filter-group-name))))
(ibuffer-kill-filter-group it)
(funcall (if interactive-p #'call-interactively #'funcall)
#'kill-line arg)))
(defun ibuffer-insert-filter-group-before (newgroup group)
(let* ((found nil)
@ -953,7 +952,7 @@ prompt for NAME, and use the current filters."
(list
(read-from-minibuffer "Save current filter groups as: ")
ibuffer-filter-groups)))
(ibuffer-aif (assoc name ibuffer-saved-filter-groups)
(if-let ((it (assoc name ibuffer-saved-filter-groups)))
(setcdr it groups)
(push (cons name groups) ibuffer-saved-filter-groups))
(ibuffer-maybe-save-stuff))
@ -1125,7 +1124,7 @@ Interactively, prompt for NAME, and use the current filters."
(list
(read-from-minibuffer "Save current filters as: ")
ibuffer-filtering-qualifiers)))
(ibuffer-aif (assoc name ibuffer-saved-filters)
(if-let ((it (assoc name ibuffer-saved-filters)))
(setcdr it filters)
(push (cons name filters) ibuffer-saved-filters))
(ibuffer-maybe-save-stuff))
@ -1337,11 +1336,11 @@ pattern. For example, for a buffer associated with file
For a buffer associated with file '/a/b/c.d', this matches
against '/a/b'. For a buffer not associated with a file, this
matches against the value of `default-directory' in that buffer."
(:description "directory name"
:reader (read-from-minibuffer "Filter by directory name (regex): "))
(ibuffer-aif (with-current-buffer buf (ibuffer-buffer-file-name))
(let ((dirname (file-name-directory it)))
(when dirname (string-match qualifier dirname)))
( :description "directory name"
:reader (read-from-minibuffer "Filter by directory name (regex): "))
(if-let ((it (with-current-buffer buf (ibuffer-buffer-file-name))))
(when-let ((dirname (file-name-directory it)))
(string-match qualifier dirname))
(when default-directory (string-match qualifier default-directory))))
;;;###autoload (autoload 'ibuffer-filter-by-size-gt "ibuf-ext")

View file

@ -35,7 +35,7 @@
If TEST returns non-nil, bind `it' to the value, and evaluate
TRUE-BODY. Otherwise, evaluate forms in FALSE-BODY as if in `progn'.
Compare with `if'."
(declare (indent 2))
(declare (obsolete if-let "29.1") (indent 2))
(let ((sym (make-symbol "ibuffer-aif-sym")))
`(let ((,sym ,test))
(if ,sym

View file

@ -832,7 +832,7 @@ width and the longest string in LIST."
(let ((pt (save-excursion
(mouse-set-point event)
(point))))
(ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name)
(if-let ((it (get-text-property (point) 'ibuffer-filter-group-name)))
(ibuffer-toggle-marks it)
(goto-char pt)
(let ((mark (ibuffer-current-mark)))
@ -1263,8 +1263,8 @@ become unmarked.
If point is on a group name, then this function operates on that
group."
(interactive)
(ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name)
(setq group it))
(when-let ((it (get-text-property (point) 'ibuffer-filter-group-name)))
(setq group it))
(let ((count
(ibuffer-map-lines
(lambda (_buf mark)
@ -1336,7 +1336,7 @@ If point is on a group name, this function operates on that group."
(when (and movement (< movement 0))
(setq arg (- arg)))
(ibuffer-forward-line 0)
(ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name)
(if-let ((it (get-text-property (point) 'ibuffer-filter-group-name)))
(progn
(require 'ibuf-ext)
(ibuffer-mark-on-buffer #'identity mark it))
@ -1540,7 +1540,7 @@ If point is on a group name, this function operates on that group."
;; `ibuffer-inline-columns' alist and insert it
;; into our generated code. Otherwise, we just
;; generate a call to the column function.
(ibuffer-aif (assq sym ibuffer-inline-columns)
(if-let ((it (assq sym ibuffer-inline-columns)))
(nth 1 it)
`(or (,sym buffer mark) "")))
;; You're not expected to understand this. Hell, I
@ -1737,7 +1737,7 @@ If point is on a group name, this function operates on that group."
(cond ((zerop total) "No processes")
((= 1 total) "1 process")
(t (format "%d processes" total))))))
(ibuffer-aif (get-buffer-process buffer)
(if-let ((it (get-buffer-process buffer)))
(format "(%s %s)" it (process-status it))
""))
@ -1872,8 +1872,8 @@ the buffer object itself and the current mark symbol."
(let ((result
(if (buffer-live-p (ibuffer-current-buffer))
(when (or (null group)
(ibuffer-aif (get-text-property (point) 'ibuffer-filter-group)
(equal group it)))
(when-let ((it (get-text-property (point) 'ibuffer-filter-group)))
(equal group it)))
(save-excursion
(funcall function
(ibuffer-current-buffer)