Fix buffer menu unmark (bug#80082)

Now when calling 'Buffer-menu-unmark-all-buffers', only the
selected mark is removed.

* lisp/buff-menu.el (Buffer-menu--unmark): Add a mark parameter
to correctly select it in the entry.
(Buffer-menu-unmark, Buffer-menu-unmark-all-buffers)
(Buffer-menu-backup-unmark): Usage.
This commit is contained in:
Manuel Giraud 2026-01-08 08:45:04 +01:00 committed by Juri Linkov
parent e4f49d2710
commit 66ff6064f5

View file

@ -465,7 +465,7 @@ When `outline-minor-mode' is enabled and point is on the outline
heading line, this command will unmark all entries in the outline." heading line, this command will unmark all entries in the outline."
(interactive "P" Buffer-menu-mode) (interactive "P" Buffer-menu-mode)
(cond ((tabulated-list-get-id) (cond ((tabulated-list-get-id)
(Buffer-menu--unmark) (Buffer-menu--unmark ?\r)
(forward-line (if backup -1 1))) (forward-line (if backup -1 1)))
((and (bound-and-true-p outline-minor-mode) (outline-on-heading-p)) ((and (bound-and-true-p outline-minor-mode) (outline-on-heading-p))
(let ((old-pos (point)) (let ((old-pos (point))
@ -488,11 +488,7 @@ When called interactively prompt for MARK; RET remove all marks."
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(while (not (eobp)) (while (not (eobp))
(when-let* ((entry (tabulated-list-get-entry))) (Buffer-menu--unmark mark)
(let ((xmarks (list (aref entry 0) (aref entry 2))))
(when (or (char-equal mark ?\r)
(member (char-to-string mark) xmarks))
(Buffer-menu--unmark))))
(forward-line)))) (forward-line))))
(defun Buffer-menu-unmark-all () (defun Buffer-menu-unmark-all ()
@ -506,15 +502,22 @@ When called interactively prompt for MARK; RET remove all marks."
(forward-line -1) (forward-line -1)
(while (and (not (tabulated-list-get-id)) (not (bobp))) (while (and (not (tabulated-list-get-id)) (not (bobp)))
(forward-line -1)) (forward-line -1))
(if (tabulated-list-get-id) (Buffer-menu--unmark))) (if (tabulated-list-get-id) (Buffer-menu--unmark ?\r)))
(defun Buffer-menu--unmark () (defun Buffer-menu--unmark (mark)
(tabulated-list-set-col 0 " " t) "Remove MARK in current entry.
(let ((buf (Buffer-menu-buffer))) If MARK is \\`RET' remove all marks."
(when buf (when-let* ((entry (tabulated-list-get-entry)))
(if (buffer-modified-p buf) ;; A mark could appear in column 0 or 2.
(tabulated-list-set-col 2 "*" t) (dolist (col '(0 2))
(tabulated-list-set-col 2 " " t))))) (when (or (char-equal mark ?\r)
(char-equal mark (string-to-char (aref entry col))))
(tabulated-list-set-col col " " t)))
;; Reset modified mark in column 2.
(let ((buf (Buffer-menu-buffer)))
(when (and buf (buffer-modified-p buf)
(string-equal (aref entry 2) " "))
(tabulated-list-set-col 2 "*" t)))))
(defun Buffer-menu-delete (&optional arg) (defun Buffer-menu-delete (&optional arg)
"Mark the buffer on this Buffer Menu buffer line for deletion. "Mark the buffer on this Buffer Menu buffer line for deletion.