diff options
| author | Juri Linkov | 2024-06-07 09:45:05 +0300 |
|---|---|---|
| committer | Juri Linkov | 2024-06-07 09:45:05 +0300 |
| commit | b18bdbb2c1ea004a3ad8f7c1716fcbc6a61ef927 (patch) | |
| tree | 0fb34f137f5061dca26b20ad9fd8969bccd594af | |
| parent | 7d36bb0547fd2f1e0315edbe579bed68796d5c39 (diff) | |
| download | emacs-b18bdbb2c1ea004a3ad8f7c1716fcbc6a61ef927.tar.gz emacs-b18bdbb2c1ea004a3ad8f7c1716fcbc6a61ef927.zip | |
* lisp/buff-menu.el: Mark all entries in outline.
(Buffer-menu-mark, Buffer-menu-unmark, Buffer-menu-delete)
(Buffer-menu-save): Mark all entries in the outline
when `outline-minor-mode' is enabled and point is
on the outline heading line (bug#70150).
(Buffer-menu-backup-unmark): Support outline heading lines.
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | lisp/buff-menu.el | 107 |
2 files changed, 85 insertions, 25 deletions
| @@ -1877,7 +1877,8 @@ chat buffers use by default. | |||
| 1877 | --- | 1877 | --- |
| 1878 | *** New user option 'Buffer-menu-group-by'. | 1878 | *** New user option 'Buffer-menu-group-by'. |
| 1879 | It controls how buffers are divided into groups that are displayed with | 1879 | It controls how buffers are divided into groups that are displayed with |
| 1880 | headings using Outline minor mode. | 1880 | headings using Outline minor mode. Using commands that mark buffers |
| 1881 | on the outline heading line will mark all buffers in the outline. | ||
| 1881 | 1882 | ||
| 1882 | +++ | 1883 | +++ |
| 1883 | *** New command 'Buffer-menu-toggle-internal'. | 1884 | *** New command 'Buffer-menu-toggle-internal'. |
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el index d83bf2249e6..c35fa42934c 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el | |||
| @@ -411,19 +411,50 @@ is nil or omitted, and signal an error otherwise." | |||
| 411 | 411 | ||
| 412 | ;;; Commands for modifying Buffer Menu entries. | 412 | ;;; Commands for modifying Buffer Menu entries. |
| 413 | 413 | ||
| 414 | (defvar outline-minor-mode) | ||
| 415 | (declare-function outline-on-heading-p "outline" (&optional invisible-ok)) | ||
| 416 | (declare-function outline-end-of-subtree "outline" ()) | ||
| 417 | (declare-function outline-previous-heading "outline" ()) | ||
| 418 | |||
| 414 | (defun Buffer-menu-mark () | 419 | (defun Buffer-menu-mark () |
| 415 | "Mark the Buffer menu entry at point for later display. | 420 | "Mark the Buffer menu entry at point for later display. |
| 416 | It will be displayed by the \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command." | 421 | It will be displayed by the \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command. |
| 422 | When `outline-minor-mode' is enabled and point is on the outline | ||
| 423 | heading line, this command will mark all entries in the outline." | ||
| 417 | (interactive nil Buffer-menu-mode) | 424 | (interactive nil Buffer-menu-mode) |
| 418 | (tabulated-list-set-col 0 (char-to-string Buffer-menu-marker-char) t) | 425 | (cond ((tabulated-list-get-id) |
| 419 | (forward-line)) | 426 | (tabulated-list-set-col 0 (char-to-string Buffer-menu-marker-char) t) |
| 427 | (forward-line)) | ||
| 428 | ((and (bound-and-true-p outline-minor-mode) (outline-on-heading-p)) | ||
| 429 | (let ((limit (save-excursion (outline-end-of-subtree) (point))) | ||
| 430 | ;; Skip outline subheadings on recursive calls | ||
| 431 | (outline-minor-mode nil)) | ||
| 432 | (forward-line) | ||
| 433 | (while (< (point) limit) | ||
| 434 | (Buffer-menu-mark)))) | ||
| 435 | (t (forward-line)))) | ||
| 420 | 436 | ||
| 421 | (defun Buffer-menu-unmark (&optional backup) | 437 | (defun Buffer-menu-unmark (&optional backup) |
| 422 | "Cancel all requested operations on buffer on this line and move down. | 438 | "Cancel all requested operations on buffer on this line and move down. |
| 423 | Optional prefix arg means move up." | 439 | Optional prefix arg means move up. |
| 440 | When `outline-minor-mode' is enabled and point is on the outline | ||
| 441 | heading line, this command will unmark all entries in the outline." | ||
| 424 | (interactive "P" Buffer-menu-mode) | 442 | (interactive "P" Buffer-menu-mode) |
| 425 | (Buffer-menu--unmark) | 443 | (cond ((tabulated-list-get-id) |
| 426 | (forward-line (if backup -1 1))) | 444 | (Buffer-menu--unmark) |
| 445 | (forward-line (if backup -1 1))) | ||
| 446 | ((and (bound-and-true-p outline-minor-mode) (outline-on-heading-p)) | ||
| 447 | (let ((old-pos (point)) | ||
| 448 | (limit (save-excursion (outline-end-of-subtree) (point))) | ||
| 449 | ;; Skip outline subheadings on recursive calls | ||
| 450 | (outline-minor-mode nil)) | ||
| 451 | (forward-line) | ||
| 452 | (while (< (point) limit) | ||
| 453 | (Buffer-menu-unmark)) | ||
| 454 | (when backup | ||
| 455 | (goto-char old-pos) | ||
| 456 | (outline-previous-heading)))) | ||
| 457 | (t (forward-line (if backup -1 1))))) | ||
| 427 | 458 | ||
| 428 | (defun Buffer-menu-unmark-all-buffers (mark) | 459 | (defun Buffer-menu-unmark-all-buffers (mark) |
| 429 | "Cancel a requested operation on all buffers. | 460 | "Cancel a requested operation on all buffers. |
| @@ -449,7 +480,10 @@ When called interactively prompt for MARK; RET remove all marks." | |||
| 449 | "Move up and cancel all requested operations on buffer on line above." | 480 | "Move up and cancel all requested operations on buffer on line above." |
| 450 | (interactive nil Buffer-menu-mode) | 481 | (interactive nil Buffer-menu-mode) |
| 451 | (forward-line -1) | 482 | (forward-line -1) |
| 452 | (Buffer-menu--unmark)) | 483 | (while (and (not (tabulated-list-get-id)) (not (bobp))) |
| 484 | (forward-line -1)) | ||
| 485 | (unless (bobp) | ||
| 486 | (Buffer-menu--unmark))) | ||
| 453 | 487 | ||
| 454 | (defun Buffer-menu--unmark () | 488 | (defun Buffer-menu--unmark () |
| 455 | (tabulated-list-set-col 0 " " t) | 489 | (tabulated-list-set-col 0 " " t) |
| @@ -465,20 +499,34 @@ A subsequent \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] command \ | |||
| 465 | will delete it. | 499 | will delete it. |
| 466 | 500 | ||
| 467 | If prefix argument ARG is non-nil, it specifies the number of | 501 | If prefix argument ARG is non-nil, it specifies the number of |
| 468 | buffers to delete; a negative ARG means to delete backwards." | 502 | buffers to delete; a negative ARG means to delete backwards. |
| 503 | |||
| 504 | When `outline-minor-mode' is enabled and point is on the outline | ||
| 505 | heading line, this command will mark all entries in the outline. | ||
| 506 | However, ARG is not supported in this case." | ||
| 469 | (interactive "p" Buffer-menu-mode) | 507 | (interactive "p" Buffer-menu-mode) |
| 470 | (if (or (null arg) (= arg 0)) | 508 | (cond |
| 471 | (setq arg 1)) | 509 | ((and (bound-and-true-p outline-minor-mode) (outline-on-heading-p)) |
| 472 | (while (> arg 0) | 510 | (let ((limit (save-excursion (outline-end-of-subtree) (point))) |
| 473 | (when (Buffer-menu-buffer) | 511 | ;; Skip outline subheadings on recursive calls |
| 474 | (tabulated-list-set-col 0 (char-to-string Buffer-menu-del-char) t)) | 512 | (outline-minor-mode nil)) |
| 475 | (forward-line 1) | 513 | (forward-line) |
| 476 | (setq arg (1- arg))) | 514 | (while (< (point) limit) |
| 477 | (while (< arg 0) | 515 | (Buffer-menu-delete)))) |
| 478 | (when (Buffer-menu-buffer) | 516 | (t |
| 479 | (tabulated-list-set-col 0 (char-to-string Buffer-menu-del-char) t)) | 517 | (if (or (null arg) (= arg 0)) |
| 480 | (forward-line -1) | 518 | (setq arg 1)) |
| 481 | (setq arg (1+ arg)))) | 519 | (while (> arg 0) |
| 520 | (when (Buffer-menu-buffer) | ||
| 521 | (tabulated-list-set-col 0 (char-to-string Buffer-menu-del-char) t)) | ||
| 522 | (forward-line 1) | ||
| 523 | (setq arg (1- arg))) | ||
| 524 | |||
| 525 | (while (< arg 0) | ||
| 526 | (when (Buffer-menu-buffer) | ||
| 527 | (tabulated-list-set-col 0 (char-to-string Buffer-menu-del-char) t)) | ||
| 528 | (forward-line -1) | ||
| 529 | (setq arg (1+ arg)))))) | ||
| 482 | 530 | ||
| 483 | (defun Buffer-menu-delete-backwards (&optional arg) | 531 | (defun Buffer-menu-delete-backwards (&optional arg) |
| 484 | "Mark the buffer on this Buffer Menu line for deletion, and move up. | 532 | "Mark the buffer on this Buffer Menu line for deletion, and move up. |
| @@ -491,11 +539,22 @@ will delete the marked buffer. Prefix ARG | |||
| 491 | (defun Buffer-menu-save () | 539 | (defun Buffer-menu-save () |
| 492 | "Mark the buffer on this Buffer Menu line for saving. | 540 | "Mark the buffer on this Buffer Menu line for saving. |
| 493 | A subsequent \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] \ | 541 | A subsequent \\<Buffer-menu-mode-map>\\[Buffer-menu-execute] \ |
| 494 | command will save it." | 542 | command will save it. |
| 543 | When `outline-minor-mode' is enabled and point is on the outline | ||
| 544 | heading line, this command will mark all entries in the outline." | ||
| 495 | (interactive nil Buffer-menu-mode) | 545 | (interactive nil Buffer-menu-mode) |
| 496 | (when (Buffer-menu-buffer) | 546 | (cond ((tabulated-list-get-id) |
| 497 | (tabulated-list-set-col 2 "S" t) | 547 | (when (Buffer-menu-buffer) |
| 498 | (forward-line 1))) | 548 | (tabulated-list-set-col 2 "S" t)) |
| 549 | (forward-line)) | ||
| 550 | ((and (bound-and-true-p outline-minor-mode) (outline-on-heading-p)) | ||
| 551 | (let ((limit (save-excursion (outline-end-of-subtree) (point))) | ||
| 552 | ;; Skip outline subheadings on recursive calls | ||
| 553 | (outline-minor-mode nil)) | ||
| 554 | (forward-line) | ||
| 555 | (while (< (point) limit) | ||
| 556 | (Buffer-menu-save)))) | ||
| 557 | (t (forward-line)))) | ||
| 499 | 558 | ||
| 500 | (defun Buffer-menu-not-modified (&optional arg) | 559 | (defun Buffer-menu-not-modified (&optional arg) |
| 501 | "Mark the buffer on this line as unmodified (no changes to save). | 560 | "Mark the buffer on this line as unmodified (no changes to save). |