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: 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 Message-ID: <87ildfdqwu.fsf@gnu.org> References: <87r0s5efab.fsf@frege.mail-host-address-is-not-set> <87edo5bc61.fsf@gnu.org> <87edo52mtg.fsf@gnu.org> <87o7n8jwzw.fsf@gnu.org> <87jzxwjghd.fsf@gnu.org> <87fs8kjedb.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38170"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.11.3; 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 Sat Apr 29 10:39:23 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 1psg71-0009h5-2P for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 29 Apr 2023 10:39:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psg6E-0007gZ-KB; Sat, 29 Apr 2023 04:38:34 -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 1psg6D-0007gQ-F0 for help-gnu-emacs@gnu.org; Sat, 29 Apr 2023 04:38:33 -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 1psg6A-0004It-TU; Sat, 29 Apr 2023 04:38:31 -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=J3VOJ1tAcObgCSkwJF49LVfdwupRSW0EvI6Sn8i56NY=; b=g2XyVExTpABCqJ cnKQE76WzqVuHW81dWsElm+J3+uZWNzQeEKq2yiRhWptR7Exv+fRt0IWoJ2WooKJhK24yKZC6M4Vi ThqH3Wa+x5IEQcFubsJySZc10JlzYG2IMATwjrUBEBNvu3znwd9iV6furLmQCseCL0Xk9XVcSnTy1 yIIaVlKoDdeNANOjnE7nF3zE4hQ7ObhS2fdluJ7/Vn+ZNEPASXbF4VIIVwLQ3dv9nUg88ZllrTcHT sdjeaDkxcuezRg7I8qs7SYWw+2iHmjtSL5r+CUZqNlNT9NNJhrMcqYDpbn0F/EcSRC+3AK6YdLylp pIsPDB45+UPyDsaOSDjg==; 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 1psg6A-000894-Al; Sat, 29 Apr 2023 04:38:30 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailauth.nyi.internal (Postfix) with ESMTP id 29C3727C0054; Sat, 29 Apr 2023 04:38:29 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 29 Apr 2023 04:38:29 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeduledgudefhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpehffgfhvfevufffjgfkgggtsehttdertddtredtnecuhfhrohhmpefvrghs shhilhhoucfjohhrnhcuoehtshguhhesghhnuhdrohhrgheqnecuggftrfgrthhtvghrnh epudejtdehuddvleffjeekteegvdehleehvdeufefhueekkeekhedvgfeggeffvefgnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhrnh domhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqkeeijeefkeejkeegqdeifeeh vdelkedqthhsughhpeepghhnuhdrohhrghesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Feedback-ID: ib2b94485:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 29 Apr 2023 04:38:27 -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:143453 Archived-At: Hongyi Zhao 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