unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] * lisp/ibuffer.el: Add ability to (un-)mark or delete buffers in the region.
@ 2015-12-12 21:45 foudfou
  2015-12-14 17:33 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: foudfou @ 2015-12-12 21:45 UTC (permalink / raw)
  To: emacs-devel

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

Hi All,

I recently realized in ibuffer that the region could no be used to select buffers. This can be done only with prefix and at point. Being able to visually select and mark (lots of) buffers in different places in a (big) buffer list is helpful though.

This is what this patch is about. It doesn't change previous behaviors, and just adds the ability to select with the region. For the sake of simplicity, I didn't modify current menu labels, the mode's help, nor renamed the impacted functions.

Cheers

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ibuffer.el-Add-ability-to-un-mark-or-delete-buf.patch --]
[-- Type: text/x-patch; name="0001-lisp-ibuffer.el-Add-ability-to-un-mark-or-delete-buf.patch", Size: 3511 bytes --]

From 2f2766f23eec7fedf8b6848bb8a513585562fd3c Mon Sep 17 00:00:00 2001
From: foudfou <foudil.newbie+git@gmail.com>
Date: Sat, 12 Dec 2015 22:06:03 +0100
Subject: [PATCH] * lisp/ibuffer.el: Add ability to (un-)mark or delete buffers
 in the region.

---
 lisp/ibuffer.el | 45 +++++++++++++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index 89477bd..e8920e0 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -1354,23 +1354,36 @@ ibuffer-toggle-marks
     (message "%s buffers marked" count))
   (ibuffer-redisplay t))
 
-(defun ibuffer-mark-forward (arg)
-  "Mark the buffer on this line, and move forward ARG lines.
+(defsubst ibuffer-get-region-and-prefix ()
+  (let ((arg (prefix-numeric-value current-prefix-arg)))
+    (if (use-region-p) (list (region-beginning) (region-end) arg)
+      (list nil nil arg))))
+
+(defun ibuffer-mark-forward (start end arg)
+  "Mark the buffers in the region, or ARG buffers.
 If point is on a group name, this function operates on that group."
-  (interactive "p")
-  (ibuffer-mark-interactive arg ibuffer-marked-char))
+  (interactive (ibuffer-get-region-and-prefix))
+  (ibuffer-mark-region-or-n-with-char start end arg ibuffer-marked-char))
 
-(defun ibuffer-unmark-forward (arg)
-  "Unmark the buffer on this line, and move forward ARG lines.
+(defun ibuffer-unmark-forward (start end arg)
+  "Unmark the buffers in the region, or ARG buffers.
 If point is on a group name, this function operates on that group."
-  (interactive "p")
-  (ibuffer-mark-interactive arg ?\s))
+  (interactive (ibuffer-get-region-and-prefix))
+  (ibuffer-mark-region-or-n-with-char start end arg ?\s))
 
 (defun ibuffer-unmark-backward (arg)
-  "Unmark the buffer on this line, and move backward ARG lines.
+  "Unmark the ARG previous buffers.
 If point is on a group name, this function operates on that group."
   (interactive "p")
-  (ibuffer-unmark-forward (- arg)))
+  (ibuffer-unmark-forward nil nil (- arg)))
+
+(defun ibuffer-mark-region-or-n-with-char (start end arg mark-char)
+  (if (use-region-p)
+      (let ((cur (point)) (line-count (count-lines start end)))
+        (goto-char start)
+        (ibuffer-mark-interactive line-count mark-char)
+        (goto-char cur))
+      (ibuffer-mark-interactive arg mark-char)))
 
 (defun ibuffer-mark-interactive (arg mark &optional movement)
   (ibuffer-assert-ibuffer-mode)
@@ -1409,16 +1422,16 @@ ibuffer-set-mark-1
 		       (list (ibuffer-current-buffer)
 			     mark))))
 
-(defun ibuffer-mark-for-delete (arg)
-  "Mark the buffers on ARG lines forward for deletion.
+(defun ibuffer-mark-for-delete (start end arg)
+  "Mark for deletion the buffers in the region, or ARG buffers.
 If point is on a group name, this function operates on that group."
-  (interactive "P")
-  (ibuffer-mark-interactive arg ibuffer-deletion-char 1))
+  (interactive (ibuffer-get-region-and-prefix))
+  (ibuffer-mark-region-or-n-with-char start end arg ibuffer-deletion-char))
 
 (defun ibuffer-mark-for-delete-backwards (arg)
-  "Mark the buffers on ARG lines backward for deletion.
+  "Mark for deletion the ARG previous buffers.
 If point is on a group name, this function operates on that group."
-  (interactive "P")
+  (interactive "p")
   (ibuffer-mark-interactive arg ibuffer-deletion-char -1))
 
 (defun ibuffer-current-buffer (&optional must-be-live)
-- 
2.6.3


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

* Re: [PATCH] * lisp/ibuffer.el: Add ability to (un-)mark or delete buffers in the region.
  2015-12-12 21:45 [PATCH] * lisp/ibuffer.el: Add ability to (un-)mark or delete buffers in the region foudfou
@ 2015-12-14 17:33 ` Eli Zaretskii
  2015-12-14 18:29   ` John Wiegley
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2015-12-14 17:33 UTC (permalink / raw)
  To: foudfou; +Cc: emacs-devel

> From: foudfou <foudil.newbie@gmail.com>
> Date: Sat, 12 Dec 2015 22:45:09 +0100
> 
> I recently realized in ibuffer that the region could no be used to select buffers. This can be done only with prefix and at point. Being able to visually select and mark (lots of) buffers in different places in a (big) buffer list is helpful though.
> 
> This is what this patch is about. It doesn't change previous behaviors, and just adds the ability to select with the region. For the sake of simplicity, I didn't modify current menu labels, the mode's help, nor renamed the impacted functions.

Could someone who uses ibuffer.el please look into this patch and
provide comments?

TIA



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

* Re: [PATCH] * lisp/ibuffer.el: Add ability to (un-)mark or delete buffers in the region.
  2015-12-14 17:33 ` Eli Zaretskii
@ 2015-12-14 18:29   ` John Wiegley
  2015-12-14 19:10     ` Drew Adams
  0 siblings, 1 reply; 6+ messages in thread
From: John Wiegley @ 2015-12-14 18:29 UTC (permalink / raw)
  To: foudfou; +Cc: emacs-devel

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

>>>>> Eli Zaretskii <eliz@gnu.org> writes:

>> This is what this patch is about. It doesn't change previous behaviors, and
>> just adds the ability to select with the region. For the sake of simplicity,
>> I didn't modify current menu labels, the mode's help, nor renamed the
>> impacted functions.

> Could someone who uses ibuffer.el please look into this patch and provide
> comments?

Foudil, why does this patch rely on the use of the region to select a group of
buffers, rather than the existing functionality of using 'm' to mark buffer(s)
for subsequent action? This is a pattern used by many other modes, such as
dired.

In my brief testing, dired does not allow aggregate actions based on regions
either. Therefore, since ibuffer advertises itself as "a dired for buffers" --
and likewise, proced for processes -- the method for dealing with aggregate
targets should be kept consistent.

Thus, I'm inclined to reject this patch in favor of the existing "marking"
methodology.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 629 bytes --]

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

* RE: [PATCH] * lisp/ibuffer.el: Add ability to (un-)mark or delete buffers in the region.
  2015-12-14 18:29   ` John Wiegley
@ 2015-12-14 19:10     ` Drew Adams
  2015-12-14 19:52       ` [PATCH] * lisp/ibuffer.el: Add ability to (nu-)mark " John Wiegley
  0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2015-12-14 19:10 UTC (permalink / raw)
  To: John Wiegley, foudfou; +Cc: emacs-devel

> Foudil, why does this patch rely on the use of the region to select a group
> of buffers, rather than the existing functionality of using 'm' to mark
> buffer(s) for subsequent action? This is a pattern used by many other modes,
> such as dired.
> 
> In my brief testing, dired does not allow aggregate actions based on regions
> either. Therefore, since ibuffer advertises itself as "a dired for buffers"
> --
> and likewise, proced for processes -- the method for dealing with aggregate
> targets should be kept consistent.
> 
> Thus, I'm inclined to reject this patch in favor of the existing "marking"
> methodology.

FWIW: My library dired+.el does let you use the region to act on
(mark, unmark, toggle marks, flag for deletion) a selection of
files (and dirs).

http://www.emacswiki.org/emacs/DiredPlus#RegionMenu

If you also use my library mouse3.el then the region menu has many
more possibilities:

http://www.emacswiki.org/emacs/DiredPlus#RegionMenuWithMouse3Library



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

* Re: [PATCH] * lisp/ibuffer.el: Add ability to (nu-)mark or delete buffers in the region.
  2015-12-14 19:10     ` Drew Adams
@ 2015-12-14 19:52       ` John Wiegley
  2015-12-14 20:07         ` John Wiegley
  0 siblings, 1 reply; 6+ messages in thread
From: John Wiegley @ 2015-12-14 19:52 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel, foudfou

>>>>> Drew Adams <drew.adams@oracle.com> writes:

> FWIW: My library dired+.el does let you use the region to act on (mark,
> unmark, toggle marks, flag for deletion) a selection of files (and dirs).

Indeed, dired allows 'm' to mark a selected region, while ibuffer does not.
This should be remedied.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



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

* Re: [PATCH] * lisp/ibuffer.el: Add ability to (nu-)mark or delete buffers in the region.
  2015-12-14 19:52       ` [PATCH] * lisp/ibuffer.el: Add ability to (nu-)mark " John Wiegley
@ 2015-12-14 20:07         ` John Wiegley
  0 siblings, 0 replies; 6+ messages in thread
From: John Wiegley @ 2015-12-14 20:07 UTC (permalink / raw)
  To: foudfou; +Cc: emacs-devel

>>>>> John Wiegley <johnw@gnu.org> writes:

> Indeed, dired allows 'm' to mark a selected region, while ibuffer does not.
> This should be remedied.

Given Drew's remarks, foudfou, I have applied your patch. Thank you for your
contribution.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



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

end of thread, other threads:[~2015-12-14 20:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-12 21:45 [PATCH] * lisp/ibuffer.el: Add ability to (un-)mark or delete buffers in the region foudfou
2015-12-14 17:33 ` Eli Zaretskii
2015-12-14 18:29   ` John Wiegley
2015-12-14 19:10     ` Drew Adams
2015-12-14 19:52       ` [PATCH] * lisp/ibuffer.el: Add ability to (nu-)mark " John Wiegley
2015-12-14 20:07         ` John Wiegley

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).