all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Hongyi Zhao <hongyi.zhao@gmail.com>
To: Tassilo Horn <tsdh@gnu.org>
Cc: stefan-husmann@t-online.de, help-gnu-emacs@gnu.org
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:52:13 +0800	[thread overview]
Message-ID: <CAGP6PO+pBMV9dDezhydgBXi22ze2qs=-LRPjbZUA1Ovs3FsiAw@mail.gmail.com> (raw)
In-Reply-To: <CAGP6PO+Mb5L4_ESr3N67atW0AwzAMfkHDtCq3eAGR=FLKDCAhA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4021 bytes --]

On Sun, Apr 30, 2023 at 8:42 AM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> 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:

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.

Regards,
Zhao

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

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 215461 bytes --]

  reply	other threads:[~2023-04-30  0:52 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                           ` How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.) Tassilo Horn
2023-04-29  9:25                             ` 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 [this message]
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='CAGP6PO+pBMV9dDezhydgBXi22ze2qs=-LRPjbZUA1Ovs3FsiAw@mail.gmail.com' \
    --to=hongyi.zhao@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=stefan-husmann@t-online.de \
    --cc=tsdh@gnu.org \
    /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.