From: Alexandre Julliard Date: Sun, 6 Jan 2008 11:12:24 +0000 (+0100) Subject: git.el: Support for getting diffs from inside the log-edit buffer. X-Git-Tag: v1.5.4-rc3~27 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=8b30aa50593b159791fe1478cb5725caaf219d06;p=git.git git.el: Support for getting diffs from inside the log-edit buffer. Take advantage of the new log-edit feature that allows to show a diff with C-c C-d while editing the log message. Signed-off-by: Alexandre Julliard Signed-off-by: Junio C Hamano --- diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el index 28a4899a0..cadb99233 100644 --- a/contrib/emacs/git.el +++ b/contrib/emacs/git.el @@ -1024,7 +1024,9 @@ Return the list of files that haven't been handled." (setq default-directory dir) (setq buffer-read-only t))) (display-buffer buffer) - (shrink-window-if-larger-than-buffer)) + ; shrink window only if it displays the status buffer + (when (eq (window-buffer) (current-buffer)) + (shrink-window-if-larger-than-buffer))) (defun git-diff-file () "Diff the marked file(s) against HEAD." @@ -1097,6 +1099,11 @@ Return the list of files that haven't been handled." (with-current-buffer log-edit-parent-buffer (git-get-filenames (git-marked-files-state 'added 'deleted 'modified)))) +(defun git-log-edit-diff () + "Run a diff of the current files being committed from a log-edit buffer." + (with-current-buffer log-edit-parent-buffer + (git-diff-file))) + (defun git-append-sign-off (name email) "Append a Signed-off-by entry to the current buffer, avoiding duplicates." (let ((sign-off (format "Signed-off-by: %s <%s>" name email)) @@ -1169,7 +1176,10 @@ Return the list of files that haven't been handled." (when (re-search-forward "^Date: \\(.*\\)$" nil t) (setq date (match-string 1))))) (git-setup-log-buffer buffer author-name author-email subject date)) - (log-edit #'git-do-commit nil #'git-log-edit-files buffer) + (if (boundp 'log-edit-diff-function) + (log-edit 'git-do-commit nil '((log-edit-listfun . git-log-edit-files) + (log-edit-diff-function . git-log-edit-diff)) buffer) + (log-edit 'git-do-commit nil 'git-log-edit-files buffer)) (setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords)) (setq buffer-file-coding-system coding-system) (re-search-forward (regexp-quote (concat git-log-msg-separator "\n")) nil t))))