DORMANTno replies

[PATCH 1/3] git.el: Support for getting diffs from inside the log-edit buffer.

From: Alexandre Julliard <hidden>
Date: 2016-06-15 22:44:02
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 contrib/emacs/git.el |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 28a4899..e0e6316 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))))
-- 
1.5.4.rc2.53.gb6f8

-- 
Alexandre Julliard
julliard@winehq.org
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help