From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#24880: 26.0.50; buff-menu: Command to unmark all buffers Date: Wed, 16 Nov 2016 19:09:19 +0900 (JST) Message-ID: References: <871syqnsyo.fsf@gmail.com> <83a8dejkne.fsf@gnu.org> <87eg2ox0hi.fsf@gmail.com> <83h978hgrs.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Trace: blaine.gmane.org 1479291053 17508 195.159.176.226 (16 Nov 2016 10:10:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 16 Nov 2016 10:10:53 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: 24880@debbugs.gnu.org, Tino Calancha To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 16 11:10:48 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6xAZ-0008OV-Pm for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Nov 2016 11:10:20 +0100 Original-Received: from localhost ([::1]:51632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6xAZ-00070M-VZ for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Nov 2016 05:10:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6xAP-0006yV-FV for bug-gnu-emacs@gnu.org; Wed, 16 Nov 2016 05:10:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6xAI-0002Fe-PY for bug-gnu-emacs@gnu.org; Wed, 16 Nov 2016 05:10:09 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43435) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c6xAI-0002FZ-Lu for bug-gnu-emacs@gnu.org; Wed, 16 Nov 2016 05:10:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c6xAI-0007FT-Eh for bug-gnu-emacs@gnu.org; Wed, 16 Nov 2016 05:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Nov 2016 10:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24880 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24880-submit@debbugs.gnu.org id=B24880.147929097227821 (code B ref 24880); Wed, 16 Nov 2016 10:10:02 +0000 Original-Received: (at 24880) by debbugs.gnu.org; 16 Nov 2016 10:09:32 +0000 Original-Received: from localhost ([127.0.0.1]:58834 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6x9o-0007Ee-75 for submit@debbugs.gnu.org; Wed, 16 Nov 2016 05:09:32 -0500 Original-Received: from mail-pf0-f195.google.com ([209.85.192.195]:34171) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6x9m-0007ER-5y for 24880@debbugs.gnu.org; Wed, 16 Nov 2016 05:09:30 -0500 Original-Received: by mail-pf0-f195.google.com with SMTP id y68so9622016pfb.1 for <24880@debbugs.gnu.org>; Wed, 16 Nov 2016 02:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=lf6MAYdmX1uh370gKYoq0fBJaMNoRzuapI3Sx6zvR9w=; b=J6vDOfrnm0ThtteTB5QujAOhDOZC2sDr/gFnNO4uuU4fCKUrmWFJOoEg6SYJctu+4e YG/kCxhLDb7ce1+juUUY6yrUldpEfy+4yehj190vz4knvvQI4JSdFVwYP8smDREVHfD1 jsBJbcpNpbENGXoT2ewD3gw9mCXIrgrO+dtiYxfQzsjoG2lLteEylJmmtbiFj4F4yjQZ +WeWTdkRMrVdK5BFr0565yPssx2PJnj0zpHc7EPJTuHurtdqJieoJRmvMA4WF5YAmnkN WqUvmxwi+0uBQn+cHBIqVcPwIkBFGpyQfExDFrZT73GyGIFPyXRmEoyfV5PQRZnXOJUJ 5xFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=lf6MAYdmX1uh370gKYoq0fBJaMNoRzuapI3Sx6zvR9w=; b=OOdaLE39BQfP5ZuZWqAjRm9lj/F9HwW2s/lwvpB1Nq67/S6dwbdjpi4uS9AUW+Uix2 3D7D4UGcZqTN8cC9xeePiYBCeU8hUz3VMIgBqiuDwgj2u7kwrkPpOPDlAaa24UZ3YtQ+ EyP9u4s61GhAAPSKlJI5z4CCWGfIM0IYhV8UwdcqmRidtp0IQwJhXgjUFyMGSiTPfnJ0 oxGu0H0SXgcFa0WZwXV6kN1qAxeGX+KJv+0+Th8du0ADES5lqw4ckYjIQrYKQh3VCdtu gwqOvLUV5KTefIYK7Qwo16pRHdYMplGxEnPCXgkkDWiI0IhlBGGJxbXzvtWW8c/+qGlk ZA+A== X-Gm-Message-State: ABUngvfFFto9hJpzJBlleIcuElaXOFrgBjitQMmC9nqTcwAKVlF3xjnJ/penGY3lsQklWA== X-Received: by 10.98.89.6 with SMTP id n6mr3369140pfb.43.1479290964519; Wed, 16 Nov 2016 02:09:24 -0800 (PST) Original-Received: from calancha-pc (57.92.100.220.dy.bbexcite.jp. [220.100.92.57]) by smtp.gmail.com with ESMTPSA id m19sm19127951pfi.24.2016.11.16.02.09.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Nov 2016 02:09:23 -0800 (PST) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <83h978hgrs.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:125750 Archived-At: On Tue, 15 Nov 2016, Eli Zaretskii wrote: >> This is the amended patch: > > Thanks, please see a few comments below. Thank you. I have implemented your comments. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From bcc00e4f1da3f9c6bbb484c403fc7a107ccafb8d Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Wed, 16 Nov 2016 19:01:21 +0900 Subject: [PATCH] buff-menu: Add command to unmark all buffers Bind 'U' in buff-menu, bs and electric-buff-menu to commands to unmark all buffers (Bug#24880). * lisp/emacs-lisp/tabulated-list.el (tabulated-list-header-overlay-p): New predicate; return non-nil if tabulated-list has a fake header. * lisp/buff-menu.el (Buffer-menu-unmark-all-buffers): New command; remove all flags that use a particular mark from all the lines. Bind it to 'M-DEL'. (Buffer-menu-unmark-all): New command; remove all flags from all the lines. Bind it to 'U'. (Buffer-menu-marker-char, Buffer-menu-del-char): New variables. (Buffer-menu-delete, Buffer-menu-mark): Use them. (Buffer-menu-mode-map): Update menus. (Buffer-menu-mode): Update mode doc. * lisp/bs.el (bs-unmark-all, bs-unmark-previous): New commands. (bs-mode-map): Bind them to 'U' and '' respectively. (bs-mode): Update mode doc. * lisp/ebuff-menu.el (electric-buffer-menu-mode-map): Bind Buffer-menu-unmark-all to 'U' and Buffer-menu-unmark-all-buffers to 'M-DEL'. (electric-buffer-list): Update mode doc. * doc/emacs/buffers.texi (Several Buffers): Mention Buffer-menu-unmark-all and Buffer-menu-unmark-all-buffers. ; * etc/NEWS: Add an entry per each new feature. --- doc/emacs/buffers.texi | 12 +++++++++++ etc/NEWS | 18 ++++++++++++++++ lisp/bs.el | 31 +++++++++++++++++++++++++++ lisp/buff-menu.el | 44 ++++++++++++++++++++++++++++++++++++--- lisp/ebuff-menu.el | 3 +++ lisp/emacs-lisp/tabulated-list.el | 6 ++++++ 6 files changed, 111 insertions(+), 3 deletions(-) diff --git a/doc/emacs/buffers.texi b/doc/emacs/buffers.texi index 2eb837f..c70e583 100644 --- a/doc/emacs/buffers.texi +++ b/doc/emacs/buffers.texi @@ -411,6 +411,18 @@ Several Buffers @kindex DEL @r{(Buffer Menu)} Move to the previous line and remove all flags on that line (@code{Buffer-menu-backup-unmark}). + +@item M-@key{DEL} +@findex Buffer-menu-unmark-all-buffers +@kindex M-DEL @r{(Buffer Menu)} +Remove a particular flag from all lines +(@code{Buffer-menu-unmark-all-buffers}). + +@item U +@findex Buffer-menu-unmark-all +@kindex U @r{(Buffer Menu)} +Remove all flags from all the lines +(@code{Buffer-menu-unmark-all}). @end table @noindent diff --git a/etc/NEWS b/etc/NEWS index 15c264f..4b2af50 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -280,6 +280,24 @@ the file's actual content before prompting the user. * Changes in Specialized Modes and Packages in Emacs 26.1 +** Electric-Buffer-menu + ++++ +*** Key 'U' is bound to 'Buffer-menu-unmark-all' and key 'M-DEL' is +bound to 'Buffer-menu-unmark-all-buffers'. + +** bs + +--- +*** Two new commands 'bs-unmark-all', bound to 'U', and +'bs-unmark-previous', bound to . + +** Buffer-menu + ++++ +*** Two new commands 'Buffer-menu-unmark-all', bound to 'U' and +'Buffer-menu-unmark-all-buffers', bound to 'M-DEL'. + ** Ibuffer --- diff --git a/lisp/bs.el b/lisp/bs.el index 8351169..2ee0a5b 100644 --- a/lisp/bs.el +++ b/lisp/bs.el @@ -491,6 +491,8 @@ bs-mode-map (define-key map "t" 'bs-visit-tags-table) (define-key map "m" 'bs-mark-current) (define-key map "u" 'bs-unmark-current) + (define-key map "U" 'bs-unmark-all) + (define-key map "\177" 'bs-unmark-previous) (define-key map ">" 'scroll-right) (define-key map "<" 'scroll-left) (define-key map "?" 'bs-help) @@ -635,6 +637,8 @@ bs-mode \\[bs-clear-modified] -- clear modified-flag on that buffer. \\[bs-mark-current] -- mark current line's buffer to be displayed. \\[bs-unmark-current] -- unmark current line's buffer to be displayed. +\\[bs-unmark-all] -- unmark all buffer lines. +\\[bs-unmark-previous] -- unmark previous line's buffer to be displayed. \\[bs-show-sorted] -- display buffer list sorted by next sort aspect. \\[bs-set-configuration-and-refresh] -- ask user for a configuration and \ apply selected configuration. @@ -882,6 +886,33 @@ bs-unmark-current (lambda (buf) (setq bs--marked-buffers (delq buf bs--marked-buffers))))) +(defun bs-unmark-previous (count) + "Unmark previous COUNT buffers. +Move point vertically up COUNT lines. +When called interactively a numeric prefix argument sets COUNT." + (interactive "p") + (forward-line (- count)) + (save-excursion (bs-unmark-current count))) + +(defun bs-unmark-all () + "Unmark all buffers." + (interactive) + (let ((marked (string-to-char bs-string-marked)) + (current (string-to-char bs-string-current)) + (marked-cur (string-to-char bs-string-current-marked)) + (unmarked (string-to-char bs-string-show-normally)) + (inhibit-read-only t)) + (save-excursion + (goto-char (point-min)) + (forward-line 2) + (while (not (eobp)) + (if (eq (char-after) marked) + (subst-char-in-region (point) (1+ (point)) marked unmarked) + (when (eq (char-after) marked-cur) + (subst-char-in-region (point) (1+ (point)) marked-cur current))) + (forward-line 1)) + (setq bs--marked-buffers nil)))) + (defun bs--show-config-message (what) "Show message indicating the new showing status WHAT. WHAT is a value of nil, `never', or `always'." diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el index 4742628..f34c814 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el @@ -37,6 +37,12 @@ Buffer-menu :group 'tools :group 'convenience) +(defvar Buffer-menu-marker-char ?> + "The mark character for marked buffers.") + +(defvar Buffer-menu-del-char ?D + "Character used to flag buffers for deletion.") + (defcustom Buffer-menu-use-header-line t "If non-nil, use the header line to display Buffer Menu column titles." :type 'boolean @@ -121,6 +127,8 @@ Buffer-menu-mode-map (define-key map "\177" 'Buffer-menu-backup-unmark) (define-key map "~" 'Buffer-menu-not-modified) (define-key map "u" 'Buffer-menu-unmark) + (define-key map "\M-\177" 'Buffer-menu-unmark-all-buffers) + (define-key map "U" 'Buffer-menu-unmark-all) (define-key map "m" 'Buffer-menu-mark) (define-key map "t" 'Buffer-menu-visit-tags-table) (define-key map "%" 'Buffer-menu-toggle-read-only) @@ -197,6 +205,12 @@ Buffer-menu-mode-map (bindings--define-key menu-map [umk] '(menu-item "Unmark" Buffer-menu-unmark :help "Cancel all requested operations on buffer on this line and move down")) + (bindings--define-key menu-map [umkab] + '(menu-item "Remove marks..." Buffer-menu-unmark-all-buffers + :help "Cancel a requested operation on all buffers")) + (bindings--define-key menu-map [umka] + '(menu-item "Unmark all" Buffer-menu-unmark-all + :help "Cancel all requested operations on buffers")) (bindings--define-key menu-map [mk] '(menu-item "Mark" Buffer-menu-mark :help "Mark buffer on this line for being displayed by v command")) @@ -239,6 +253,8 @@ Buffer-menu-mode \\[Buffer-menu-execute] Delete or save marked buffers. \\[Buffer-menu-unmark] Remove all marks from current line. With prefix argument, also move up one line. +\\[Buffer-menu-unmark-all-buffers] Remove a particular mark from all lines. +\\[Buffer-menu-unmark-all] Remove all marks from all lines. \\[Buffer-menu-backup-unmark] Back up a line and remove marks. \\[Buffer-menu-toggle-read-only] Toggle read-only status of buffer on this line. \\[revert-buffer] Update the list of buffers. @@ -346,7 +362,7 @@ Buffer-menu-mark "Mark the Buffer menu entry at point for later display. It will be displayed by the \\\\[Buffer-menu-select] command." (interactive) - (tabulated-list-set-col 0 ">" t) + (tabulated-list-set-col 0 (char-to-string Buffer-menu-marker-char) t) (forward-line)) (defun Buffer-menu-unmark (&optional backup) @@ -356,6 +372,28 @@ Buffer-menu-unmark (Buffer-menu--unmark) (forward-line (if backup -1 1))) +(defun Buffer-menu-unmark-all-buffers (mark) + "Cancel a requested operation on all buffers. +MARK is the character to flag the operation on the buffers. +When called interactively prompt for MARK; RET remove all marks." + (interactive "cRemove marks (RET means all):") + (save-excursion + (goto-char (point-min)) + (when (tabulated-list-header-overlay-p) + (forward-line)) + (while (not (eobp)) + (let ((xmarks (list (aref (tabulated-list-get-entry) 0) + (aref (tabulated-list-get-entry) 2)))) + (when (or (char-equal mark ?\r) + (member (char-to-string mark) xmarks)) + (Buffer-menu--unmark))) + (forward-line)))) + +(defun Buffer-menu-unmark-all () + "Cancel all requested operations on buffers." + (interactive) + (Buffer-menu-unmark-all-buffers ?\r)) + (defun Buffer-menu-backup-unmark () "Move up and cancel all requested operations on buffer on line above." (interactive) @@ -382,12 +420,12 @@ Buffer-menu-delete (setq arg 1)) (while (> arg 0) (when (Buffer-menu-buffer) - (tabulated-list-set-col 0 "D" t)) + (tabulated-list-set-col 0 (char-to-string Buffer-menu-del-char) t)) (forward-line 1) (setq arg (1- arg))) (while (< arg 0) (when (Buffer-menu-buffer) - (tabulated-list-set-col 0 "D" t)) + (tabulated-list-set-col 0 (char-to-string Buffer-menu-del-char) t)) (forward-line -1) (setq arg (1+ arg)))) diff --git a/lisp/ebuff-menu.el b/lisp/ebuff-menu.el index 5536f94..74a9dd5 100644 --- a/lisp/ebuff-menu.el +++ b/lisp/ebuff-menu.el @@ -55,6 +55,8 @@ electric-buffer-menu-mode-map (define-key map "\177" 'Buffer-menu-backup-unmark) (define-key map "~" 'Buffer-menu-not-modified) (define-key map "u" 'Buffer-menu-unmark) + (define-key map "\M-\177" 'Buffer-menu-unmark-all-buffers) + (define-key map "U" 'Buffer-menu-unmark-all) (let ((i ?0)) (while (<= i ?9) (define-key map (char-to-string i) 'digit-argument) @@ -114,6 +116,7 @@ electric-buffer-list \\[Buffer-menu-save] -- mark that buffer to be saved. \\[Buffer-menu-delete] or \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted. \\[Buffer-menu-unmark] -- remove all kinds of marks from current line. +\\[Buffer-menu-unmark-all] -- remove all kinds of marks from all lines. \\[Electric-buffer-menu-mode-view-buffer] -- view buffer, returning when done. \\[Buffer-menu-backup-unmark] -- back up a line and remove marks." (interactive "P") diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index cf297f1..9523d5e 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -259,6 +259,12 @@ tabulated-list-print-fake-header (make-overlay (point-min) (point)))) (overlay-put tabulated-list--header-overlay 'face 'underline)))) +(defsubst tabulated-list-header-overlay-p (&optional pos) + "Return non-nil if there is a fake header. +Optional arg POS is a buffer position where to look for a fake header; +defaults to `point-min'." + (overlays-at (or pos (point-min)))) + (defun tabulated-list-revert (&rest ignored) "The `revert-buffer-function' for `tabulated-list-mode'. It runs `tabulated-list-revert-hook', then calls `tabulated-list-print'." -- 2.10.2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.3) of 2016-11-16 Repository revision: 36b99556dea23f17d5598bbed366e7201eec9fbb