help-gnu-emacs
[Top][All Lists]
Advanced

[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: Sat, 29 Apr 2023 18:08:20 +0800

On Sat, Apr 29, 2023 at 5:41 PM Tassilo Horn <tsdh@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > I tried with the following configuration, but it still creates 3
> > frames, as shown in the attchment:
>
> There are only two frames in the screenshot, what you have numbered are
> emacs windows.  But yes, the 2nd pdf buffer should have been displayed
> in the other frame where a pdf is already displayed.  You might have to
> edebug the function and check M-: (frame-parameter nil 'th/pdf-frame)
> RET in both frames.  Only the one spawned by the first "show this pdf
> buffer" should have this parameter set.
>
> BTW, I wouldn't put the function and display-buffer-alist setting in the
> :config section of (use-package pdf-tools ...) but top-level.  It might
> have been loaded too late.  Maybe try that and restart emacs.

Tried as follows:

(use-package pdf-tools
  :ensure t
  :init
  (pdf-tools-install)
  (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)))))
    ;; TODO: I guess there's a better way for this case, i.e., something with
    ;; invoking display-buffer with reusable-frames parameter or something.
    (progn
          (select-frame frame)
          (switch-to-buffer buffer))
      (display-buffer-pop-up-frame
       buffer (cons
               '(pop-up-frame-parameters (th/pdf-frame . t))
               alist))))

  (add-to-list 'display-buffer-alist
               `((derived-mode . pdf-view-mode)
         th/display-buffer-in-my-pdf-frame))

)

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.

> > Which Martin? I checked as follows and there are many:
> >
> > werner@X10DAi:~/Public/repo/git.savannah.gnu.org/git/emacs.git$ git
> > log --format='%an <%ae>' | grep -i martin | awk '!a[$0]++'
> > Martin Rudalics <rudalics@gmx.at>
> > martin rudalics <rudalics@gmx.at>
>
> These two Martins. :-)
>
> Bye,
> Tassilo

Best,
Zhao

Attachment: image.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]