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: Tassilo Horn
Subject: Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.)
Date: Mon, 01 May 2023 08:15:53 +0200
User-agent: mu4e 1.11.4; emacs 30.0.50

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:

Hm, I think a problem might be that when you open the PDF first (and
this actually starts emacs itself), the th/pdf-frame frame parameter
might not be assigned to that frame.  Please verify using M-:
(frame-parameter nil 'th/pdf-frame) RET in that frame.  If it doesn't
return t, then that's the case.  Then you'd somehow need to ensure that
this initial frame gets the parameter, e.g., by adding a function like
this to some reasonable hook:

(defun th/pdf-frame-ensure ()
  (when (and (derived-mode-p 'pdf-view-mode)
             (zerop (length (seq-filter
                             (lambda (f)
                               (frame-parameter f 'th/pdf-frame))
                             (frame-list)))))
    (set-frame-parameter nil 'th/pdf-frame t)))

Unfortunately, I don't know which hook.  pdf-view-mode-hook might run
too early, i.e., the buffer might be set up before displaying it which
eventually will create the frame.  So maybe after-make-frame-functions
is better (but then you'd need to use the frame given as parameter).  I
guess you'll need to do some testing here.

BTW, I wonder if you really want to have a dedicated tex frame or just a
dedicated pdf frame + one editing/normal frame.  If it's actually the
latter, I wouldn't introduce another th/tex-frame parameter but simply
test for (null (frame-parameter frame 'th/pdf-frame)) everywhere.

Bye,
Tassilo



reply via email to

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