[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to have a frame dedicated to buffers of a certain kind? (was: us
From: |
Hongyi Zhao |
Subject: |
Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.) |
Date: |
Sun, 30 Apr 2023 08:42:42 +0800 |
On Sun, Apr 30, 2023 at 4:08 AM Tassilo Horn <tsdh@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > And this time the 3rd circle numbered window will be used to display
> > the LaTeX code and PDF alternately when I do the forward and backward
> > searching. This is not the result we hope to see.
>
> Here's a slightly improved version:
>
> (defun th/display-buffer-in-my-pdf-frame (buffer alist)
> (if-let ((frame (car (seq-filter
> (lambda (f) (frame-parameter f 'th/pdf-frame))
> (frame-list)))))
> (display-buffer-use-some-frame
> buffer `((frame-predicate . ,(lambda (f)
> (frame-parameter f 'th/pdf-frame)))))
> (display-buffer-pop-up-frame
> buffer (cons
> '(pop-up-frame-parameters (th/pdf-frame . t))
> alist))))
>
> ;; PDFs in a dedicated pdf frame.
> (add-to-list 'display-buffer-alist
> `((derived-mode . pdf-view-mode)
> th/display-buffer-in-my-pdf-frame))
>
> The problem remains that when double-clicking in the pdf-view-mode
> buffer to jump to the corresponding position in the tex file, the tex
> file buffer appears in a new window of the pdf frame. The issue is that
> pdf-tools uses pop-to-buffer here:
>
> (defun pdf-sync-backward-search (x y)
> "Go to the source corresponding to image coordinates X, Y.
>
> Try to find the exact position, if
> `pdf-sync-backward-use-heuristic' is non-nil."
> (cl-destructuring-bind (source finder)
> (pdf-sync-backward-correlate x y)
> (pop-to-buffer (or (find-buffer-visiting source)
> (find-file-noselect source))
> pdf-sync-backward-display-action)
> (push-mark)
> (funcall finder)
> (run-hooks 'pdf-sync-backward-hook)))
>
> But there you go! You can define a pdf-sync-backward-display-action to
> make it work.
>
> (setq pdf-sync-backward-display-action
> '(display-buffer-reuse-window (reusable-frames . t)))
Thank you for your wonderful tricks/tips/codes once more. This time,
it can work perfectly according to the intention discussed here using
the following configuration:
(use-package pdf-tools
:ensure t
:init
(pdf-tools-install)
(setq pdf-sync-backward-display-action
'(display-buffer-reuse-window (reusable-frames . t)))
(defun th/display-buffer-in-my-pdf-frame (buffer alist)
(if-let ((frame (car (seq-filter
(lambda (f) (frame-parameter f 'th/pdf-frame))
(frame-list)))))
(display-buffer-use-some-frame
buffer `((frame-predicate . ,(lambda (f)
(frame-parameter f 'th/pdf-frame)))))
(display-buffer-pop-up-frame
buffer (cons
'(pop-up-frame-parameters (th/pdf-frame . t))
alist))))
;; PDFs in a dedicated pdf frame.
(add-to-list 'display-buffer-alist
`((derived-mode . pdf-view-mode)
th/display-buffer-in-my-pdf-frame))
)
> You can read up how that all works in (info "(elisp) Displaying
> Buffers").
Thank you for hints. But the Elisp code you mentioned requires a
significant level of proficiency in Elisp programming. Even if I
understand the underlying mechanics of the problem being discussed, it
may still be challenging to write the corresponding code
implementation without a strong foundation in Elisp.
> Bye,
> Tassilo
Best,
Zhao
image.png
Description: PNG image
- Re: use pdf-tools in Emacs., (continued)
- Re: use pdf-tools in Emacs., Hongyi Zhao, 2023/04/28
- Re: use pdf-tools in Emacs., Tassilo Horn, 2023/04/28
- Re: use pdf-tools in Emacs., Hongyi Zhao, 2023/04/28
- Re: use pdf-tools in Emacs., Tassilo Horn, 2023/04/28
- Re: use pdf-tools in Emacs., Hongyi Zhao, 2023/04/28
- How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.), Tassilo Horn, 2023/04/29
- Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.), Hongyi Zhao, 2023/04/29
- Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.), Tassilo Horn, 2023/04/29
- Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.), Hongyi Zhao, 2023/04/29
- Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.), Tassilo Horn, 2023/04/29
- Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.),
Hongyi Zhao <=
- Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.), Hongyi Zhao, 2023/04/29
- Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.), Tassilo Horn, 2023/04/30
- Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.), Hongyi Zhao, 2023/04/30
- Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.), Hongyi Zhao, 2023/04/29