> Why not have `c' open the commit buffer directly, and `c' with a prefix
> argument (i.e. `C-u c') could open up the full option menu.  In fact I
> would recommend this as the default for *all* magit commands (dangerous
> commands would probably want to be wrapped in a y-or-n-p).
>
> This would be efficient and convenient, provide for internal consistency
> within magit and this would be consistent with how Emacs at large
> handles optional command customization.  To new users who have used
> Emacs before this should be the obvious thing to try.
>
> If there is any interest I'd be happy to put together a patch, given
> magit's very nice meta-programmed action mechanisms it seems like it
> should be a small change... very easy to implement, attached.
>

I'm happy to hear that something along these lines will be adopted.

Having used my previous patch for an hour or so I'm finding this
prefix-argument tact matches very well with my own personal Emacs-warped
muscle memory.  If it's useful I'm attaching an improved version of the
previous patch.

Cheers, and thanks for magit, it's a constant convenience and the code
is very well written and fun to edit.

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D
>From 4222380ad2325c08c37c379016e6f624aca6410e Mon Sep 17 00:00:00 2001
From: Eric Schulte <[email protected]>
Date: Thu, 29 Aug 2013 13:14:25 -0600
Subject: [PATCH] only show action options when prefix argument used

This commit also introduces the `magit-confirmation-groups'
customization variable which may be used to control which groups require
explicit confirmation.  Only pushing requires explicit confirmation by
default.  Not fully tested, but has been working well for an hour or so
of solid use.
---
 magit-key-mode.el | 45 +++++++++++++++++++++++++++++++++------------
 1 file changed, 33 insertions(+), 12 deletions(-)

diff --git a/magit-key-mode.el b/magit-key-mode.el
index 3932085..dfe6a45 100644
--- a/magit-key-mode.el
+++ b/magit-key-mode.el
@@ -667,6 +667,18 @@ Return the point before the actions part, if any, nil otherwise."
     p))
 
 ;;; Generate Groups
+(defcustom magit-confirmation-groups '(pushing)
+  "Actions which will require explicit confirmation."
+  :group 'git-commit
+  :type 'list
+  :initialize
+  (lambda (symbol value)
+    (let ((val (eval value)))
+      ;; set the value
+      (set-default symbol val)
+      ;; update group functions
+      (mapc (lambda (g) (magit-key-mode-generate (car g)))
+            magit-key-mode-groups))))
 
 (defun magit-key-mode-de-generate (group)
   "Unbind the function for GROUP."
@@ -677,19 +689,28 @@ Return the point before the actions part, if any, nil otherwise."
   "Generate the key-group menu for GROUP."
   (let ((opts (magit-key-mode-options-for-group group)))
     (eval
-     `(defun ,(intern (concat "magit-key-mode-popup-" (symbol-name group))) nil
+     `(defun ,(intern (concat "magit-key-mode-popup-" (symbol-name group)))
+        (&optional arg)
         ,(concat "Key menu for " (symbol-name group))
-        (interactive)
-        (magit-key-mode
-         (quote ,group)
-         ;; As a tempory kludge it is okay to do this here.
-         ,(cl-case group
-            (logging
-             '(when magit-have-graph
-                (list "--graph")))
-            (diff-options
-             '(when (local-variable-p 'magit-diff-options)
-                magit-diff-options))))))))
+        (interactive "P")
+        (if arg
+            ;; pop up the full menu
+            (magit-key-mode
+             (quote ,group)
+             ;; As a tempory kludge it is okay to do this here.
+             ,(cl-case group
+                (logging
+                 '(when magit-have-graph
+                    (list "--graph")))
+                (diff-options
+                 '(when (local-variable-p 'magit-diff-options)
+                    magit-diff-options))))
+          ;; execute the first action directly
+          ,(let ((action (cddadr (assoc 'actions opts)))
+                 (action-desc (cadadr (assoc 'actions opts))))
+             (if (member group magit-confirmation-groups)
+                 `(when (y-or-n-p ,action-desc) ,action)
+               action)))))))
 
 ;; create the interactive functions for the key mode popups (which are
 ;; applied in the top-level key maps)
-- 
1.8.4

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"magit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to