Skip to content

Commit

Permalink
Basic argument display in place.
Browse files Browse the repository at this point in the history
  • Loading branch information
philjackson committed Aug 31, 2010
1 parent 15acede commit 0604574
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions magit-key-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@
("H" "Reflog on head" magit-reflog-head))
(switches
("-f" "First parent" "--first-parent")
("-a" "All" "--all"))))
("-a" "All" "--all"))
(arguments
("-g" "Grep" "--grep" read-from-minibuffer))))
"Holds the key, help, function mapping for the log-mode. If you
modify this make sure you reset `magit-key-mode-key-maps' to
nil.")
Expand All @@ -180,7 +182,7 @@ put it in magit-key-mode-key-maps for fast lookup."
(let* ((options (magit-key-mode-options-for-group for-group))
(actions (cdr (assoc 'actions options)))
(switches (cdr (assoc 'switches options)))
(modifiers (cdr (assoc 'modifiers options))))
(arguments (cdr (assoc 'arguments options))))
(let ((map (make-sparse-keymap)))
;; all maps should 'quit' with C-g
(define-key map (kbd "C-g") 'magit-key-mode-kill-buffer)
Expand All @@ -197,6 +199,13 @@ put it in magit-key-mode-key-maps for fast lookup."
(magit-key-mode-add-option
',for-group
,(nth 2 k))))))
(when arguments
(dolist (k arguments)
(define-key map (car k) `(lambda ()
(interactive)
(magit-key-mode-add-argument
',for-group
,(nth 2 k))))))
(aput 'magit-key-mode-key-maps for-group map)
map)))

Expand All @@ -205,7 +214,7 @@ put it in magit-key-mode-key-maps for fast lookup."
command-line).")

(defvar magit-key-mode-header-re
(rx line-start (| "Actions" "Switches") ":"))
(rx line-start (| "Actions" "Switches" "Arguments") ":"))

(defvar magit-key-mode-action-re
(rx line-start
Expand All @@ -227,6 +236,9 @@ put it in magit-key-mode-key-maps for fast lookup."
,@body
(magit-key-mode-kill-buffer)))

(defun magit-key-mode-add-argument (for-group option-name)
)

(defun magit-key-mode-add-option (for-group option-name)
"Toggles the appearance of OPTION-NAME in
`magit-key-mode-current-options'."
Expand Down Expand Up @@ -270,6 +282,7 @@ put it in magit-key-mode-key-maps for fast lookup."
"Function used to draw actions, switches and parameters."
(let* ((options (magit-key-mode-options-for-group for-group))
(switches (cdr (assoc 'switches options)))
(arguments (cdr (assoc 'arguments options)))
(actions (cdr (assoc 'actions options))))
(insert "Actions:\n")
(dolist (action actions)
Expand All @@ -288,7 +301,17 @@ put it in magit-key-mode-key-maps for fast lookup."
(if (member option magit-key-mode-current-options)
(propertize option 'font-lock-face 'font-lock-warning-face)
option)
")"
"\n"))))))
")\n"))))
(insert "Arguments:\n")
(dolist (argument arguments)
(insert
(concat
" "
(car argument)
": "
(nth 1 argument)
" ("
(nth 2 argument)
")\n")))))

(provide 'magit-key-mode)

0 comments on commit 0604574

Please sign in to comment.