Skip to content

Commit

Permalink
Accommodate Emacs 26
Browse files Browse the repository at this point in the history
If `window-buffer-change-functions` isn't bound fallback
to `bookmark-after-jump-hook`.

The window argument for the inserted hook is optional to
accommodate both cases.
  • Loading branch information
Rahguzar committed Jan 24, 2023
1 parent 5005096 commit a9ee1fb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lisp/pdf-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -1663,11 +1663,15 @@ See also `pdf-view-bookmark-make-record'."
(file (bookmark-prop-get bmk 'filename))
(buf (or (find-buffer-visiting file)
(find-file-noselect file)))
(buf-chg-fns-p (boundp 'window-buffer-change-functions))
(hook (if buf-chg-fns-p
'window-buffer-change-functions
'bookmark-after-jump-hook))
(show-fn-sym (make-symbol "pdf-show-buffer-function")))
(fset show-fn-sym
(lambda (win)
(with-current-buffer buf
(remove-hook 'window-buffer-change-functions show-fn-sym t)
(lambda (&optional win)
(when (eq buf (current-buffer))
(remove-hook hook show-fn-sym buf-chg-fns-p)
(unless (derived-mode-p 'pdf-view-mode)
(pdf-view-mode))
(when size
Expand All @@ -1687,7 +1691,7 @@ See also `pdf-view-bookmark-make-record'."
1
(frame-char-height))))))))))
(set-buffer buf)
(add-hook 'window-buffer-change-functions show-fn-sym nil t)))
(add-hook hook show-fn-sym nil buf-chg-fns-p)))

(defun pdf-view-bookmark-jump (bmk)
"Switch to bookmark BMK.
Expand Down

0 comments on commit a9ee1fb

Please sign in to comment.