aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2022-08-09 18:15:56 +0200
committerStefan Kangas2022-08-09 18:15:56 +0200
commit3ef18c7a213f4f3c03eec033fcb8219fb17cd53d (patch)
tree889cecf146a27847abc3c71ea23985083d19365f
parentb0653b27e25bfad2416364c33e1a5994285435c4 (diff)
downloademacs-3ef18c7a213f4f3c03eec033fcb8219fb17cd53d.tar.gz
emacs-3ef18c7a213f4f3c03eec033fcb8219fb17cd53d.zip
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.
-rw-r--r--lisp/ibuf-ext.el31
-rw-r--r--lisp/ibuf-macs.el2
-rw-r--r--lisp/ibuffer.el16
3 files changed, 24 insertions, 25 deletions
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el
index a56c1a87212..44c1ae867d4 100644
--- a/lisp/ibuf-ext.el
+++ b/lisp/ibuf-ext.el
@@ -865,7 +865,7 @@ specification, with the same structure as an element of the list
865 "Move point to the filter group whose name is NAME." 865 "Move point to the filter group whose name is NAME."
866 (interactive 866 (interactive
867 (list (ibuffer-read-filter-group-name "Jump to filter group: "))) 867 (list (ibuffer-read-filter-group-name "Jump to filter group: ")))
868 (ibuffer-aif (assoc name (ibuffer-current-filter-groups-with-position)) 868 (if-let ((it (assoc name (ibuffer-current-filter-groups-with-position))))
869 (goto-char (cdr it)) 869 (goto-char (cdr it))
870 (error "No filter group with name %s" name))) 870 (error "No filter group with name %s" name)))
871 871
@@ -876,7 +876,7 @@ The group will be added to `ibuffer-filter-group-kill-ring'."
876 (interactive (list (ibuffer-read-filter-group-name "Kill filter group: " t))) 876 (interactive (list (ibuffer-read-filter-group-name "Kill filter group: " t)))
877 (when (equal name "Default") 877 (when (equal name "Default")
878 (error "Can't kill default filter group")) 878 (error "Can't kill default filter group"))
879 (ibuffer-aif (assoc name ibuffer-filter-groups) 879 (if-let ((it (assoc name ibuffer-filter-groups)))
880 (progn 880 (progn
881 (push (copy-tree it) ibuffer-filter-group-kill-ring) 881 (push (copy-tree it) ibuffer-filter-group-kill-ring)
882 (setq ibuffer-filter-groups (ibuffer-remove-alist 882 (setq ibuffer-filter-groups (ibuffer-remove-alist
@@ -891,13 +891,12 @@ The group will be added to `ibuffer-filter-group-kill-ring'."
891 "Kill the filter group at point. 891 "Kill the filter group at point.
892See also `ibuffer-kill-filter-group'." 892See also `ibuffer-kill-filter-group'."
893 (interactive "P\np") 893 (interactive "P\np")
894 (ibuffer-aif (save-excursion 894 (if-let ((it (save-excursion
895 (ibuffer-forward-line 0) 895 (ibuffer-forward-line 0)
896 (get-text-property (point) 'ibuffer-filter-group-name)) 896 (get-text-property (point) 'ibuffer-filter-group-name))))
897 (progn 897 (ibuffer-kill-filter-group it)
898 (ibuffer-kill-filter-group it)) 898 (funcall (if interactive-p #'call-interactively #'funcall)
899 (funcall (if interactive-p #'call-interactively #'funcall) 899 #'kill-line arg)))
900 #'kill-line arg)))
901 900
902(defun ibuffer-insert-filter-group-before (newgroup group) 901(defun ibuffer-insert-filter-group-before (newgroup group)
903 (let* ((found nil) 902 (let* ((found nil)
@@ -953,7 +952,7 @@ prompt for NAME, and use the current filters."
953 (list 952 (list
954 (read-from-minibuffer "Save current filter groups as: ") 953 (read-from-minibuffer "Save current filter groups as: ")
955 ibuffer-filter-groups))) 954 ibuffer-filter-groups)))
956 (ibuffer-aif (assoc name ibuffer-saved-filter-groups) 955 (if-let ((it (assoc name ibuffer-saved-filter-groups)))
957 (setcdr it groups) 956 (setcdr it groups)
958 (push (cons name groups) ibuffer-saved-filter-groups)) 957 (push (cons name groups) ibuffer-saved-filter-groups))
959 (ibuffer-maybe-save-stuff)) 958 (ibuffer-maybe-save-stuff))
@@ -1125,7 +1124,7 @@ Interactively, prompt for NAME, and use the current filters."
1125 (list 1124 (list
1126 (read-from-minibuffer "Save current filters as: ") 1125 (read-from-minibuffer "Save current filters as: ")
1127 ibuffer-filtering-qualifiers))) 1126 ibuffer-filtering-qualifiers)))
1128 (ibuffer-aif (assoc name ibuffer-saved-filters) 1127 (if-let ((it (assoc name ibuffer-saved-filters)))
1129 (setcdr it filters) 1128 (setcdr it filters)
1130 (push (cons name filters) ibuffer-saved-filters)) 1129 (push (cons name filters) ibuffer-saved-filters))
1131 (ibuffer-maybe-save-stuff)) 1130 (ibuffer-maybe-save-stuff))
@@ -1337,11 +1336,11 @@ pattern. For example, for a buffer associated with file
1337For a buffer associated with file '/a/b/c.d', this matches 1336For a buffer associated with file '/a/b/c.d', this matches
1338against '/a/b'. For a buffer not associated with a file, this 1337against '/a/b'. For a buffer not associated with a file, this
1339matches against the value of `default-directory' in that buffer." 1338matches against the value of `default-directory' in that buffer."
1340 (:description "directory name" 1339 ( :description "directory name"
1341 :reader (read-from-minibuffer "Filter by directory name (regex): ")) 1340 :reader (read-from-minibuffer "Filter by directory name (regex): "))
1342 (ibuffer-aif (with-current-buffer buf (ibuffer-buffer-file-name)) 1341 (if-let ((it (with-current-buffer buf (ibuffer-buffer-file-name))))
1343 (let ((dirname (file-name-directory it))) 1342 (when-let ((dirname (file-name-directory it)))
1344 (when dirname (string-match qualifier dirname))) 1343 (string-match qualifier dirname))
1345 (when default-directory (string-match qualifier default-directory)))) 1344 (when default-directory (string-match qualifier default-directory))))
1346 1345
1347;;;###autoload (autoload 'ibuffer-filter-by-size-gt "ibuf-ext") 1346;;;###autoload (autoload 'ibuffer-filter-by-size-gt "ibuf-ext")
diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el
index 718b779a921..acffb74ead3 100644
--- a/lisp/ibuf-macs.el
+++ b/lisp/ibuf-macs.el
@@ -35,7 +35,7 @@
35If TEST returns non-nil, bind `it' to the value, and evaluate 35If TEST returns non-nil, bind `it' to the value, and evaluate
36TRUE-BODY. Otherwise, evaluate forms in FALSE-BODY as if in `progn'. 36TRUE-BODY. Otherwise, evaluate forms in FALSE-BODY as if in `progn'.
37Compare with `if'." 37Compare with `if'."
38 (declare (indent 2)) 38 (declare (obsolete if-let "29.1") (indent 2))
39 (let ((sym (make-symbol "ibuffer-aif-sym"))) 39 (let ((sym (make-symbol "ibuffer-aif-sym")))
40 `(let ((,sym ,test)) 40 `(let ((,sym ,test))
41 (if ,sym 41 (if ,sym
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index d6870aab5dd..5cb4fe2a7a3 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -832,7 +832,7 @@ width and the longest string in LIST."
832 (let ((pt (save-excursion 832 (let ((pt (save-excursion
833 (mouse-set-point event) 833 (mouse-set-point event)
834 (point)))) 834 (point))))
835 (ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name) 835 (if-let ((it (get-text-property (point) 'ibuffer-filter-group-name)))
836 (ibuffer-toggle-marks it) 836 (ibuffer-toggle-marks it)
837 (goto-char pt) 837 (goto-char pt)
838 (let ((mark (ibuffer-current-mark))) 838 (let ((mark (ibuffer-current-mark)))
@@ -1263,8 +1263,8 @@ become unmarked.
1263If point is on a group name, then this function operates on that 1263If point is on a group name, then this function operates on that
1264group." 1264group."
1265 (interactive) 1265 (interactive)
1266 (ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name) 1266 (when-let ((it (get-text-property (point) 'ibuffer-filter-group-name)))
1267 (setq group it)) 1267 (setq group it))
1268 (let ((count 1268 (let ((count
1269 (ibuffer-map-lines 1269 (ibuffer-map-lines
1270 (lambda (_buf mark) 1270 (lambda (_buf mark)
@@ -1336,7 +1336,7 @@ If point is on a group name, this function operates on that group."
1336 (when (and movement (< movement 0)) 1336 (when (and movement (< movement 0))
1337 (setq arg (- arg))) 1337 (setq arg (- arg)))
1338 (ibuffer-forward-line 0) 1338 (ibuffer-forward-line 0)
1339 (ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name) 1339 (if-let ((it (get-text-property (point) 'ibuffer-filter-group-name)))
1340 (progn 1340 (progn
1341 (require 'ibuf-ext) 1341 (require 'ibuf-ext)
1342 (ibuffer-mark-on-buffer #'identity mark it)) 1342 (ibuffer-mark-on-buffer #'identity mark it))
@@ -1540,7 +1540,7 @@ If point is on a group name, this function operates on that group."
1540 ;; `ibuffer-inline-columns' alist and insert it 1540 ;; `ibuffer-inline-columns' alist and insert it
1541 ;; into our generated code. Otherwise, we just 1541 ;; into our generated code. Otherwise, we just
1542 ;; generate a call to the column function. 1542 ;; generate a call to the column function.
1543 (ibuffer-aif (assq sym ibuffer-inline-columns) 1543 (if-let ((it (assq sym ibuffer-inline-columns)))
1544 (nth 1 it) 1544 (nth 1 it)
1545 `(or (,sym buffer mark) ""))) 1545 `(or (,sym buffer mark) "")))
1546 ;; You're not expected to understand this. Hell, I 1546 ;; 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."
1737 (cond ((zerop total) "No processes") 1737 (cond ((zerop total) "No processes")
1738 ((= 1 total) "1 process") 1738 ((= 1 total) "1 process")
1739 (t (format "%d processes" total)))))) 1739 (t (format "%d processes" total))))))
1740 (ibuffer-aif (get-buffer-process buffer) 1740 (if-let ((it (get-buffer-process buffer)))
1741 (format "(%s %s)" it (process-status it)) 1741 (format "(%s %s)" it (process-status it))
1742 "")) 1742 ""))
1743 1743
@@ -1872,8 +1872,8 @@ the buffer object itself and the current mark symbol."
1872 (let ((result 1872 (let ((result
1873 (if (buffer-live-p (ibuffer-current-buffer)) 1873 (if (buffer-live-p (ibuffer-current-buffer))
1874 (when (or (null group) 1874 (when (or (null group)
1875 (ibuffer-aif (get-text-property (point) 'ibuffer-filter-group) 1875 (when-let ((it (get-text-property (point) 'ibuffer-filter-group)))
1876 (equal group it))) 1876 (equal group it)))
1877 (save-excursion 1877 (save-excursion
1878 (funcall function 1878 (funcall function
1879 (ibuffer-current-buffer) 1879 (ibuffer-current-buffer)