From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH 1/2] emacs: Remove "M" key binding for marking all lines. Date: Wed, 27 May 2015 20:52:36 +0300 Message-ID: <87iobdvrff.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxfVW-0000C9-UF for guix-devel@gnu.org; Wed, 27 May 2015 13:52:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxfVR-00018I-Un for guix-devel@gnu.org; Wed, 27 May 2015 13:52:46 -0400 Received: from mail-lb0-x229.google.com ([2a00:1450:4010:c04::229]:33537) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxfVR-00017q-Ij for guix-devel@gnu.org; Wed, 27 May 2015 13:52:41 -0400 Received: by lbcue7 with SMTP id ue7so12735381lbc.0 for ; Wed, 27 May 2015 10:52:40 -0700 (PDT) Received: from leviafan ([217.107.192.160]) by mx.google.com with ESMTPSA id ex12sm3989376lac.7.2015.05.27.10.52.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 May 2015 10:52:38 -0700 (PDT) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Reasons for this patch: - Make "m" (mark) key binding do the same thing as "u" (unmark) =E2=80=94 i= .e., respect the prefix argument ("C-u m" to mark all lines). - Free "M" key binding (previously used to mark all) for "guix-apply-manifest" command which is introduced in the next patch. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-emacs-Remove-M-key-binding-for-marking-all-lines.patch >From 83f44de5f99d13ecdeff1aa7747d7e6d5eeec72b Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Wed, 27 May 2015 16:51:25 +0300 Subject: [PATCH 1/2] emacs: Remove "M" key binding for marking all lines. * emacs/guix-list.el: Split 'guix-list-mark' into internal and interactive functions. Remove "M" key binding, use "C-u m" instead. (guix-list--mark): New function. Use it in other marking functions. (guix-list-mark): Mark all lines with a prefix argument. * doc/emacs.texi (Emacs List buffer): Document changes in the key bindings. --- doc/emacs.texi | 4 +--- emacs/guix-list.el | 42 ++++++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/doc/emacs.texi b/doc/emacs.texi index e1d14a4..9678570 100644 --- a/doc/emacs.texi +++ b/doc/emacs.texi @@ -213,9 +213,7 @@ Default key bindings available for both ``package-list'' and @table @kbd @item m -Mark the current entry. -@item M -Mark all entries. +Mark the current entry (with prefix, mark all entries). @item u Unmark the current entry (with prefix, unmark all entries). @item @key{DEL} diff --git a/emacs/guix-list.el b/emacs/guix-list.el index 600f2bd..279de81 100644 --- a/emacs/guix-list.el +++ b/emacs/guix-list.el @@ -292,13 +292,11 @@ See `guix-list-marked' for the meaning of ARGS." See `guix-list-get-marked' for details." (mapcar #'car (apply #'guix-list-get-marked mark-names))) -(defun guix-list-mark (mark-name &optional advance &rest args) +(defun guix-list--mark (mark-name &optional advance &rest args) "Put a mark on the current line. Also add the current entry to `guix-list-marked' using its ID and ARGS. MARK-NAME is a symbol from `guix-list-mark-alist'. -If ADVANCE is non-nil, move forward by one line after marking. -Interactively, put a general mark and move to the next line." - (interactive '(general t)) +If ADVANCE is non-nil, move forward by one line after marking." (let ((id (guix-list-current-id))) (if (eq mark-name 'empty) (setq guix-list-marked (assq-delete-all id guix-list-marked)) @@ -310,12 +308,21 @@ Interactively, put a general mark and move to the next line." (tabulated-list-put-tag (guix-list-get-mark-string mark-name) advance)) -(defun guix-list-mark-all (mark-name) +(defun guix-list-mark (&optional arg) + "Mark the current line and move to the next line. +With ARG, mark all lines." + (interactive "P") + (if arg + (guix-list-mark-all) + (guix-list--mark 'general t))) + +(defun guix-list-mark-all (&optional mark-name) "Mark all lines with MARK-NAME mark. MARK-NAME is a symbol from `guix-list-mark-alist'. Interactively, put a general mark on all lines." - (interactive '(general)) - (guix-list-for-each-line #'guix-list-mark mark-name)) + (interactive) + (or mark-name (setq mark-name 'general)) + (guix-list-for-each-line #'guix-list--mark mark-name)) (defun guix-list-unmark (&optional arg) "Unmark the current line and move to the next line. @@ -323,13 +330,13 @@ With ARG, unmark all lines." (interactive "P") (if arg (guix-list-unmark-all) - (guix-list-mark 'empty t))) + (guix-list--mark 'empty t))) (defun guix-list-unmark-backward () "Move up one line and unmark it." (interactive) (forward-line -1) - (guix-list-mark 'empty)) + (guix-list--mark 'empty)) (defun guix-list-unmark-all () "Unmark all lines." @@ -360,7 +367,6 @@ Same as `tabulated-list-sort', but also restore marks after sorting." (define-key map (kbd "RET") 'guix-list-describe) (define-key map (kbd "m") 'guix-list-mark) (define-key map (kbd "*") 'guix-list-mark) - (define-key map (kbd "M") 'guix-list-mark-all) (define-key map (kbd "u") 'guix-list-unmark) (define-key map (kbd "DEL") 'guix-list-unmark-backward) (define-key map [remap tabulated-list-sort] 'guix-list-sort) @@ -417,7 +423,7 @@ This macro defines the following functions: ,(concat "Put '" mark-name-str "' mark and move to the next line.\n" "Also add the current entry to `guix-list-marked'.") (interactive) - (guix-list-mark ',mark-name t)))) + (guix-list--mark ',mark-name t)))) marks-val) (defun ,init-fun () @@ -531,7 +537,7 @@ AVAILABLE list, otherwise mark all DEFAULT outputs." (guix-completing-read-multiple prompt available nil t) default))) - (apply #'guix-list-mark mark t outputs))) + (apply #'guix-list--mark mark t outputs))) (defun guix-package-list-mark-install (&optional arg) "Mark the current package for installation and move to the next line. @@ -606,7 +612,7 @@ accept an entry as argument." (interactive) (guix-list-mark-package-upgrades (lambda (entry) - (apply #'guix-list-mark + (apply #'guix-list--mark 'upgrade nil (guix-get-installed-outputs entry))))) @@ -661,7 +667,7 @@ The specification is suitable for `guix-process-package-actions'." (installed (guix-get-key-val entry 'installed))) (if installed (user-error "This output is already installed") - (guix-list-mark 'install t)))) + (guix-list--mark 'install t)))) (defun guix-output-list-mark-delete () "Mark the current output for deletion and move to the next line." @@ -670,7 +676,7 @@ The specification is suitable for `guix-process-package-actions'." (let* ((entry (guix-list-current-entry)) (installed (guix-get-key-val entry 'installed))) (if installed - (guix-list-mark 'delete t) + (guix-list--mark 'delete t) (user-error "This output is not installed")))) (defun guix-output-list-mark-upgrade () @@ -683,13 +689,13 @@ The specification is suitable for `guix-process-package-actions'." (user-error "This output is not installed")) (when (or (guix-get-key-val entry 'obsolete) (y-or-n-p "This output is not obsolete. Try to upgrade it anyway? ")) - (guix-list-mark 'upgrade t)))) + (guix-list--mark 'upgrade t)))) (defun guix-output-list-mark-upgrades () "Mark all obsolete package outputs for upgrading." (interactive) (guix-list-mark-package-upgrades - (lambda (_) (guix-list-mark 'upgrade)))) + (lambda (_) (guix-list--mark 'upgrade)))) (defun guix-output-list-execute () "Perform actions on the marked outputs." @@ -850,7 +856,7 @@ With ARG, mark all generations for deletion." (interactive "P") (if arg (guix-list-mark-all 'delete) - (guix-list-mark 'delete t))) + (guix-list--mark 'delete t))) (defun guix-generation-list-execute () "Delete marked generations." -- 2.4.0 --=-=-=--