emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/pdf-tools 70865fb38d 8/8: Fix: Keep cursor on the same lin


From: ELPA Syncer
Subject: [nongnu] elpa/pdf-tools 70865fb38d 8/8: Fix: Keep cursor on the same line when reopening list of annots
Date: Sat, 10 Jun 2023 16:02:07 -0400 (EDT)

branch: elpa/pdf-tools
commit 70865fb38ddf97023e7d23a7cc8ff22b13b643b0
Author: Pedro Ribeiro Mendes JĂșnior <pedrormjunior@gmail.com>
Commit: Vedang Manerikar <ved.manerikar@gmail.com>

    Fix: Keep cursor on the same line when reopening list of annots
    
    Check if the buffer of the list of annotations already exists. In that
    case, avoid calling `tabulated-list-print` because the call to that
    function makes the cursor move to the beginning of the buffer.
    
    Tested for:
    - the buffer of the list of annotations already exists;
    - a new note is created;
    - that buffer is reopened with the cursor on the same position as
      previous left;
    
    and the newly inserted note appears as expected.
    
    Closes: #211
---
 lisp/pdf-annot.el | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lisp/pdf-annot.el b/lisp/pdf-annot.el
index 078f132cad..344a5c0d27 100644
--- a/lisp/pdf-annot.el
+++ b/lisp/pdf-annot.el
@@ -1722,16 +1722,19 @@ pretty-printed output."
 \\{pdf-annot-list-mode-map}"
   (interactive)
   (pdf-util-assert-pdf-buffer)
-  (let ((buffer (current-buffer)))
-    (with-current-buffer (get-buffer-create
-                          (format "*%s's annots*"
-                                  (file-name-sans-extension
-                                   (buffer-name))))
+  (let* ((buffer (current-buffer))
+         (name (format "*%s's annots*"
+                       (file-name-sans-extension
+                        (buffer-name))))
+         (annots-existed (and (get-buffer name)
+                              pdf-annot-list-buffer)))
+    (with-current-buffer (get-buffer-create name)
       (delay-mode-hooks
         (unless (derived-mode-p 'pdf-annot-list-mode)
           (pdf-annot-list-mode))
         (setq pdf-annot-list-document-buffer buffer)
-        (tabulated-list-print)
+        (unless annots-existed
+          (tabulated-list-print))
         (setq tablist-context-window-function
               (lambda (id) (pdf-annot-list-context-function id buffer))
               tablist-operations-function #'pdf-annot-list-operation-function)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]