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: Mon, 1 May 2023 08:28:55 +0800

On Mon, May 1, 2023 at 3:02 AM Tassilo Horn <tsdh@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > But I found a further problem: If I first opened the PDF file, then it
> > still won't be able to create a new frame dedicated to buffers of
> > LaTeX code, as shown in the attached screenshot.
>
> True.  I didn't know this was a requirement.  Basically you could just
> copy&paste&adapt this code to dedicate a special frame to anything you'd
> like.  But that's left as an excercise to the reader. ;-)

I tried as follows, but still can't achieve the goal:

(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))))

  (defun th/display-buffer-in-my-tex-frame (buffer alist)
    (if-let ((frame (car (seq-filter
                          (lambda (f) (frame-parameter f 'th/tex-frame))
                          (frame-list)))))
    (display-buffer-use-some-frame
     buffer `((frame-predicate . ,(lambda (f)
                    (frame-parameter f 'th/tex-frame)))))
      (display-buffer-pop-up-frame
       buffer (cons
               '(pop-up-frame-parameters (th/tex-frame . t))
               alist))))

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


> Bye,
> Tassilo

Best,
Zhao



reply via email to

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