Subject: bug#35624: log-view-diff regression

From: Juri Linkov <[email-masked]>
Date: Fri, 24 May 2019 00:07:25 +0300

>> Maybe just set window-start to the first non-empty line initially,
>> thus moving the empty line out of screen?
>
> Thought about this too. Could work, but the fact that it's not easy to
> "undo" the view if you pressed 'C-p' accidentally is a downside.

"undo" is a minuscule issue, or rather a non-issue at all,
whereas the idea is good.  Created a feature request bug#35860

>>> If you really must have it this way, do we have an example of invisible
>>> text expanding when cursor moves inside, and then contracting when it's out
>>> again? Meaning if would look like an empty line you wanted after you press
>>> 'C-p', but not visible at all otherwise.
>>
>> Yes, this is possible:
>
> It almost works fine, but going from the second log entry to the first with
> 'p' while at bol leads to the first (empty) line becoming visible.

Asked about this in http://lists.gnu.org/archive/html/emacs-devel/2019-05/msg00827.html
and the answer was to use reveal-mode.

> BTW, if we implement this, here's something we could add as well:
>
> Instead of the empty line, how about it will contain some quick help string
> for the 'd' command, so that the user is not too puzzled if they hit 'C-p'
> by accident?

Good idea, added too:

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index b6feb3b8d1..1637f1106f 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1018,7 +1018,10 @@ vc-git-print-log
     ;; read-only.
     (let ((inhibit-read-only t))
       (with-current-buffer buffer
-	(insert "\n")
+        (overlay-put (make-overlay (point) (progn (insert (propertize "\n" 'help-echo
+          "You can use `d' on the top empty line to compare with the current working revision"))
+          (point)))
+          'invisible t)
 	(apply 'vc-git-command buffer
 	       'async files
 	       (append
@@ -1122,7 +1125,8 @@ vc-git-log-view-mode
 	     (1 'change-log-acknowledgment)
 	     (2 'change-log-acknowledgment))
 	    ("^Date:   \\(.+\\)" (1 'change-log-date))
-	    ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))))
+	    ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message))))))
+  (reveal-mode 1))

 (defun vc-git-show-log-entry (revision)