Permit cancelling log edits.

* magit.el: Permit cancelling log edits.

magit-log-edit-confirm-cancellation: New defcustom.
magit-log-edit-map: New keybinding: C-c C-k to cancel the log.
magit-log-edit-cancel-log-message: New function.
magit-pop-to-log-edit: Indicate that cancellation is possible.
This commit is contained in:
Jesse Alama 2009-02-21 18:54:13 -08:00 committed by John Wiegley
parent 5c42f45f53
commit 44763451f1

View file

@ -101,6 +101,11 @@ Setting this to nil will make it do nothing, setting it to t will arrange things
(const :tag "Immediately" 0) (const :tag "Immediately" 0)
(integer :tag "After this many seconds"))) (integer :tag "After this many seconds")))
(defcustom magit-log-edit-confirm-cancellation nil
"Require acknowledgement before cancelling the log edit buffer."
:group 'magit
:type 'boolean)
(defface magit-header (defface magit-header
'((t)) '((t))
"Face for generic header lines. "Face for generic header lines.
@ -2167,6 +2172,7 @@ in log buffer."
(define-key map (kbd "C-c C-a") 'magit-log-edit-toggle-amending) (define-key map (kbd "C-c C-a") 'magit-log-edit-toggle-amending)
(define-key map (kbd "M-p") 'log-edit-previous-comment) (define-key map (kbd "M-p") 'log-edit-previous-comment)
(define-key map (kbd "M-n") 'log-edit-next-comment) (define-key map (kbd "M-n") 'log-edit-next-comment)
(define-key map (kbd "C-c C-k") 'magit-log-edit-cancel-log-message)
map)) map))
(defvar magit-pre-log-edit-window-configuration nil) (defvar magit-pre-log-edit-window-configuration nil)
@ -2306,6 +2312,17 @@ Prefix arg means justify as well."
(set-window-configuration magit-pre-log-edit-window-configuration) (set-window-configuration magit-pre-log-edit-window-configuration)
(setq magit-pre-log-edit-window-configuration nil)))) (setq magit-pre-log-edit-window-configuration nil))))
(defun magit-log-edit-cancel-log-message ()
(interactive)
(when (or (not magit-log-edit-confirm-cancellation)
(yes-or-no-p
"Really cancel editing the log (any changes will be lost)?"))
(erase-buffer)
(bury-buffer)
(when magit-pre-log-edit-window-configuration
(set-window-configuration magit-pre-log-edit-window-configuration)
(setq magit-pre-log-edit-window-configuration nil))))
(defun magit-log-edit-toggle-amending () (defun magit-log-edit-toggle-amending ()
(interactive) (interactive)
(let* ((fields (magit-log-edit-get-fields)) (let* ((fields (magit-log-edit-get-fields))
@ -2325,7 +2342,7 @@ Prefix arg means justify as well."
(pop-to-buffer buf) (pop-to-buffer buf)
(setq default-directory dir) (setq default-directory dir)
(magit-log-edit-mode) (magit-log-edit-mode)
(message "Type C-c C-c to %s." operation))) (message "Type C-c C-c to %s (C-c C-k to cancel)." operation)))
(defun magit-log-edit () (defun magit-log-edit ()
(interactive) (interactive)