Skip to content

Commit

Permalink
do not change point position for open buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
QiangF committed Aug 15, 2024
1 parent 2d16b2f commit 4fd700b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions bookmark-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ The current buffer must not have a backing file."
(eq bookmark-make-record-function #'bookmark-make-record-default))
`(,(bookmark-buffer-name)
(buffer . ,(buffer-name))
;; save buffer dir for dired-mode buffers
(buffer-dir . ,(if (equal major-mode 'dired-mode)
default-directory nil))
(handler . ,#'bookmark-view-handler-fallback))
(bookmark-make-record)))

Expand Down Expand Up @@ -187,6 +190,36 @@ without overwriting an already existing bookmark."
(defun bookmark-view-open (bm)
"Open view bookmark BM."
(interactive (list (bookmark-view-read "Open view: ")))
;; update point for open buffers
(mapc (lambda (elt)
(if (eq (car-safe elt) 'buffer)
;; create non-existing dired buffer
(mapc (lambda (elt)
(let* ((buffer-alist (cdr elt))
(buffer-cons (assoc 'buffer buffer-alist))
(buffer (and buffer-cons (get-buffer (cdr buffer-cons))))
buffer-dir)
(when buffer
(unless (buffer-live-p buffer)
(when (setq buffer-dir (cdr (assoc 'buffer-dir buffer-alist)))
(dired buffer-dir))))))
(cdr elt))
(when (eq (car-safe elt) 'window)
(mapc (lambda (elt)
(when (eq (car-safe elt) 'leaf)
(mapc (lambda (elt)
(when (eq (car-safe elt) 'buffer)
(let ((buffer (get-buffer (nth 1 elt))))
(when (buffer-live-p buffer)
(with-current-buffer buffer
(mapc (lambda (elt)
(when (eq (car-safe elt) 'point)
(setcdr elt (point))))
(cddr elt)))))))
(cdr elt))))
(cdr elt))
(cdr elt))))
(cdr (bookmark-get-bookmark bm)))
(bookmark-jump bm #'ignore))

;;;###autoload
Expand Down

0 comments on commit 4fd700b

Please sign in to comment.