Pretty layout of actions.
This commit is contained in:
parent
ee332fdf4f
commit
02600a8e47
1 changed files with 17 additions and 4 deletions
|
@ -324,16 +324,29 @@ put it in magit-key-mode-key-maps for fast lookup."
|
||||||
(setq buffer-read-only t)
|
(setq buffer-read-only t)
|
||||||
(fit-window-to-buffer))
|
(fit-window-to-buffer))
|
||||||
|
|
||||||
|
(defun magit-key-mode-draw-actions (actions)
|
||||||
|
(when actions
|
||||||
|
(let* ((action-strs (mapcar (lambda (a)
|
||||||
|
(format " %s: %s" (car a) (nth 1 a)))
|
||||||
|
actions))
|
||||||
|
(longest-act (apply 'max (mapcar 'length action-strs)))
|
||||||
|
(max-size 70))
|
||||||
|
(insert "Actions:\n")
|
||||||
|
(dolist (str action-strs)
|
||||||
|
(let ((padding (make-string (- (+ longest-act 5) (length str)) ? )))
|
||||||
|
(insert str)
|
||||||
|
(if (> (+ (current-column) longest-act) max-size)
|
||||||
|
(insert "\n")
|
||||||
|
(insert padding))))
|
||||||
|
(insert "\n"))))
|
||||||
|
|
||||||
(defun magit-key-mode-draw (for-group)
|
(defun magit-key-mode-draw (for-group)
|
||||||
"Function used to draw actions, switches and parameters."
|
"Function used to draw actions, switches and parameters."
|
||||||
(let* ((options (magit-key-mode-options-for-group for-group))
|
(let* ((options (magit-key-mode-options-for-group for-group))
|
||||||
(switches (cdr (assoc 'switches options)))
|
(switches (cdr (assoc 'switches options)))
|
||||||
(arguments (cdr (assoc 'arguments options)))
|
(arguments (cdr (assoc 'arguments options)))
|
||||||
(actions (cdr (assoc 'actions options))))
|
(actions (cdr (assoc 'actions options))))
|
||||||
(insert "Actions:\n")
|
(magit-key-mode-draw-actions actions)
|
||||||
(dolist (action actions)
|
|
||||||
(insert
|
|
||||||
(format " %s: %s\n" (car action) (nth 1 action))))
|
|
||||||
(when switches
|
(when switches
|
||||||
(insert "Switches:\n")
|
(insert "Switches:\n")
|
||||||
(dolist (switch switches)
|
(dolist (switch switches)
|
||||||
|
|
Loading…
Add table
Reference in a new issue