all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: Hongyi Zhao <hongyi.zhao@gmail.com>
Cc: stefan-husmann@t-online.de, help-gnu-emacs@gnu.org
Subject: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.)
Date: Sat, 29 Apr 2023 10:30:20 +0200	[thread overview]
Message-ID: <87ildfdqwu.fsf@gnu.org> (raw)
In-Reply-To: <CAGP6POJOYOe81x-d5ySxhp-FdwD-pq4N8Vozd=szk2yMFreSCQ@mail.gmail.com>

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.  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'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.

Bye,
Tassilo



  reply	other threads:[~2023-04-29  8:30 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-25 14:50 use pdf-tools in Emacs Hongyi Zhao
2023-04-25 15:09 ` Rudolf Schlatte
2023-04-26  2:01   ` Hongyi Zhao
2023-04-27 11:23     ` stefan-husmann
2023-04-27 15:02       ` Tassilo Horn
2023-04-27 15:27         ` Hongyi Zhao
2023-04-27 15:53           ` Ruijie Yu via Users list for the GNU Emacs text editor
2023-04-27 23:54             ` Hongyi Zhao
2023-04-27 18:30           ` Tassilo Horn
2023-04-27 23:55             ` Hongyi Zhao
2023-04-28  7:15               ` Tassilo Horn
2023-04-28 10:48                 ` christian de larrinaga via Users list for the GNU Emacs text editor
2023-04-28 12:43                 ` Hongyi Zhao
2023-04-28 13:11                   ` Tassilo Horn
2023-04-28 13:37                     ` Hongyi Zhao
2023-04-28 13:58                       ` Tassilo Horn
2023-04-29  2:17                         ` Hongyi Zhao
2023-04-29  8:30                           ` Tassilo Horn [this message]
2023-04-29  9:25                             ` How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.) Hongyi Zhao
2023-04-29  9:35                               ` Tassilo Horn
2023-04-29 10:08                                 ` Hongyi Zhao
2023-04-29 19:37                                   ` Tassilo Horn
2023-04-30  0:42                                     ` Hongyi Zhao
2023-04-30  0:52                                       ` Hongyi Zhao
2023-04-30 18:59                                         ` Tassilo Horn
2023-05-01  0:28                                           ` Hongyi Zhao
2023-05-01  6:15                                             ` Tassilo Horn
2023-05-01  7:21                                               ` Hongyi Zhao
2023-05-02 18:38                                                 ` Tassilo Horn
2023-05-03  1:45                                                   ` Hongyi Zhao
2023-05-03  2:37                                                     ` Ruijie Yu via Users list for the GNU Emacs text editor
2023-05-03  3:24                                                       ` Hongyi Zhao
2023-05-03  3:38                                                         ` Hongyi Zhao
2023-05-03  7:48                                                     ` Tassilo Horn
2023-05-09  0:03                                                   ` Hongyi Zhao
2023-04-30  1:05                                 ` Hongyi Zhao
2023-05-01 10:09             ` where to get "use-package"? [was: Re: use pdf-tools in Emacs] gebser
2023-05-01 10:30               ` Philip Kaludercic
2023-05-02  0:46                 ` gebser
2023-05-18 14:51   ` use pdf-tools in Emacs Björn Bidar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ildfdqwu.fsf@gnu.org \
    --to=tsdh@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    --cc=hongyi.zhao@gmail.com \
    --cc=stefan-husmann@t-online.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.