From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: foudfou Newsgroups: gmane.emacs.devel Subject: [PATCH] * lisp/ibuffer.el: Add ability to (un-)mark or delete buffers in the region. Date: Sat, 12 Dec 2015 22:45:09 +0100 Message-ID: <566C9565.2000300@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010604090302050401000202" X-Trace: ger.gmane.org 1449977337 19117 80.91.229.3 (13 Dec 2015 03:28:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Dec 2015 03:28:57 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 13 04:28:56 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a7xLC-0002bE-BL for ged-emacs-devel@m.gmane.org; Sun, 13 Dec 2015 04:28:54 +0100 Original-Received: from localhost ([::1]:53806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7xLB-0001iy-JN for ged-emacs-devel@m.gmane.org; Sat, 12 Dec 2015 22:28:53 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7sXp-0000nV-Oq for emacs-devel@gnu.org; Sat, 12 Dec 2015 17:21:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a7sXm-0005Hv-Hj for emacs-devel@gnu.org; Sat, 12 Dec 2015 17:21:37 -0500 Original-Received: from ip-131.net-81-220-246.rev.numericable.fr ([81.220.246.131]:36403 helo=mail.foudil.fr) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7sXm-0005HS-6J for emacs-devel@gnu.org; Sat, 12 Dec 2015 17:21:34 -0500 Original-Received: from [192.168.0.13] (ip-131.net-81-220-246.rev.numericable.fr [81.220.246.131]) by mail.foudil.fr (Postfix) with ESMTPSA id 0F8D64ECD for ; Sat, 12 Dec 2015 22:45:10 +0100 (CET) X-Enigmail-Draft-Status: N1010 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 81.220.246.131 X-Mailman-Approved-At: Sat, 12 Dec 2015 22:28:41 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:196195 Archived-At: This is a multi-part message in MIME format. --------------010604090302050401000202 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 v= isually 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, a= nd just adds the ability to select with the region. For the sake of simpl= icity, I didn't modify current menu labels, the mode's help, nor renamed = the impacted functions. Cheers --------------010604090302050401000202 Content-Type: text/x-patch; name="0001-lisp-ibuffer.el-Add-ability-to-un-mark-or-delete-buf.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-lisp-ibuffer.el-Add-ability-to-un-mark-or-delete-buf.pa"; filename*1="tch" =46rom 2f2766f23eec7fedf8b6848bb8a513585562fd3c Mon Sep 17 00:00:00 2001 From: foudfou Date: Sat, 12 Dec 2015 22:06:03 +0100 Subject: [PATCH] * lisp/ibuffer.el: Add ability to (un-)mark or delete bu= ffers 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)) =20 -(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)= ) =20 -(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)) =20 (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))) =20 (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)))) =20 -(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-cha= r)) =20 (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)) =20 (defun ibuffer-current-buffer (&optional must-be-live) --=20 2.6.3 --------------010604090302050401000202--