From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: How to have a frame dedicated to buffers of a certain kind? (was: use pdf-tools in Emacs.) Date: Tue, 02 May 2023 20:38:42 +0200 Message-ID: <875y9ak17o.fsf@gnu.org> References: <87edo52mtg.fsf@gnu.org> <87o7n8jwzw.fsf@gnu.org> <87jzxwjghd.fsf@gnu.org> <87fs8kjedb.fsf@gnu.org> <87ildfdqwu.fsf@gnu.org> <87fs8jauv0.fsf@gnu.org> <87y1mafo4i.fsf@gnu.org> <87354h9osf.fsf@gnu.org> <878re8h87w.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32059"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.11.4; emacs 30.0.50 Cc: stefan-husmann@t-online.de, help-gnu-emacs@gnu.org To: Hongyi Zhao Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 02 21:01:32 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ptvFk-00089p-Ey for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 02 May 2023 21:01:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ptvF4-0007vR-Sl; Tue, 02 May 2023 15:00:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptvF1-0007v1-PY for help-gnu-emacs@gnu.org; Tue, 02 May 2023 15:00:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptvF1-0003fE-CC; Tue, 02 May 2023 15:00:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-reply-to:Date:Subject:To:From: References; bh=QCcbc1YJrxcEuKVWtEK/frkHRmVDOnaAeoY6xRkfalU=; b=mj6noXuORWjU9B /u9eoLOtZFxR2iomZVnuEjYUOsf45Z9hV9kDLskhjHAU1SLQ6K0z3NJkUbtpOPmJFMCUHTmAY2piu SaqXFPH8cHYVr68+4DNiv4WEc+KGlFuV6P7QzBn3G5SYrNrZjhI7WEufxgthvkuhH5PW8Dw69/Pgc FIVPze+bCtPoWVfIYDP3N2kWm8Kz8a+jBy+kHcpqIfy9WdoSyYILrA3L88/8/Sn+DvPNKnwaucsQ+ tPmRGJXwtW29enL726AmDoGeZSuIZcp2clH4Wzx6KwrGTg2NHnFAObzn1iSSWzt7U3u2Apz3v7Hqc fwZvYE+/hBIU/n4h/iXg==; Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ptvF0-0003C5-Vb; Tue, 02 May 2023 15:00:47 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 5761B27C0054; Tue, 2 May 2023 15:00:46 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 02 May 2023 15:00:46 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedviedgudefvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpehffgfhvfevufffjgfkgggtsehmtderredtredtnecuhfhrohhmpefvrghs shhilhhoucfjohhrnhcuoehtshguhhesghhnuhdrohhrgheqnecuggftrfgrthhtvghrnh epiefhteffieeludefffffkeevgeffheeghfeitedtjeeggfevieeuudevheffffetnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhrnh domhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqkeeijeefkeejkeegqdeifeeh vdelkedqthhsughhpeepghhnuhdrohhrghesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Feedback-ID: ib2b94485:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 2 May 2023 15:00:45 -0400 (EDT) In-reply-to: X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143496 Archived-At: --=-=-= Content-Type: text/plain Hongyi Zhao writes: Hi Zhao, >> 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. > > Please go ahead with the latter and let me test it. It's attached to this mail. I've tested these three scenarios: 1. Start emacs, find tex source and then view it using AUCTeX View command where the last step creates a new pdf-dedicated frame. 2. Start emacs, find pdf document which opens the pdf in a new pdf-dedicated frame. Double-click in the pdf finds the tex source in the other (non-pdf) frame. 3. Start "emacs foo.pdf" which shows the pdf in the initial frame and the code makes sure this frame has the th/pdf-frame parameter. Double-click in the pdf which spawns a new frame showing the tex source. In all three cases I tested forward/backward synctex search which seems to work as you like. But that's the last code for this topic from me. I like helping and giving hints but my spare time is too limited to write ready-made solutions to problems that don't scratch an itch of my own. :-) Also note that my solution or maybe your requirements have their problems: now it's hard to add more rules to display-buffer-alist because for all of them you have to encode the "but, please, not in the pdf-frame" stuff. It's pretty complicated. FWIW, I simply use a large wide frame with a side-by-site split where the tex source is displayed in the left window and the pdf in the right window. That works without any special configuration and isn't less convenient, IMHO. Bye, Tassilo --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=my-pdf-frame.el Content-Transfer-Encoding: quoted-printable ;; -*- lexical-binding: t; -*- (defun th/display-buffer-in-my-pdf-frame (buffer alist) (let ((pred (lambda (f) (frame-parameter f 'th/pdf-frame)))) (if-let ((frame (car (seq-filter pred (frame-list))))) (display-buffer-use-some-frame buffer `((frame-predicate . ,pred))) (display-buffer-pop-up-frame buffer (cons '(pop-up-frame-parameters (th/pdf-frame . t)) alist))))) (defun th/display-buffer-but-not-in-my-pdf-frame (buffer alist) (let ((pred (lambda (f) (and (frame-visible-p f) (null (frame-parameter f 'th/pdf-frame)))))) (if-let ((frame (car (seq-filter pred (frame-list))))) (display-buffer-use-some-frame buffer `((frame-predicate . ,pred))) (display-buffer-pop-up-frame buffer 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)) ;; Non-PDF buffers not in the pdf-frame (add-to-list 'display-buffer-alist `((not (derived-mode . pdf-view-mode)) th/display-buffer-but-not-in-my-pdf-frame)) ;; Make backward search show the tex buffer in another non-PDF frame if it's ;; already shown there. (setq pdf-sync-backward-display-action #'th/display-buffer-but-not-in-my-pd= f-frame) ;; The below hopefully handles the case where emacs is called with the pdf = file ;; from the command line/file manager, so that the inital frame must already ;; get the th/pdf-frame parameter. (defun th/pdf-frame-ensure () (when (and (derived-mode-p 'pdf-view-mode) (null (seq-filter (lambda (f) (frame-parameter f 'th/pdf-frame)) (frame-list)))) (set-frame-parameter (window-frame (get-buffer-window (current-buffer) 'visible)) 'th/pdf-frame t))) (add-hook 'window-setup-hook #'th/pdf-frame-ensure) --=-=-=--