From: Dan Nicolaescu <dann@ics.uci.edu>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: Juanma Barranquero <lekktu@gmail.com>,
Chong Yidong <cyd@stupidchicken.com>,
Emacs developers <emacs-devel@gnu.org>
Subject: Re: bug#881: patch for bug #881
Date: Thu, 7 Jan 2010 09:09:52 -0800 (PST) [thread overview]
Message-ID: <201001071709.o07H9qow021561@godzilla.ics.uci.edu> (raw)
In-Reply-To: <jwvfx6jhtw1.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 06 Jan 2010 15:19:16 -0500")
Stefan Monnier <monnier@IRO.UMontreal.CA> 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.
-\\<log-edit-mode-map>The buffer will be put in `log-edit-mode'.
+\\<log-edit-mode-map>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)
next prev parent reply other threads:[~2010-01-07 17:09 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87wrzwp5gd.fsf@stupidchicken.com>
2010-01-06 0:43 ` bug#881: patch for bug #881 Juanma Barranquero
2010-01-06 3:35 ` Karl Fogel
2010-01-06 4:12 ` Juanma Barranquero
2010-01-06 4:19 ` Karl Fogel
2010-01-06 10:12 ` Juanma Barranquero
2010-01-06 18:15 ` Eli Zaretskii
2010-01-06 20:43 ` Juanma Barranquero
2010-01-07 4:14 ` Eli Zaretskii
2010-01-07 9:13 ` Juanma Barranquero
2010-01-06 4:13 ` Eli Zaretskii
2010-01-06 4:34 ` Stefan Monnier
2010-01-06 7:00 ` Dan Nicolaescu
2010-01-06 7:22 ` Óscar Fuentes
2010-01-06 9:34 ` Stephen J. Turnbull
2010-01-06 14:20 ` Stefan Monnier
2010-01-06 18:29 ` Dan Nicolaescu
2010-01-06 20:19 ` Stefan Monnier
2010-01-07 17:09 ` Dan Nicolaescu [this message]
2010-01-07 20:07 ` Stefan Monnier
2010-01-06 18:29 ` Eli Zaretskii
2010-01-06 18:52 ` Óscar Fuentes
2010-01-06 20:20 ` Stefan Monnier
2010-01-06 20:40 ` Eli Zaretskii
2010-01-07 15:33 ` Juanma Barranquero
2010-01-07 17:15 ` bzr --fixes [was Re: bug#881: patch for bug #881] Glenn Morris
2010-01-07 20:12 ` Juanma Barranquero
2010-01-07 20:34 ` bzr --fixes Glenn Morris
2010-01-07 22:35 ` Juanma Barranquero
2010-01-08 9:01 ` Eli Zaretskii
2010-01-08 8:27 ` Eli Zaretskii
2010-01-06 20:00 ` Committing other people's changes (was: bug#881: patch for bug #881) Reiner Steib
2010-01-16 21:50 ` bug#881: patch for bug #881 Chong Yidong
2010-01-16 21:52 ` Juanma Barranquero
2010-01-16 22:30 ` Chong Yidong
2010-01-17 9:38 ` Dan Nicolaescu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201001071709.o07H9qow021561@godzilla.ics.uci.edu \
--to=dann@ics.uci.edu \
--cc=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.org \
--cc=lekktu@gmail.com \
--cc=monnier@IRO.UMontreal.CA \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).