[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 17:25:30 +0800 |
On Sat, Apr 29, 2023 at 4:38 PM Tassilo Horn <tsdh@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > I tried the following configuration:
> >
> > (use-package pdf-tools
> > :ensure t
> > :init
> > (pdf-tools-install)
> > :config
> > (add-to-list 'display-buffer-alist
> > '((derived-mode . pdf-view-mode)
> > display-buffer-pop-up-frame))
> >
> > )
> >
> > See the attached screenshot for the effect. In short, frame 1 will
> > open frame 2, and 2 will open 3. But I just want to open frames 1 and
> > 2 and automatically switch between them for forward and backward
> > search.
>
> Ok, if I understand correctly, you basically want one "normal" emacs
> frame and one for viewing pdfs and you want that this separate frame is
> reused.
Yes.
> The below code does the job but probably there's a better
> solution for the "the dedicated frame already exists" part which I
> didn't find during my testing...
>
> My trick is to add a parameter th/pdf-frame to the decicated frame and
> search for that.
>
> --8<---------------cut here---------------start------------->8---
> (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))
> --8<---------------cut here---------------end--------------->8---
I tried with the following configuration, but it still creates 3
frames, as shown in the attchment:
(use-package pdf-tools
:ensure t
:init
(pdf-tools-install)
:config
(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))
)
> I've changed the subject because this has nothing to do with pdf-tools
> anymore but could be applied to any kind of buffers, e.g., others might
> want a separate dericated frame for dired or gnus or whatever. If you
> are lucky, the new subject catches the attention of Martin.
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>
Martin Jerabek <om@mailservice.ms>
Martin Carlson <spearalot@gmail.com>
Martin Joerg <martin.joerg@gmail.com>
Kapuze Martin <m.s.p@posteo.de>
Martin Kletzander <nert.pinx@gmail.com>
Ricardo Martins <ricardo@scarybox.net>
Ricardo Martins <1706+meqif@users.noreply.github.com>
Martin Jesper Low Madsen <martin@martinjlowm.dk>
Agustin Martin Domingo <agustin6martin@gmail.com>
“Martin <“rudalics@gmx.atâ€
> Bye,
> Tassilo
Regards,
Zhao
image.png
Description: PNG image
- Re: use pdf-tools in Emacs., (continued)
- Re: use pdf-tools in Emacs., Tassilo Horn, 2023/04/27
- Re: use pdf-tools in Emacs., Hongyi Zhao, 2023/04/27
- Re: use pdf-tools in Emacs., Tassilo Horn, 2023/04/28
- Re: use pdf-tools in Emacs., christian de larrinaga, 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
- 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 <=
- 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, 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/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