commit 01c0cd8cc3fd3e81d72208a2184bf9b073acda30 from: Omar Polo date: Tue Sep 14 17:49:35 2021 UTC 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. commit - 96b3eb1c8104c73f29849cf445512cc2d7b7be87 commit + 01c0cd8cc3fd3e81d72208a2184bf9b073acda30 blob - 826d72aca67d8b568d7f5d2f864a710d903d2000 blob + c2500bfc0171160c9c829433d0ad9406d659b683 --- vc-got.el +++ 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."