[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vc-got 01c0cd8 3/3: annotate-time: drop save-excursion,
From: |
ELPA Syncer |
Subject: |
[elpa] externals/vc-got 01c0cd8 3/3: annotate-time: drop save-excursion, explain why looking-at |
Date: |
Tue, 14 Sep 2021 13:57:23 -0400 (EDT) |
branch: externals/vc-got
commit 01c0cd8cc3fd3e81d72208a2184bf9b073acda30
Author: Omar Polo <op@omarpolo.com>
Commit: Omar Polo <op@omarpolo.com>
annotate-time: drop save-excursion, explain why looking-at
The (save-excursion (beginning-of-line) ...) bit is not needed, as the
VC interface guarantees us that the point is at the right place before
each invocation.
While there, add an explanation for the `looking-at' usage: ideally we
should use `re-search-forward' (which moves the cursor too) but
produces an ugly result. It's the second time I'm stumbling on this
and wasting time, so the note is warranted.
---
vc-got.el | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/vc-got.el b/vc-got.el
index 826d72a..c2500bf 100755
--- a/vc-got.el
+++ b/vc-got.el
@@ -806,15 +806,18 @@ Provides capture group for the commit revision id.")
(defun vc-got-annotate-time ()
"Return the time of the next line of annotation at or after point.
Value is returned as floating point fractional number of days."
- (save-excursion
- (beginning-of-line)
- (when (looking-at vc-got--annotate-re)
- (let ((str (match-string-no-properties 2)))
- (vc-annotate-convert-time
- (encode-time 0 0 0
- (string-to-number (substring str 8 10))
- (string-to-number (substring str 5 7))
- (string-to-number (substring str 0 4))))))))
+ ;; XXX: to behave like vc-git here we should call re-search-forward
+ ;; instead of looking-at, as it makes the fontification of the line
+ ;; start AFTER the info. The problem is, due to the format of the
+ ;; blame, it produces an ugly result, with colors starting at
+ ;; different offsets depending on how long the commiter name is.
+ (when (looking-at vc-got--annotate-re)
+ (let ((str (match-string-no-properties 2)))
+ (vc-annotate-convert-time
+ (encode-time 0 0 0
+ (string-to-number (substring str 8 10))
+ (string-to-number (substring str 5 7))
+ (string-to-number (substring str 0 4)))))))
(defun vc-got-annotate-extract-revision-at-line ()
"Return revision corresponding to the current line or nil."