From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: bug#881: patch for bug #881 Date: Thu, 07 Jan 2010 15:07:39 -0500 Message-ID: References: <87wrzwp5gd.fsf@stupidchicken.com> <201001060700.o06706Sw006855@godzilla.ics.uci.edu> <201001061829.o06IT0Zm002189@godzilla.ics.uci.edu> <201001071709.o07H9qow021561@godzilla.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1262894966 29916 80.91.229.12 (7 Jan 2010 20:09:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Jan 2010 20:09:26 +0000 (UTC) Cc: Juanma Barranquero , Chong Yidong , Emacs developers To: Dan Nicolaescu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 07 21:09:18 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NSyfV-0003P8-OY for ged-emacs-devel@m.gmane.org; Thu, 07 Jan 2010 21:09:18 +0100 Original-Received: from localhost ([127.0.0.1]:33531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSyfV-0005yl-VH for ged-emacs-devel@m.gmane.org; Thu, 07 Jan 2010 15:09:18 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSye4-00048S-P3 for emacs-devel@gnu.org; Thu, 07 Jan 2010 15:07:48 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSydz-000418-VE for emacs-devel@gnu.org; Thu, 07 Jan 2010 15:07:48 -0500 Original-Received: from [199.232.76.173] (port=38156 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSydz-00040j-6D for emacs-devel@gnu.org; Thu, 07 Jan 2010 15:07:43 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:51660) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NSydy-00016K-MF for emacs-devel@gnu.org; Thu, 07 Jan 2010 15:07:42 -0500 Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id o07K7dc6008980; Thu, 7 Jan 2010 15:07:39 -0500 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 653663A105; Thu, 7 Jan 2010 15:07:39 -0500 (EST) In-Reply-To: <201001071709.o07H9qow021561@godzilla.ics.uci.edu> (Dan Nicolaescu's message of "Thu, 7 Jan 2010 09:09:52 -0800 (PST)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3443=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:119612 Archived-At: > Here's a 100% untested version of this. It serves all the needs I can > think off at the moment. > git can add "--amend" and "--signoff" to `log-edit-extra-flags'. > Author: "foo bar" foo@bar.baz > can be dealt with using `log-edit-before-checkin-process'. > We can add a key binding to log-edit.el to insert Author: in the buffer. > The part that removes the extra markup (i.e. Author: ) from the buffer > is not implemented, but it should not be too hard. > What do you think? I dislike the `log-edit-mode' which returns a function rather that running the code directly. And of course the "FIXME: this should be a function in log-edit.el" would need to be fixed. This said, I was thinking of something simpler: let the RFC822-like message go unchanged to the backend, so if the backend doesn't support "Author:" that line will just end up staying in the commit message, which doesn't seem like a bad way to handle this case. Of course, vc.el should provide some generic function(s) to parse the RFC822-like format, so backends don't have to do it all by hand. Stefan > Index: vc.el > =================================================================== > RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v > retrieving revision 1.746 > diff -u -3 -p -r1.746 vc.el > --- vc.el 7 Dec 2009 09:02:16 -0000 1.746 > +++ vc.el 7 Jan 2010 16:56:25 -0000 > @@ -261,7 +261,7 @@ > ;; Unregister FILE from this backend. This is only needed if this > ;; backend may be used as a "more local" backend for temporary editing. > ;; > -;; * checkin (files rev comment) > +;; * checkin (files rev comment &rest args) > ;; > ;; Commit changes in FILES to this backend. If REV is non-nil, that > ;; should become the new revision number (not all backends do > @@ -269,6 +269,7 @@ > ;; implementation should pass the value of vc-checkin-switches to > ;; the backend command. (Note: in older versions of VC, this > ;; command took a single file argument and not a list.) > +;; ARGS should be passed to the backend command. > ;; > ;; * find-revision (file rev buffer) > ;; > @@ -477,6 +478,12 @@ > ;; Return the revision number that follows REV for FILE, or nil if no such > ;; revision exists. > ;; > +;; - log-edit-mode () > +;; > +;; Return a symbol that is the mode to use for editing the check in > +;; log. This defaults to `log-edit-mode' and is expected to be > +;; changed (if at all) to a derived mode of `log-edit-mode'. > +;; > ;; - check-headers () > ;; > ;; Return non-nil if the current buffer contains any version headers. > @@ -1348,7 +1365,7 @@ Runs the normal hooks `vc-before-checkin > files rev comment initial-contents > "Enter a change comment." > "*VC-log*" > - (lambda (files rev comment) > + (lambda (files rev comment extra-flags) > (message "Checking in %s..." (vc-delistify files)) > ;; "This log message intentionally left almost blank". > ;; RCS 5.7 gripes about white-space-only comments too. > @@ -1359,7 +1376,7 @@ Runs the normal hooks `vc-before-checkin > ;; We used to change buffers to get local value of vc-checkin-switches, > ;; but 'the' local buffer is not a well-defined concept for filesets. > (progn > - (vc-call-backend backend 'checkin files rev comment) > + (vc-call-backend backend 'checkin files rev comment extra-flags) > (mapc 'vc-delete-automatic-version-backups files)) > `((vc-state . up-to-date) > (vc-checkout-time . ,(nth 5 (file-attributes file))) > @@ -1729,7 +1746,7 @@ The headers are reset to their non-expan > files rev oldcomment t > "Enter a replacement change comment." > "*VC-log*" > - (lambda (files rev comment) > + (lambda (files rev comment ignored) > (vc-call-backend > ;; Less of a kluge than it looks like; log-view mode only passes > ;; this function a singleton list. Arguments left in this form in > @@ -2414,6 +2431,8 @@ to provide the `find-revision' operation > (defalias 'vc-default-check-headers 'ignore) > +(defun vc-default-log-edit-mode (backend) 'log-edit-mode) > + > (defun vc-default-log-view-mode (backend) (log-view-mode)) > (defun vc-default-show-log-entry (backend rev) > Index: vc-dispatcher.el > =================================================================== > RCS file: /cvsroot/emacs/emacs/lisp/vc-dispatcher.el,v > retrieving revision 1.71 > diff -u -3 -p -r1.71 vc-dispatcher.el > --- vc-dispatcher.el 1 Oct 2009 03:32:27 -0000 1.71 > +++ vc-dispatcher.el 7 Jan 2010 16:56:26 -0000 > @@ -526,7 +526,9 @@ NOT-URGENT means it is ok to continue if > (log-edit 'vc-finish-logentry > nil > `((log-edit-listfun . (lambda () ',fileset)) > - (log-edit-diff-function . (lambda () (vc-diff nil))))) > + (log-edit-diff-function . (lambda () (vc-diff nil)))) > + nil > + (vc-call-backend (car fileset) 'log-edit-mode)) > (set (make-local-variable 'vc-log-fileset) fileset) > (make-local-variable 'vc-log-extra) > (set-buffer-modified-p nil) > @@ -587,6 +589,15 @@ the buffer contents as a comment." > (or (vc-dispatcher-browsing) (vc-buffer-sync))) > (unless vc-log-operation > (error "No log operation is pending")) > + > + ;; FIXME: this should be a function in log-edit.el > + (when log-edit-before-checkin-process > + (dolist (crt log-edit-before-checkin-process) > + ;; Remove all lines matching (car crt) > + ;; Append to `log-edit-extra-flags' the results of (cdr crt). > + ) > + ) > + > ;; save the parameters held in buffer-local variables > (let ((logbuf (current-buffer)) > (log-operation vc-log-operation) > @@ -601,7 +612,8 @@ the buffer contents as a comment." > (funcall log-operation > log-fileset > log-extra > - log-entry)) > + log-entry > + log-edit-extra-flags)) > ;; Remove checkin window (after the checkin so that if that fails > ;; we don't zap the log buffer and the typing therein). > ;; -- IMO this should be replaced with quit-window > Index: log-edit.el > =================================================================== > RCS file: /cvsroot/emacs/emacs/lisp/log-edit.el,v > retrieving revision 1.56 > diff -u -3 -p -r1.56 log-edit.el > --- log-edit.el 2 Oct 2009 03:48:41 -0000 1.56 > +++ log-edit.el 7 Jan 2010 16:56:26 -0000 > @@ -185,6 +185,25 @@ when this variable is set to nil.") > (defvar log-edit-callback nil) > (defvar log-edit-diff-function nil) > (defvar log-edit-listfun nil) > +(defvar log-edit-extra-flags nil > + "List of extra flags to pass to the check in command.") > +(defvar log-edit-before-checkin-process nil > + "Alist that contains instructions for processing the commit message before check in. > + > +The format is: (REGEXP . INSTRUCTIONS). > + > +All lines matching REGEXP are removed. > + > +For example: > + > +(\"^#.*\" . nil) > +means: just remove all lines starting with #. This can be used > +to insert lines in the commit buffer that contain for example the > +list of files to be committed. > + > +(\"Author: \\(.*\\)\" . (list \"--author\" (match-string 1))) > +means: append (list \"--author\" (match-string 1)) to > +`log-edit-extra-flags'.") > (defvar log-edit-parent-buffer nil) > ;;; Originally taken from VC-Log mode > @@ -315,9 +334,10 @@ automatically." > (2 font-lock-function-name-face)))) > ;;;###autoload > -(defun log-edit (callback &optional setup params buffer &rest ignore) > +(defun log-edit (callback &optional setup params buffer mode &rest ignore) > "Setup a buffer to enter a log message. > -\\The buffer will be put in `log-edit-mode'. > +\\The buffer will be put in mode MODE or `log-edit-mode' > +if MODE is nil. > If SETUP is non-nil, the buffer is then erased and `log-edit-hook' is run. > Mark and point will be set around the entire contents of the buffer so > that it is easy to kill the contents of the buffer with \\[kill-region]. > @@ -338,7 +358,9 @@ uses the current buffer." > (when (and log-edit-setup-invert (not (eq setup 'force))) > (setq setup (not setup))) > (when setup (erase-buffer)) > - (log-edit-mode) > + (if mode > + (funcall mode) > + (log-edit-mode)) > (set (make-local-variable 'log-edit-callback) callback) > (if (listp params) > (dolist (crt params)