unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Alfred M. Szmidt" <ams@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: vc-modify-change-comment for "modern" backend fix
Date: Wed, 18 May 2022 02:34:48 -0400	[thread overview]
Message-ID: <E1nrDGi-0006Q7-Fy@fencepost.gnu.org> (raw)
In-Reply-To: <jwvilq4814l.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Tue, 17 May 2022 14:31:28 -0400)

What about something like this, I've tested it briefly with a
vc-fossil-get-log-entry, and with RCS and it seems to behave as it
does previously -- though slightly confused by what it does for RCS
(it inserts the header, but not the commit?).

diff --git a/lisp/vc/log-view.el b/lisp/vc/log-view.el
index 415b1564ed..93e38bf3d2 100644
--- a/lisp/vc/log-view.el
+++ b/lisp/vc/log-view.el
@@ -521,17 +520,6 @@
 (defun log-view-extract-comment ()
-  "Parse comment from around the current point in the log."
-  (save-excursion
-    (let (st en (backend (vc-backend (log-view-current-file))))
-      (log-view-end-of-defun)
-      (cond ((eq backend 'SVN)
-	     (forward-line -1)))
-      (setq en (point))
-      (or (log-view-current-entry nil t)
-          (throw 'beginning-of-buffer nil))
-      (cond ((memq backend '(SCCS RCS CVS SVN))
-	     (forward-line 2))
-	    ((eq backend 'Hg)
-	     (forward-line 4)
-	     (re-search-forward "summary: *" nil t)))
-      (setq st (point))
-      (buffer-substring st en))))
+  "Extract the commit message for the current file."
+  (vc-call-backend log-view-vc-backend
+                   'get-log-entry
+                   (log-view-current-file)
+                   (log-view-current-tag)))
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 3508f684c4..01ff7db356 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -359,6 +359,11 @@
 ;;   and make sure it is displayed in the buffer's window.  The default
 ;;   implementation of this function works for RCS-style logs.
 ;;
+;; - get-log-entry (file revision)
+;;
+;;   Return a string containing the log entry for FILE at revision
+;;   REVISION.
+
 ;; - comment-history (file)
 ;;
 ;;   Return a string containing all log entries that were made for FILE.
@@ -671,12 +676,7 @@
 ;; - The git backend supports amending, but in a different
 ;;   way (press `C-c C-e' in log-edit buffer, when making a new commit).
 ;;
-;; - Second, `log-view-modify-change-comment' doesn't seem to support
-;;   modern backends at all because `log-view-extract-comment'
-;;   unconditionally calls `log-view-current-file'.  This should be easy to
-;;   fix.
-;;
-;; - Third, doing message editing in log-view might be a natural way to go
+;; - Second, doing message editing in log-view might be a natural way to go
 ;;   about it, but editing any but the last commit (and even it, if it's
 ;;   been pushed) is a dangerous operation in Git, which we shouldn't make
 ;;   too easy for users to perform.
@@ -3158,6 +3158,23 @@ vc-default-show-log-entry
   (with-no-warnings
    (log-view-goto-rev rev)))
 
+(defun vc-default-get-log-entry (_backend _file _revision)
+  (save-excursion
+    (let (st en (backend (vc-backend (log-view-current-file))))
+      (log-view-end-of-defun)
+      (cond ((eq backend 'SVN)
+             (forward-line -1)))
+      (setq en (point))
+      (or (log-view-current-entry nil t)
+          (throw 'beginning-of-buffer nil))
+      (cond ((memq backend '(SCCS RCS CVS SVN))
+             (forward-line 2))
+            ((eq backend 'Hg)
+             (forward-line 4)
+             (re-search-forward "summary: *" nil t)))
+      (setq st (point))
+      (buffer-substring st en))))
+
 (defun vc-default-comment-history (backend file)
   "Return a string with all log entries stored in BACKEND for FILE."
   (when (vc-find-backend-function backend 'print-log)



  parent reply	other threads:[~2022-05-18  6:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-17  7:04 vc-modify-change-comment for "modern" backend fix Alfred M. Szmidt
2022-05-17  8:36 ` Alfred M. Szmidt
2022-05-17 12:02   ` Eli Zaretskii
2022-05-17 18:31   ` Stefan Monnier
2022-05-17 19:10     ` Alfred M. Szmidt
2022-05-17 23:20       ` Dmitry Gutov
2022-05-18  6:34     ` Alfred M. Szmidt [this message]
2022-05-18 11:29       ` Eli Zaretskii
2022-05-19  6:11         ` Alfred M. Szmidt
2022-05-19 14:47           ` Stefan Monnier
2022-05-19  0:05       ` Dmitry Gutov
2022-05-19  6:11         ` Alfred M. Szmidt
2022-05-19  9:25           ` Dmitry Gutov
2022-05-19  9:58             ` Alfred M. Szmidt
2022-05-19 10:24               ` Dmitry Gutov

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=E1nrDGi-0006Q7-Fy@fencepost.gnu.org \
    --to=ams@gnu.org \
    --cc=emacs-devel@gnu.org \
    --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).