From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Re: bug#881: patch for bug #881 Date: Thu, 7 Jan 2010 09:09:52 -0800 (PST) Message-ID: <201001071709.o07H9qow021561@godzilla.ics.uci.edu> References: <87wrzwp5gd.fsf@stupidchicken.com> <201001060700.o06706Sw006855@godzilla.ics.uci.edu> <201001061829.o06IT0Zm002189@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 1262885098 25936 80.91.229.12 (7 Jan 2010 17:24:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Jan 2010 17:24:58 +0000 (UTC) Cc: Juanma Barranquero , Chong Yidong , Emacs developers To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 07 18:24:50 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 1NSw6L-0002L5-Ne for ged-emacs-devel@m.gmane.org; Thu, 07 Jan 2010 18:24:50 +0100 Original-Received: from localhost ([127.0.0.1]:40421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSw6L-0000QN-RJ for ged-emacs-devel@m.gmane.org; Thu, 07 Jan 2010 12:24:49 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSvtc-0008ID-3P for emacs-devel@gnu.org; Thu, 07 Jan 2010 12:11:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSvtX-0008D8-MH for emacs-devel@gnu.org; Thu, 07 Jan 2010 12:11:39 -0500 Original-Received: from [199.232.76.173] (port=58002 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSvtX-0008Cw-Fk for emacs-devel@gnu.org; Thu, 07 Jan 2010 12:11:35 -0500 Original-Received: from colin-baker-v0.ics.uci.edu ([128.195.1.153]:39401) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NSvtW-0006tw-ST for emacs-devel@gnu.org; Thu, 07 Jan 2010 12:11:35 -0500 Original-Received: from godzilla.ics.uci.edu (godzilla.ics.uci.edu [128.195.10.101]) by colin-baker-v0.ics.uci.edu (8.13.8/8.13.8) with ESMTP id o07H9rC3010253 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 7 Jan 2010 09:09:53 -0800 Original-Received: (from dann@localhost) by godzilla.ics.uci.edu (8.13.8+Sun/8.13.6/Submit) id o07H9qow021561; Thu, 7 Jan 2010 09:09:52 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Wed, 06 Jan 2010 15:19:16 -0500") Original-Lines: 209 X-ICS-MailScanner-Information: Please send mail to helpdesk@ics.uci.edu or more information X-ICS-MailScanner-ID: o07H9rC3010253 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-0.34, required 5, autolearn=disabled, ALL_TRUSTED -1.44, FM_MULTI_ODD2 1.10) X-ICS-MailScanner-From: dann@godzilla.ics.uci.edu 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:119598 Archived-At: Stefan Monnier writes: > >> > How should it work? We don't have any nice generic mechanism/UI for > >> > doing VC backend specific things in the commit buffer. > >> It's a general concept, although it's not supported by all backends. > > The general concept is that backends want to do backend specific things :-) > > That's another part. But for "author", I think we should support it in > the generic part of the VC code. After all, it's a concept we've been > using in ChangeLog for ages: the fact that only recent VCS support it is > no excuse ;-) > > > This would be helpful, but not enough, we also want to have some key > > bindings, menu entries for backend specific things. > > > So how about starting by replacing the call to `log-edit' in > > `vc-log-edit' with (vc-call-backend backend 'log-edit) > > > and then each backend that so desires can implement a mode derived from > > log-edit and do whatever it wants (like we do for log-view). > > Fine by me. But please remember that whenever possible and meaningful, > it's better to add features to vc.el than to particular backends. 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? 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)