unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 1/2] emacs: Remove "M" key binding for marking all lines.
@ 2015-05-27 17:52 Alex Kost
  2015-05-29 11:50 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Kost @ 2015-05-27 17:52 UTC (permalink / raw)
  To: guix-devel

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

Reasons for this patch:

- Make "m" (mark) key binding do the same thing as "u" (unmark) — 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-emacs-Remove-M-key-binding-for-marking-all-lines.patch --]
[-- Type: text/x-diff, Size: 6836 bytes --]

From 83f44de5f99d13ecdeff1aa7747d7e6d5eeec72b Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
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


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

end of thread, other threads:[~2015-05-29 11:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-27 17:52 [PATCH 1/2] emacs: Remove "M" key binding for marking all lines Alex Kost
2015-05-29 11:50 ` Ludovic Courtès

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

	https://git.savannah.gnu.org/cgit/guix.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).