unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#68949: [PATCH] Optionally show internal buffers in Buffer Menu mode
@ 2024-02-06 12:24 Mattias Engdegård
  2024-02-06 12:43 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Mattias Engdegård @ 2024-02-06 12:24 UTC (permalink / raw)
  To: 68949

[-- Attachment #1: Type: text/plain, Size: 133 bytes --]

`list-buffers` (C-x C-b) never shows internal buffers but it would sometimes be very useful if it did.
This patch adds a toggle.


[-- Attachment #2: buff-menu-show-internal.diff --]
[-- Type: application/octet-stream, Size: 3671 bytes --]

diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 5796544c534..512ee608edb 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -100,6 +100,10 @@ Buffer-menu-files-only
 This is set by the prefix argument to `buffer-menu' and related
 commands.")
 
+(defvar-local Buffer-menu-show-internal nil
+  "Non-nil if the current Buffer Menu lists internal buffers.
+Internal buffers are those whose name start with a space.")
+
 (defvar-local Buffer-menu-filter-predicate nil
   "Function to filter out buffers in the buffer list.
 Buffers that don't satisfy the predicate will be skipped.
@@ -140,6 +144,7 @@ Buffer-menu-mode-map
   "V"           #'Buffer-menu-view
   "O"           #'Buffer-menu-view-other-window
   "T"           #'Buffer-menu-toggle-files-only
+  "I"           #'Buffer-menu-toggle-internal
   "M-s a C-s"   #'Buffer-menu-isearch-buffers
   "M-s a C-M-s" #'Buffer-menu-isearch-buffers-regexp
   "M-s a C-o"   #'Buffer-menu-multi-occur
@@ -197,6 +202,10 @@ Buffer-menu-mode-menu
      :help "Toggle whether the current buffer-menu displays only file buffers"
      :style toggle
      :selected Buffer-menu-files-only]
+    ["Show Internal Buffers" Buffer-menu-toggle-internal
+     :help "Toggle whether the current buffer-menu displays internal buffers"
+     :style toggle
+     :selected Buffer-menu-show-internal]
     "---"
     ["Refresh" revert-buffer
      :help "Refresh the *Buffer List* buffer contents"]
@@ -317,6 +326,11 @@ list-buffers
   (interactive "P")
   (display-buffer (list-buffers-noselect arg)))
 
+(defun Buffer-menu--selection-message ()
+  (message (cond (Buffer-menu-files-only "Showing only file-visiting buffers.")
+                 (Buffer-menu-show-internal "Showing all buffers.")
+	         (t "Showing all non-internal buffers."))))
+
 (defun Buffer-menu-toggle-files-only (arg)
   "Toggle whether the current `buffer-menu' displays only file buffers.
 With a positive ARG, display only file buffers.  With zero or
@@ -325,9 +339,18 @@ Buffer-menu-toggle-files-only
   (setq Buffer-menu-files-only
 	(cond ((not arg) (not Buffer-menu-files-only))
 	      ((> (prefix-numeric-value arg) 0) t)))
-  (message (if Buffer-menu-files-only
-	       "Showing only file-visiting buffers."
-	     "Showing all non-internal buffers."))
+  (Buffer-menu--selection-message)
+  (revert-buffer))
+
+(defun Buffer-menu-toggle-internal (arg)
+  "Toggle whether the current `buffer-menu' displays internal buffers.
+With a positive ARG, display non-internal buffers only.  With zero or
+negative ARG, display internal buffers as well."
+  (interactive "P" Buffer-menu-mode)
+  (setq Buffer-menu-show-internal
+	(cond ((not arg) (not Buffer-menu-show-internal))
+	      ((> (prefix-numeric-value arg) 0) t)))
+  (Buffer-menu--selection-message)
   (revert-buffer))
 
 (define-obsolete-function-alias 'Buffer-menu-sort 'tabulated-list-sort
@@ -667,6 +690,7 @@ list-buffers--refresh
         (marked-buffers (Buffer-menu-marked-buffers))
         (buffer-menu-buffer (current-buffer))
 	(show-non-file (not Buffer-menu-files-only))
+        (show-internal Buffer-menu-show-internal)
 	(filter-predicate (and (functionp Buffer-menu-filter-predicate)
 			       Buffer-menu-filter-predicate))
 	entries name-width)
@@ -686,7 +710,8 @@ list-buffers--refresh
 	       (file buffer-file-name))
 	  (when (and (buffer-live-p buffer)
 		     (or buffer-list
-			 (and (or (not (string= (substring name 0 1) " "))
+			 (and (or show-internal
+                                  (not (string= (substring name 0 1) " "))
                                   file)
 			      (not (eq buffer buffer-menu-buffer))
 			      (or file show-non-file)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#68949: [PATCH] Optionally show internal buffers in Buffer Menu mode
  2024-02-06 12:24 bug#68949: [PATCH] Optionally show internal buffers in Buffer Menu mode Mattias Engdegård
@ 2024-02-06 12:43 ` Eli Zaretskii
  2024-02-06 12:54   ` Mattias Engdegård
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-02-06 12:43 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: 68949

> From: Mattias Engdegård <mattias.engdegard@gmail.com>
> Date: Tue, 6 Feb 2024 13:24:30 +0100
> 
> `list-buffers` (C-x C-b) never shows internal buffers but it would sometimes be very useful if it did.
> This patch adds a toggle.

Thanks.

Would a special value of prefix argument be better, perhaps?  Like in
"C-u 0 C-x C-b"?  Or maybe in addition to the toggle you suggest?

In any case, this should be in NEWS and perhaps also in the user
manual.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#68949: [PATCH] Optionally show internal buffers in Buffer Menu mode
  2024-02-06 12:43 ` Eli Zaretskii
@ 2024-02-06 12:54   ` Mattias Engdegård
  2024-02-06 15:33     ` Mattias Engdegård
  0 siblings, 1 reply; 9+ messages in thread
From: Mattias Engdegård @ 2024-02-06 12:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 68949

6 feb. 2024 kl. 13.43 skrev Eli Zaretskii <eliz@gnu.org>:

> Would a special value of prefix argument be better, perhaps?  Like in
> "C-u 0 C-x C-b"?  Or maybe in addition to the toggle you suggest?

It wouldn't help usability for myself because I find it a lot more natural to toggle after displaying than remembering a particular prefix, but if someone prefers the prefix then I'm happy to let them add it.

> In any case, this should be in NEWS and perhaps also in the user
> manual.

I've written a NEWS entry, but I'm not sure it belongs in the user manual since it's mainly of interest to Elisp programmers. It's well-visible in the menu, however.

Thanks for looking at it! I'm pushing it to master now; we can amend it as necessary.






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#68949: [PATCH] Optionally show internal buffers in Buffer Menu mode
  2024-02-06 12:54   ` Mattias Engdegård
@ 2024-02-06 15:33     ` Mattias Engdegård
  2024-02-06 17:55       ` Juri Linkov
  2024-02-06 19:55       ` Eli Zaretskii
  0 siblings, 2 replies; 9+ messages in thread
From: Mattias Engdegård @ 2024-02-06 15:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 68949-done

Pushed and closed.






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#68949: [PATCH] Optionally show internal buffers in Buffer Menu mode
  2024-02-06 15:33     ` Mattias Engdegård
@ 2024-02-06 17:55       ` Juri Linkov
  2024-02-06 19:58         ` Eli Zaretskii
  2024-02-06 19:55       ` Eli Zaretskii
  1 sibling, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2024-02-06 17:55 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Dmitry Gutov, 68949

> Pushed and closed.

Thanks, now also added support for internal buffers
to project-list-buffers as well.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#68949: [PATCH] Optionally show internal buffers in Buffer Menu mode
  2024-02-06 15:33     ` Mattias Engdegård
  2024-02-06 17:55       ` Juri Linkov
@ 2024-02-06 19:55       ` Eli Zaretskii
  1 sibling, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2024-02-06 19:55 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: 68949

> From: Mattias Engdegård <mattias.engdegard@gmail.com>
> Date: Tue, 6 Feb 2024 16:33:53 +0100
> Cc: 68949-done@debbugs.gnu.org
> 
> Pushed and closed.

Thanks, but please always remember to mention the bug number in the
log message.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#68949: [PATCH] Optionally show internal buffers in Buffer Menu mode
  2024-02-06 17:55       ` Juri Linkov
@ 2024-02-06 19:58         ` Eli Zaretskii
  2024-02-07  7:50           ` Juri Linkov
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-02-06 19:58 UTC (permalink / raw)
  To: Juri Linkov; +Cc: dmitry, mattias.engdegard, 68949

> Cc: Dmitry Gutov <dmitry@gutov.dev>, 68949@debbugs.gnu.org
> From: Juri Linkov <juri@linkov.net>
> Date: Tue, 06 Feb 2024 19:55:44 +0200
> 
> > Pushed and closed.
> 
> Thanks, now also added support for internal buffers
> to project-list-buffers as well.

Is it really a good idea to make a variable specific to Buffer menu
mode affect a completely unrelated command?

In any case, if this stays in the code, the corresponding doc strings
should mention this fact.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#68949: [PATCH] Optionally show internal buffers in Buffer Menu mode
  2024-02-06 19:58         ` Eli Zaretskii
@ 2024-02-07  7:50           ` Juri Linkov
  2024-02-07 13:03             ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2024-02-07  7:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: dmitry, mattias.engdegard, 68949

> Is it really a good idea to make a variable specific to Buffer menu
> mode affect a completely unrelated command?

Sorry, I don't understand where is a completely unrelated command?





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#68949: [PATCH] Optionally show internal buffers in Buffer Menu mode
  2024-02-07  7:50           ` Juri Linkov
@ 2024-02-07 13:03             ` Eli Zaretskii
  0 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2024-02-07 13:03 UTC (permalink / raw)
  To: Juri Linkov; +Cc: dmitry, mattias.engdegard, 68949

> From: Juri Linkov <juri@linkov.net>
> Cc: mattias.engdegard@gmail.com,  dmitry@gutov.dev,  68949@debbugs.gnu.org
> Date: Wed, 07 Feb 2024 09:50:10 +0200
> 
> > Is it really a good idea to make a variable specific to Buffer menu
> > mode affect a completely unrelated command?
> 
> Sorry, I don't understand where is a completely unrelated command?

The variable is called Buffer-menu-show-internal, which hints that it
is applicable to Buffer Menu mode, whereas your change makes
project-list-buffers, a command unrelated to Buffer Menu, obey that
variable.





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-02-07 13:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-06 12:24 bug#68949: [PATCH] Optionally show internal buffers in Buffer Menu mode Mattias Engdegård
2024-02-06 12:43 ` Eli Zaretskii
2024-02-06 12:54   ` Mattias Engdegård
2024-02-06 15:33     ` Mattias Engdegård
2024-02-06 17:55       ` Juri Linkov
2024-02-06 19:58         ` Eli Zaretskii
2024-02-07  7:50           ` Juri Linkov
2024-02-07 13:03             ` Eli Zaretskii
2024-02-06 19:55       ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).