Skip to content

Commit

Permalink
Fix: Keep cursor on the same line when reopening list of annots
Browse files Browse the repository at this point in the history
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: vedang#211
  • Loading branch information
pedrormjunior authored and vedang committed Jun 10, 2023
1 parent 0822f43 commit 70865fb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lisp/pdf-annot.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 70865fb

Please sign in to comment.