comparison lisp/log-edit.el @ 107430:1918e70c8b37

Add special markup processing for commit logs. * log-edit.el (log-edit-extra-flags): New variable. (log-edit): Add new argument MODE. Use that mode when non-nil instead of the log-view-mode. (log-view-process-buffer): New function. * vc.el: Document that the checkin method takes optional arguments. Document new backend specific method: log-view-mode. (vc-default-log-edit-mode): New function. (vc-checkin): Use a backend specific log-view-mode. Pass extra arguments to the checkin method. (vc-modify-change-comment): Pass a dummy extra argument. * vc-dispatcher.el (vc-log-edit): Add a mode argument, pass it to log-edit. (vc-start-logentry): Add a mode argument, pass it to vc-log-edit. (vc-finish-logentry): Process the log buffer before passing it down. Pass log-edit-extra-flags. * vc-bzr.el (vc-bzr-checkin): Pass extra arguments to the commit command. (log-edit-extra-flags, log-edit-before-checkin-process): New declarations. * vc-hg.el (vc-hg-checkin): Pass extra arguments to the commit command. (log-edit-extra-flags, log-edit-before-checkin-process): New declarations. (vc-hg-log-edit-mode): New derived mode. * vc-arch.el (vc-arch-checkin): * vc-cvs.el (vc-cvs-checkin): * vc-git.el (vc-git-checkin): * vc-mtn.el (vc-mtn-checkin): * vc-rcs.el (vc-rcs-checkin): * vc-sccs.el (vc-sccs-checkin): * vc-svn.el (vc-svn-checkin): Add an optional ignored argument.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 19 Mar 2010 02:37:41 -0700
parents dc9565b08f10
children 1161bde4ebd6
comparison
equal deleted inserted replaced
107429:024cba2776d2 107430:1918e70c8b37
186 (defconst log-edit-files-buf "*log-edit-files*") 186 (defconst log-edit-files-buf "*log-edit-files*")
187 (defvar log-edit-initial-files nil) 187 (defvar log-edit-initial-files nil)
188 (defvar log-edit-callback nil) 188 (defvar log-edit-callback nil)
189 (defvar log-edit-diff-function nil) 189 (defvar log-edit-diff-function nil)
190 (defvar log-edit-listfun nil) 190 (defvar log-edit-listfun nil)
191 (defvar log-edit-extra-flags nil
192 "List of extra flags to pass to the check in command.")
193 (defvar log-edit-before-checkin-process nil
194 "Alist that contains instructions for processing the commit message before check in.
195
196 The format is: (REGEXP . INSTRUCTIONS).
197
198 All lines matching REGEXP are removed.
199
200 For example:
201
202 (\"^#.*\" . nil)
203 means: just remove all lines starting with #. This can be used
204 to insert lines in the commit buffer that contain, for example, the
205 list of files to be committed.
206
207 (\"Author: \\(.*\\)\" . (list \"--author\" (match-string 1)))
208 means: append (list \"--author\" (match-string 1)) to
209 `log-edit-extra-flags'.")
191 (defvar log-edit-parent-buffer nil) 210 (defvar log-edit-parent-buffer nil)
192 211
193 ;;; Originally taken from VC-Log mode 212 ;;; Originally taken from VC-Log mode
194 213
195 (defconst log-edit-maximum-comment-ring-size 32 214 (defconst log-edit-maximum-comment-ring-size 32
316 '(("\\`\\(Summary:\\)\\(.*\\)" 335 '(("\\`\\(Summary:\\)\\(.*\\)"
317 (1 font-lock-keyword-face) 336 (1 font-lock-keyword-face)
318 (2 font-lock-function-name-face)))) 337 (2 font-lock-function-name-face))))
319 338
320 ;;;###autoload 339 ;;;###autoload
321 (defun log-edit (callback &optional setup params buffer &rest ignore) 340 (defun log-edit (callback &optional setup params buffer mode &rest ignore)
322 "Setup a buffer to enter a log message. 341 "Setup a buffer to enter a log message.
323 \\<log-edit-mode-map>The buffer will be put in `log-edit-mode'. 342 \\<log-edit-mode-map>The buffer will be put in mode MODE or `log-edit-mode'
343 if MODE is nil.
324 If SETUP is non-nil, the buffer is then erased and `log-edit-hook' is run. 344 If SETUP is non-nil, the buffer is then erased and `log-edit-hook' is run.
325 Mark and point will be set around the entire contents of the buffer so 345 Mark and point will be set around the entire contents of the buffer so
326 that it is easy to kill the contents of the buffer with \\[kill-region]. 346 that it is easy to kill the contents of the buffer with \\[kill-region].
327 Once you're done editing the message, pressing \\[log-edit-done] will call 347 Once you're done editing the message, pressing \\[log-edit-done] will call
328 `log-edit-done' which will end up calling CALLBACK to do the actual commit. 348 `log-edit-done' which will end up calling CALLBACK to do the actual commit.
339 (let ((parent (current-buffer))) 359 (let ((parent (current-buffer)))
340 (if buffer (pop-to-buffer buffer)) 360 (if buffer (pop-to-buffer buffer))
341 (when (and log-edit-setup-invert (not (eq setup 'force))) 361 (when (and log-edit-setup-invert (not (eq setup 'force)))
342 (setq setup (not setup))) 362 (setq setup (not setup)))
343 (when setup (erase-buffer)) 363 (when setup (erase-buffer))
344 (log-edit-mode) 364 (if mode
365 (funcall mode)
366 (log-edit-mode))
345 (set (make-local-variable 'log-edit-callback) callback) 367 (set (make-local-variable 'log-edit-callback) callback)
346 (if (listp params) 368 (if (listp params)
347 (dolist (crt params) 369 (dolist (crt params)
348 (set (make-local-variable (car crt)) (cdr crt))) 370 (set (make-local-variable (car crt)) (cdr crt)))
349 ;; For backward compatibility with log-edit up to version 22.2 371 ;; For backward compatibility with log-edit up to version 22.2
709 ;; each buffer, and extract them as strings. 731 ;; each buffer, and extract them as strings.
710 (dolist (buffer-entry buffer-entries) 732 (dolist (buffer-entry buffer-entries)
711 (log-edit-changelog-insert-entries (car buffer-entry) (cdr buffer-entry)) 733 (log-edit-changelog-insert-entries (car buffer-entry) (cdr buffer-entry))
712 (when (cdr buffer-entry) (newline))))) 734 (when (cdr buffer-entry) (newline)))))
713 735
736 (defun log-view-process-buffer ()
737 (when log-edit-before-checkin-process
738 (dolist (crt log-edit-before-checkin-process)
739 ;; Remove all lines matching (car crt)
740 ;; Append to `log-edit-extra-flags' the results of (cdr crt).
741 (goto-char (point-min))
742 (while (re-search-forward (car crt) nil t)
743 (when (cdr crt)
744 (setq log-edit-extra-flags (append log-edit-extra-flags (eval (cdr crt)))))
745 (replace-match "" nil t)))))
746
714 (provide 'log-edit) 747 (provide 'log-edit)
715 748
716 ;; arch-tag: 8089b39c-983b-4e83-93cd-ed0a64c7fdcc 749 ;; arch-tag: 8089b39c-983b-4e83-93cd-ed0a64c7fdcc
717 ;;; log-edit.el ends here 750 ;;; log-edit.el ends here