Window config stored and reapplied on quit.
This commit is contained in:
parent
6bd2a0d726
commit
e04f27d887
1 changed files with 25 additions and 11 deletions
|
@ -185,7 +185,10 @@ put it in magit-key-mode-key-maps for fast lookup."
|
||||||
(arguments (cdr (assoc 'arguments options))))
|
(arguments (cdr (assoc 'arguments options))))
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
;; all maps should 'quit' with C-g
|
;; all maps should 'quit' with C-g
|
||||||
(define-key map (kbd "C-g") 'magit-key-mode-kill-buffer)
|
(define-key map (kbd "C-g") (lambda ()
|
||||||
|
(interactive)
|
||||||
|
(with-magit-key-mode-command
|
||||||
|
t)))
|
||||||
(when actions
|
(when actions
|
||||||
(dolist (k actions)
|
(dolist (k actions)
|
||||||
(define-key map (car k) `(lambda ()
|
(define-key map (car k) `(lambda ()
|
||||||
|
@ -232,12 +235,12 @@ put it in magit-key-mode-key-maps for fast lookup."
|
||||||
(list magit-key-mode-action-re '(1 font-lock-builtin-face))))
|
(list magit-key-mode-action-re '(1 font-lock-builtin-face))))
|
||||||
|
|
||||||
(defmacro with-magit-key-mode-command (&rest body)
|
(defmacro with-magit-key-mode-command (&rest body)
|
||||||
|
(set-window-configuration magit-log-mode-window-conf)
|
||||||
`(let ((magit-custom-options magit-key-mode-current-options))
|
`(let ((magit-custom-options magit-key-mode-current-options))
|
||||||
,@body
|
,@body
|
||||||
(magit-key-mode-kill-buffer)))
|
(magit-key-mode-kill-buffer)))
|
||||||
|
|
||||||
(defun magit-key-mode-add-argument (for-group option-name)
|
(defun magit-key-mode-add-argument (for-group option-name))
|
||||||
)
|
|
||||||
|
|
||||||
(defun magit-key-mode-add-option (for-group option-name)
|
(defun magit-key-mode-add-option (for-group option-name)
|
||||||
"Toggles the appearance of OPTION-NAME in
|
"Toggles the appearance of OPTION-NAME in
|
||||||
|
@ -252,17 +255,27 @@ put it in magit-key-mode-key-maps for fast lookup."
|
||||||
(interactive)
|
(interactive)
|
||||||
(kill-buffer magit-key-mode-buf-name))
|
(kill-buffer magit-key-mode-buf-name))
|
||||||
|
|
||||||
|
(defvar magit-log-mode-window-conf nil
|
||||||
|
"Pre-popup window configuration.")
|
||||||
|
|
||||||
(defun magit-key-mode (for-group &optional original-opts)
|
(defun magit-key-mode (for-group &optional original-opts)
|
||||||
"Mode for magit key selection."
|
"Mode for magit key selection."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
||||||
|
;; save the window config to restore it as was
|
||||||
|
(setq magit-log-mode-window-conf
|
||||||
|
(current-window-configuration))
|
||||||
|
|
||||||
|
;; setup the mode, draw the buffer
|
||||||
(let ((buf (get-buffer-create magit-key-mode-buf-name)))
|
(let ((buf (get-buffer-create magit-key-mode-buf-name)))
|
||||||
(pop-to-buffer buf)
|
(delete-other-windows)
|
||||||
(with-current-buffer buf
|
(split-window-vertically)
|
||||||
(kill-all-local-variables)
|
(switch-to-buffer buf)
|
||||||
(set (make-variable-buffer-local
|
(kill-all-local-variables)
|
||||||
'magit-key-mode-current-options)
|
(set (make-variable-buffer-local
|
||||||
original-opts)
|
'magit-key-mode-current-options)
|
||||||
(magit-key-mode-redraw for-group))))
|
original-opts)
|
||||||
|
(magit-key-mode-redraw for-group)))
|
||||||
|
|
||||||
(defun magit-key-mode-redraw (for-group)
|
(defun magit-key-mode-redraw (for-group)
|
||||||
"(re)draw the magit key buffer."
|
"(re)draw the magit key buffer."
|
||||||
|
@ -276,7 +289,8 @@ put it in magit-key-mode-key-maps for fast lookup."
|
||||||
(magit-key-mode-build-keymap for-group)))
|
(magit-key-mode-build-keymap for-group)))
|
||||||
(magit-key-mode-draw for-group)
|
(magit-key-mode-draw for-group)
|
||||||
(setq mode-name "magit-key-mode" major-mode 'magit-key-mode))
|
(setq mode-name "magit-key-mode" major-mode 'magit-key-mode))
|
||||||
(setq buffer-read-only t))
|
(setq buffer-read-only t)
|
||||||
|
(fit-window-to-buffer))
|
||||||
|
|
||||||
(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."
|
||||||
|
|
Loading…
Add table
Reference in a new issue