;;; 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)
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")
(: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")
(: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")
(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."
(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))))))