flexibeast / ebuku

Emacs interface to the buku Web bookmark manager.
92 stars 7 forks source link

Restore cursor line after refresh #20

Closed declantsien closed 3 years ago

declantsien commented 3 years ago

I found it convenient to let ebuku to remember the line info after a refresh. Especially helpful when I am trying to delete a bookmark.

declantsien commented 3 years ago

I found an alternative/cleaner way to resolve my issue without pushing this PR. Closing this one.

(defun ebuku--restore-pos (orig-fun &rest args)
  (let ((scroll-pos (line-number-at-pos (window-start)))
        (cursor-pos (line-number-at-pos))
        (res (apply orig-fun args)))
    (beginning-of-buffer)
    (scroll-up (- scroll-pos 1))
    (goto-line cursor-pos)
    res))
(advice-add 'ebuku--delete-bookmark-sentinel :around #'ebuku--restore-pos)