From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#38354: 27.0.50; Implement display action display-buffer-in-tab Date: Wed, 27 Nov 2019 23:37:48 +0200 Organization: LINKOV.NET Message-ID: <87d0dd3yb7.fsf@mail.linkov.net> References: <87imna2nsi.fsf@mail.linkov.net> <8736ea5kcz.fsf@mail.linkov.net> <7979be54-2a01-2e97-d956-2500e7999e26@gmx.at> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="259210"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 38354@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 27 22:58:49 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ia5Kh-0015Dl-Ey for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Nov 2019 22:58:47 +0100 Original-Received: from localhost ([::1]:43568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia5Kf-0002DX-Uu for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Nov 2019 16:58:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52013) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia5J3-00010d-20 for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2019 16:57:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ia5J1-0002G9-Hx for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2019 16:57:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50342) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ia5J1-0002Fg-D9 for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2019 16:57:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ia5J1-0008AU-CT for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2019 16:57:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Nov 2019 21:57:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38354 X-GNU-PR-Package: emacs Original-Received: via spool by 38354-submit@debbugs.gnu.org id=B38354.157489178931307 (code B ref 38354); Wed, 27 Nov 2019 21:57:03 +0000 Original-Received: (at 38354) by debbugs.gnu.org; 27 Nov 2019 21:56:29 +0000 Original-Received: from localhost ([127.0.0.1]:56307 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ia5IS-00088t-Um for submit@debbugs.gnu.org; Wed, 27 Nov 2019 16:56:29 -0500 Original-Received: from chocolate.birch.relay.mailchannels.net ([23.83.209.35]:62544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ia5IQ-00088k-Ca for 38354@debbugs.gnu.org; Wed, 27 Nov 2019 16:56:27 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 37BF93C13F7; Wed, 27 Nov 2019 21:56:25 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a94.g.dreamhost.com (100-96-15-77.trex.outbound.svc.cluster.local [100.96.15.77]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 83E573C1311; Wed, 27 Nov 2019 21:56:24 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a94.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.5); Wed, 27 Nov 2019 21:56:25 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Rock-Troubled: 1d21e845767e2a2d_1574891785031_1556687824 X-MC-Loop-Signature: 1574891785031:3222463399 X-MC-Ingress-Time: 1574891785030 Original-Received: from pdx1-sub0-mail-a94.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a94.g.dreamhost.com (Postfix) with ESMTP id 4496E9C453; Wed, 27 Nov 2019 13:56:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=sFMoOEq0CaslygTkn9GCdcFEcYQ=; b= zqAJfg+2tnBLRmQO8DIGyRvSG6mnVmVEB7aWSF7YF5DAlc+xOp5QQ1xU8XUC+UlW y107SNmuPQxr4B17/6n3oRGqHxl0ZJPrg9dAIbpuW9f7dPGsk2ZmqpgwJcDz4NpR kzdJbMK2m7H9e6BUfOJdh0meXwa1kq5sU6LRMxSQbDg= Original-Received: from mail.jurta.org (m91-129-96-42.cust.tele2.ee [91.129.96.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a94.g.dreamhost.com (Postfix) with ESMTPSA id 650A49C458; Wed, 27 Nov 2019 13:56:16 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a94 In-Reply-To: <7979be54-2a01-2e97-d956-2500e7999e26@gmx.at> (martin rudalics's message of "Wed, 27 Nov 2019 10:49:17 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:172564 Archived-At: >> display-buffer-in-tab is implemented now, but we need also an action >> to display the buffer in an existing tab if such buffer is >> already displayed in it. > > Could we please clarify the term "display(ed)" in this context. IIUC > you use it > > - to say that a buffer is part of a tab (a window configuration that > can be shown on a frame), and In my code I use for this: (tab-bar-buffer-visible-in-tabs-p buffer) > - to say that a buffer is actually displayed on a frame that has a > tab-bar. In my code I use for this: (>= (length (get-buffer-window-list buffer t t)) 1) i.e. I check these situations differently, and use 'or' to combine these conditions: (or (>= (length (get-buffer-window-list buffer t t)) 1) (tab-bar-buffer-visible-in-tabs-p buffer)) Should these conditions be combined in one function (if the current tab can be considered a tab as well)? > Right? Then the former should not use the term "display(ed)" but > maybe something like "tab(bed)". "Tab a buffer" would then mean to > make sure that the buffer is part of a tab, "tabbed" that it is part > of at least one tab. Not sure if "tabbed" is the right word. None of these definitions fits: https://www.dictionary.com/browse/tabbed https://www.urbandictionary.com/define.php?term=tabbed >> This will require a new function function tab-bar-buffer-visible-in-tabs. > > What would "visible" precisely stand for here? Maybe a better word is "has"? Then the name would be tab-bar-has-buffer-in-tab. > And why "tabs" indiscriminately? Don't you ever want to check for > presence or visibility in a specific tab only? A specific tab referred by name? Maybe such function could be useful as well. But currently there is need for a function that returns a tab that has the given buffer: diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 5eb332884c..7746c59f17 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1284,6 +1284,13 @@ display-buffer-in-tab +(defun tab-bar-has-buffer-in-tab (buffer) + "Return a tab that has the buffer BUFFER." + (seq-some (lambda (tab) + (when (memq buffer (window-state-buffers (cdr (assq 'ws tab)))) + tab)) + (funcall tab-bar-tabs-function))) >> I tried to copy an existing action >> that supports frames, but can't find such a frame action that >> would select another frame if the buffer is already is displayed in it. >> Does such frame action exist whose behavior could be copied to tabs? > > 'display-buffer-reuse-window' together with 'reusable-frames' should > have all the ingredients for this. What is missing? Than we need to add 'reusable-tabs'? >> Also I use this function in a wrapper that kills the buffer, such wrapper checks >> >> (tab-bar-buffer-visible-in-tabs-p (current-buffer)) >> >> If true, it doesn't kill the buffer, but buries it. > > Via 'kill-buffer-query-functions'? Rather calling it explicitly with a new commands, but it should be possible to use 'kill-buffer-query-functions' too. >> So switching back to that tab still displays the buffer. > > When I do 'kill-buffer', I expect that buffer to get removed from > 'buffer-list' and all windows showing it, that it won't be switched to > by many functions and so on. Whatever we'd do, we have to manage this > controversy somehow. Think of changes or the deletion of the visited > files. How would we try to avoid saving such buffers to their files > in that case? A buffer can't be removed from saved window-configurations and window-states.