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
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
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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.