changeset 86908:6e9e38d61817

* log-edit.el (log-edit-show-diff): New function. (log-edit-mode-map, log-edit-menu): Bind it. (log-edit-diff-function): New variable. (log-edit): Change the 3rd param to be an alist and accept a function that computes a diff for the files involved. * vc.el (vc-log-edit): Add a diff function parameter to log-edit.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sat, 01 Dec 2007 19:37:20 +0000
parents 0f135bf21932
children 71145ecef766
files etc/NEWS lisp/ChangeLog lisp/log-edit.el lisp/vc.el
diffstat 4 files changed, 43 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/etc/NEWS	Sat Dec 01 15:57:41 2007 +0000
+++ b/etc/NEWS	Sat Dec 01 19:37:20 2007 +0000
@@ -277,6 +277,9 @@
 
 *** In VC Annotate mode, you can type V to toggle the annotation visibility.
 
+** log-edit now has a command bound to C-c C-d to show the diff for
+the files involved.
+
 ** sgml-electric-tag-pair-mode lets you simultaneously edit matched tag pairs.
 
 ** The appearance of superscript and subscript in TeX is more customizable.
--- a/lisp/ChangeLog	Sat Dec 01 15:57:41 2007 +0000
+++ b/lisp/ChangeLog	Sat Dec 01 19:37:20 2007 +0000
@@ -1,3 +1,13 @@
+2007-12-01  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* log-edit.el (log-edit-show-diff): New function.
+	(log-edit-mode-map, log-edit-menu): Bind it.
+	(log-edit-diff-function): New variable.
+	(log-edit): Change the 3rd param to be an alist and accept a
+	function that computes a diff for the files involved.
+
+	* vc.el (vc-log-edit): Add a diff function parameter to log-edit.
+
 2007-12-01  Martin Rudalics  <rudalics@gmx.at>
 
 	* play/blackbox.el (bb-up, bb-down): Revert 2007-10-21 change and
--- a/lisp/log-edit.el	Sat Dec 01 15:57:41 2007 +0000
+++ b/lisp/log-edit.el	Sat Dec 01 19:37:20 2007 +0000
@@ -57,6 +57,7 @@
 (easy-mmode-defmap log-edit-mode-map
   `(("\C-c\C-c" . log-edit-done)
     ("\C-c\C-a" . log-edit-insert-changelog)
+    ("\C-c\C-d" . log-edit-show-diff)
     ("\C-c\C-f" . log-edit-show-files)
     ("\M-n"	. log-edit-next-comment)
     ("\M-p"	. log-edit-previous-comment)
@@ -79,6 +80,8 @@
     ["Insert ChangeLog" log-edit-insert-changelog]
     ["Add to ChangeLog" log-edit-add-to-changelog]
     "--"
+    ["Show diff" log-edit-show-diff
+     :help "Show the diff for the files to be committed."]
     ["List files" log-edit-show-files
      :help "Show the list of relevant files."]
     "--"
@@ -170,6 +173,7 @@
 (defconst log-edit-files-buf "*log-edit-files*")
 (defvar log-edit-initial-files nil)
 (defvar log-edit-callback nil)
+(defvar log-edit-diff-function nil)
 (defvar log-edit-listfun nil)
 (defvar log-edit-parent-buffer nil)
 
@@ -301,7 +305,7 @@
      (2 font-lock-function-name-face))))
 
 ;;;###autoload
-(defun log-edit (callback &optional setup listfun buffer &rest ignore)
+(defun log-edit (callback &optional setup params buffer &rest ignore)
   "Setup a buffer to enter a log message.
 \\<log-edit-mode-map>The buffer will be put in `log-edit-mode'.
 If SETUP is non-nil, the buffer is then erased and `log-edit-hook' is run.
@@ -309,8 +313,13 @@
 buffer so that it is easy to kill the contents of the buffer with \\[kill-region].
 Once you're done editing the message, pressing \\[log-edit-done] will call
 `log-edit-done' which will end up calling CALLBACK to do the actual commit.
-LISTFUN if non-nil is a function of no arguments returning the list of files
-  that are concerned by the current operation (using relative names).
+PARAMS if non-nil is an alist. The keys for the alist can be:
+`log-edit-listfun' and `log-edit-diff-function'. The associated
+value for `log-edit-listfun' should be a function with not
+arguments that returns the list of files that are concerned by
+the current operation (using relative names). The associated
+value for `log-edit-diff-function' should be a function with no
+arguments that displays a diff of the files concerned by the current operation.
 If BUFFER is non-nil `log-edit' will jump to that buffer, use it to edit the
   log message and go back to the current buffer when done.  Otherwise, it
   uses the current buffer."
@@ -321,7 +330,13 @@
     (when setup (erase-buffer))
     (log-edit-mode)
     (set (make-local-variable 'log-edit-callback) callback)
-    (set (make-local-variable 'log-edit-listfun) listfun)
+    (if (listp params)
+	(dolist (crt params)
+	  (set (make-local-variable (car crt)) (cdr crt)))
+      ;; For backward compatibility with log-edit up to version 22.2
+      ;; accept non-list PARAMS to mean `log-edit-list'.
+      (set (make-local-variable 'log-edit-listfun) params))
+
     (if buffer (set (make-local-variable 'log-edit-parent-buffer) parent))
     (set (make-local-variable 'log-edit-initial-files) (log-edit-files))
     (when setup (run-hooks 'log-edit-hook))
@@ -417,6 +432,11 @@
       (indent-rigidly (point-min) (point-max)
 		      (- log-edit-common-indent common)))))
 
+(defun log-edit-show-diff ()
+  "Show the diff for the files to be committed."
+  (interactive)
+  (funcall log-edit-diff-function))
+
 (defun log-edit-show-files ()
   "Show the list of files to be committed."
   (interactive)
--- a/lisp/vc.el	Sat Dec 01 15:57:41 2007 +0000
+++ b/lisp/vc.el	Sat Dec 01 19:37:20 2007 +0000
@@ -83,8 +83,8 @@
 ;; to be installed somewhere on Emacs's path for executables.
 ;;
 ;; If your site uses the ChangeLog convention supported by Emacs, the
-;; function log-edit-comment-to-change-log could prove a useful checkin hook,
-;; although you might prefer to use C-c C-a (i.e. log-edit-insert-changelog)
+;; function `log-edit-comment-to-change-log' could prove a useful checkin hook,
+;; although you might prefer to use C-c C-a (i.e. `log-edit-insert-changelog')
 ;; from the commit buffer instead or to set `log-edit-setup-invert'.
 ;;
 ;; The vc code maintains some internal state in order to reduce expensive
@@ -3577,7 +3577,10 @@
   "Set up `log-edit' for use with VC on FILE."
   (setq default-directory
 	(with-current-buffer vc-parent-buffer default-directory))
-  (log-edit 'vc-finish-logentry nil `(lambda () ',fileset))
+  (log-edit 'vc-finish-logentry
+	    nil
+	    `((log-edit-listfun . (lambda () ',fileset))
+	      (log-edit-diff-function . (lambda () (vc-diff nil)))))
   (set (make-local-variable 'vc-log-fileset) fileset)
   (make-local-variable 'vc-log-revision)
   (set-buffer-modified-p nil)