GNU bug report logs - #77529
31.0.50; [Feature Request][VC] How can I get the current revision of the buffer opened by =vc-find-revision=?

Previous Next

Package: emacs;

Reported by: jixiuf <jixiuf <at> qq.com>

Date: Fri, 4 Apr 2025 04:26:01 UTC

Severity: wishlist

Found in version 31.0.50

Done: Sean Whitton <spwhitton <at> spwhitton.name>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: jixiuf <jixiuf <at> qq.com>
Subject: bug#77529: closed (Fixed by vc-buffer-overriding-fileset,
 vc-buffer-revision changeset)
Date: Fri, 11 Apr 2025 03:54:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#77529: 31.0.50; [Feature Request][VC] How can I get the current revision of the buffer opened by =vc-find-revision=?

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 77529 <at> debbugs.gnu.org.

-- 
77529: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77529
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Sean Whitton <spwhitton <at> spwhitton.name>
To: 5424-done <at> debbugs.gnu.org, 77529-done <at> debbugs.gnu.org
Subject: Fixed by vc-buffer-overriding-fileset, vc-buffer-revision changeset
Date: Fri, 11 Apr 2025 11:53:04 +0800
Version 31.1

These should now be fixed on master.

-- 
Sean Whitton

[Message part 3 (message/rfc822, inline)]
From: jixiuf <jixiuf <at> qq.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; [Feature Request][VC] How can I get the current revision
 of the buffer opened by =vc-find-revision=?
Date: Fri, 04 Apr 2025 12:09:47 +0800
How can I retrieve the current revision when I'm in a buffer opened by
=vc-find-revision= ?

I'm attempting to write two commands: =vc-next-revision= and
=vc-prev-revision=, similar to =magit-blob-next= and
=magit-blob-previous=.

Currently, I obtain the revision from the buffer name (which might
support Git), but I don't consider this to be the best approach. Should
we add a local variable called =vc-revision=, similar to
=vc-parent-buffer=?

Alternatively, should Emacs implement =vc-next-revision= and
=vc-prev-revision= directly in =vc.el=?

----------------------------------

;;;###autoload
(defun vc-next-revision ()
  "Visit the next revision which modified the current file."
  (interactive)
  (let* ((buffname (buffer-name))
         (prev-buffer (current-buffer))
         (parent-buffer vc-parent-buffer)
         (fileset-arg (vc-deduce-fileset nil t))
         (backend (car fileset-arg))
         (filename (car (cadr fileset-arg)))
         rev next)
    (when parent-buffer
      ;; FIXME: support other bankend for find rev?
      (when (string-match "^\\([^~]+?\\)\\(?:\\.~\\([^~]+\\)~\\)?$" buffname)
        (setq rev (match-string 2 buffname)))
      (setq next (vc-call-backend backend 'next-revision
                                  filename rev))
      (kill-buffer prev-buffer)
      (if next
          (switch-to-buffer (vc-find-revision filename next))
        (find-file filename)
        (user-error "vc timemachine: You have reached the end of time")))))
;;;###autoload
(defun vct-prev-revision ()
  "Visit the prev revision which modified the current file."
  (interactive)
  (let* ((buffname (buffer-name))
         (cur-buffer (current-buffer))
         (parent-buffer vc-parent-buffer)
         (fileset-arg (vc-deduce-fileset nil t))
         (backend (car fileset-arg))
         (filename (car (cadr fileset-arg)))
         rev prev)
    ;; FIXME: support other bankend for find rev?
    (when (string-match "^\\([^~]+?\\)\\(?:\\.~\\([^~]+\\)~\\)?$" buffname)
      (setq rev (match-string 2 buffname)))
    (if rev
        (setq prev (vc-call-backend backend 'previous-revision
                                    filename rev))
      (setq prev (vc-short-revision filename)))
    (if prev
        (progn  (switch-to-buffer (vc-find-revision filename prev))
                (when parent-buffer (kill-buffer cur-buffer)))
      (user-error "vc timemachine: You have reached the beginning of time"))))





This bug report was last modified 93 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.