From unknown Fri Aug 15 02:02:02 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#41342 <41342@debbugs.gnu.org> To: bug#41342 <41342@debbugs.gnu.org> Subject: Status: tab-bar-mode: Add context menu when right-clicking tab Reply-To: bug#41342 <41342@debbugs.gnu.org> Date: Fri, 15 Aug 2025 09:02:02 +0000 retitle 41342 tab-bar-mode: Add context menu when right-clicking tab reassign 41342 emacs submitter 41342 Stefan Kangas severity 41342 wishlist tag 41342 patch fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Sun May 17 00:00:26 2020 Received: (at submit) by debbugs.gnu.org; 17 May 2020 04:00:26 +0000 Received: from localhost ([127.0.0.1]:42035 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaATS-0007am-9Z for submit@debbugs.gnu.org; Sun, 17 May 2020 00:00:26 -0400 Received: from lists.gnu.org ([209.51.188.17]:52022) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaATR-0007af-AO for submit@debbugs.gnu.org; Sun, 17 May 2020 00:00:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaATQ-0002sg-S6 for bug-gnu-emacs@gnu.org; Sun, 17 May 2020 00:00:25 -0400 Received: from mail-yb1-xb32.google.com ([2607:f8b0:4864:20::b32]:33004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaATP-0003CZ-EY for bug-gnu-emacs@gnu.org; Sun, 17 May 2020 00:00:24 -0400 Received: by mail-yb1-xb32.google.com with SMTP id b8so3413308ybn.0 for ; Sat, 16 May 2020 21:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:date:message-id:subject:to; bh=X7+6LYDPt6z4f+AS0S8Cb1BLt9wgCV+w3hePASOJXCI=; b=Ei++JKAqaRQVfsAkRjj/8PeJpiR3l63L9mPhWcU+9q5o6vy4owyZmkZHZryqslGiDR FUK/iUicy0KOAFC9qG0lfFZzW9/1j5qQ1WaeHODlNdH4naGVb/rJGYfwbqH08a+hMDEb aD7Ht7/RgdtMumthGs1HRGzxOCrvMnVD10G6VzmYxU0/NJmhIq5wN+M52H8O7NH0OE15 6C1WGrQqmt09cafKLLYiaH2Ua9T+dcutX6S/ARXzwKRsawB8V1Zjl0DJef2DAsrKde7H gKLTiRSgp3Y2bF0kuoiLBaNxXegerrojVac3Ny5NxMN2oSmVTb2T+IA4jhVYwWCFrdkW fTgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:date:message-id:subject:to; bh=X7+6LYDPt6z4f+AS0S8Cb1BLt9wgCV+w3hePASOJXCI=; b=YYG5SgVTpZTpoosVV0wsqDGnZImgL57xr5XWNAe8UeVSprvlIkKbsgV0pUhkewOGZZ AVB762hb7vxx4CSdDcbiRVCG6092YM3c/C1XrjZ4PJ6LldEqgZr39G1t81QcbBAOq1zd 8VqjAmGw4hcVcCyUSdNHm0KvbxdC/CdAJBwEa/QesprFHukbWpnl5ftimrRjPGF0w2/I IWcsCaqvZ8PRzPIl1Bqgvh9s7uOxrDS2tl+Q1q7XvO3SpzZiiqJ7C05dBC9J5iBkP2Wi Pv4h9nbKivkBQpimeC9roPhIjDm6fmmvnugPv6xAEKQxYbxLHtNQFknKxetrIKtWnkuN +8jg== X-Gm-Message-State: AOAM530McicNNyaNCah1DXbE1RJfxjHCcY7BkQ4pBVSZxhn1XhWQ9J94 thZu61C5b4/egzG23/aDWum4CwVAt1VuJ9/gAP7UaA== X-Google-Smtp-Source: ABdhPJydb6ydhdAMBPibcUzBoT2gc/9MUNRQW8a3yiBAhElwp/kmq3ZirHaMlBVzaXw5N9q6HoZAKMInx+TF9iB11v4= X-Received: by 2002:a25:9304:: with SMTP id f4mr5000934ybo.309.1589688021554; Sat, 16 May 2020 21:00:21 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 16 May 2020 21:00:21 -0700 From: Stefan Kangas MIME-Version: 1.0 Date: Sat, 16 May 2020 21:00:21 -0700 Message-ID: Subject: Add context menu when right-clicking tab in tab-bar-mode To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::b32; envelope-from=stefankangas@gmail.com; helo=mail-yb1-xb32.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Severity: wishlist Please consider adding a context menu to tab-bar-mode shown when clicking a tab. This could including actions such as: - Close tab - Close other tabs - Duplicate tab Inspired by Firefox, one could also imagine. - Move tab - Move to Start (of list) - Move to End - Move to New Frame Best regards, Stefan Kangas From debbugs-submit-bounces@debbugs.gnu.org Sun May 17 18:14:57 2020 Received: (at 41342) by debbugs.gnu.org; 17 May 2020 22:14:57 +0000 Received: from localhost ([127.0.0.1]:45000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaRYf-0005x1-AA for submit@debbugs.gnu.org; Sun, 17 May 2020 18:14:57 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:49045) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaRYb-0005wF-MM for 41342@debbugs.gnu.org; Sun, 17 May 2020 18:14:54 -0400 X-Originating-IP: 91.129.104.245 Received: from mail.gandi.net (m91-129-104-245.cust.tele2.ee [91.129.104.245]) (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 9B35FFF805; Sun, 17 May 2020 22:14:46 +0000 (UTC) From: Juri Linkov To: Stefan Kangas Subject: Re: bug#41342: Add context menu when right-clicking tab in tab-bar-mode Organization: LINKOV.NET References: Date: Mon, 18 May 2020 01:09:47 +0300 In-Reply-To: (Stefan Kangas's message of "Sat, 16 May 2020 21:00:21 -0700") Message-ID: <87tv0egqms.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 41342 Cc: 41342@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > Please consider adding a context menu to tab-bar-mode shown when > clicking a tab. This could including actions such as: Does you mean clicking the right button, i.e. ? > - Close tab > - Close other tabs > - Duplicate tab > > Inspired by Firefox, one could also imagine. > > - Move tab > - Move to Start (of list) > - Move to End > - Move to New Frame Good idea. When someone will find a way to emit the event on the tab-bar, I'll immediately bind it to the context menu. From debbugs-submit-bounces@debbugs.gnu.org Sun May 17 18:23:56 2020 Received: (at 41342) by debbugs.gnu.org; 17 May 2020 22:23:56 +0000 Received: from localhost ([127.0.0.1]:45024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaRhM-0006HH-6a for submit@debbugs.gnu.org; Sun, 17 May 2020 18:23:56 -0400 Received: from mail-yb1-f175.google.com ([209.85.219.175]:33361) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaRhL-0006Gt-Ed for 41342@debbugs.gnu.org; Sun, 17 May 2020 18:23:55 -0400 Received: by mail-yb1-f175.google.com with SMTP id g79so672126ybf.0 for <41342@debbugs.gnu.org>; Sun, 17 May 2020 15:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:in-reply-to:references:mime-version:date:message-id:subject:to :cc; bh=tUj0CZCXNKh2rYfY7lb0xPenbxGqyX7RDenZcV83j+M=; b=anyrkAoCJ7fgCOwt1JlxlD+bOhZMnxAQx5jF3/xTnxqZCutGCt0rDfVUNv20jSj5H+ 7bc5a+llPLbz5CNc0SYdlErlV5DCajUdLoZxikUTgS/Zwcz5j9gbgkem8Lkl5KN/Iry+ i9szIrvuBYpcTxvyRq8v9b51tc/tJcBV/rlesjyWmAz5iSXkLtkhn9GXP9H9qruAX54m qZO4roWM91gXySkoU5snCHg82YOauPEvQY1pCAnnvWASmedIeQbLuXPt8tQtHwvKDyZo 8YCA8qx6vjGqAlc4TZvzCBVO1U6pnTz01RHiXvSMHh5n1bY0T3TP+zpGfX1n/CVdP15S +jrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc; bh=tUj0CZCXNKh2rYfY7lb0xPenbxGqyX7RDenZcV83j+M=; b=nNiig4p2yX3bJGRPqonHtXO2ZQa4D7bqJ9B5CGTfvIK/aKvAnQUXcxA1S0X88wN3yD hwmFoBzKIK2wQZSQdgHsOBQOceOV8vvXammjjdZkpTeD7Jeqzk8cFkgyGwbiYQnQ7Ehb ZlQ2PNk4u9cP7A6NZj/TpqTS8SCZG5bX5yx1M0Qv9+dkGEPY80ylVROtwmvCP2EDhyAN v7bhI5AZjepO2M4QosUBAO/bSKCfPJx1viHW66eYEoN6yPvyZV9FnQ8rxpObozLWuu8D dfUviyoKTqhlkW/DggApihGY76ANt3KVBSVR1CY0Kmg1PJSsRwv7RBhqC12X3XHpXWLS sOlw== X-Gm-Message-State: AOAM531aojVH9kITpmofYwc+niqAWmnbl2iy/A7FeQ505XQnEhhpTwIc mO9MLMsgNjZsKZLQxY9+W23f8sLTvb7p1wGPIVWMGQ== X-Google-Smtp-Source: ABdhPJweeBHsFHISqWrniT+04DxsF/J6MRUwaBcvC4XHKJJ3nlBkcfOGiKDf3GULzKHd+8gNOd6hajSZOesCAuP8ffs= X-Received: by 2002:a25:4c04:: with SMTP id z4mr20880501yba.466.1589754229817; Sun, 17 May 2020 15:23:49 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 17 May 2020 15:23:49 -0700 From: Stefan Kangas In-Reply-To: <87tv0egqms.fsf@mail.linkov.net> References: <87tv0egqms.fsf@mail.linkov.net> MIME-Version: 1.0 Date: Sun, 17 May 2020 15:23:49 -0700 Message-ID: Subject: Re: bug#41342: Add context menu when right-clicking tab in tab-bar-mode To: Juri Linkov Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41342 Cc: 41342@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: >> Please consider adding a context menu to tab-bar-mode shown when >> clicking a tab. This could including actions such as: > > Does you mean clicking the right button, i.e. ? Yes, I failed to mention that. > Good idea. When someone will find a way to emit the event > on the tab-bar, I'll immediately bind it to the context menu. Thanks! Best regards, Stefan Kangas From debbugs-submit-bounces@debbugs.gnu.org Sun May 17 18:29:17 2020 Received: (at control) by debbugs.gnu.org; 17 May 2020 22:29:18 +0000 Received: from localhost ([127.0.0.1]:45043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaRmX-0006Sx-Pl for submit@debbugs.gnu.org; Sun, 17 May 2020 18:29:17 -0400 Received: from mail-yb1-f171.google.com ([209.85.219.171]:37712) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaRmW-0006Sj-H2 for control@debbugs.gnu.org; Sun, 17 May 2020 18:29:16 -0400 Received: by mail-yb1-f171.google.com with SMTP id b123so2106648yba.4 for ; Sun, 17 May 2020 15:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:date:message-id:subject:to; bh=dMCMLIRHcZgqkVAmKgFTTcuZH91XPl1/h68tftu83fQ=; b=SulIGt3h8o5YtHlhkzg8abxoD1VtMn9nd2S2rCFlwSYH3vzbVYlYlOBUEBsp90u9Mx l+s523/glN6AbNPnlRsZqcNsQvGGfc2tdfJiMMCZ3eDnEiL9m4I0IxRyM/TaMpe53pNA PGzrg9pSvlE0+rYjb7rN99ivOJtONpPVxlV9lmMqqCumrlBr48wXOXsyvb7Eb+Qwo81t 3TT2rxK1OBLwv/gjExthcDMj4YNpXxiV9iBiHr71fJB5Vcig+AvxeZ9A1XJFl8v1cCXN BFrFWsVxuyI/vW5DSgk2UXhotv1+eWV7ZUcTaH0SFSHzabMDmitrjgJYMuVRduJZVc5R 3ikQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:date:message-id:subject:to; bh=dMCMLIRHcZgqkVAmKgFTTcuZH91XPl1/h68tftu83fQ=; b=JEaNABDNa2g/h+pDhHpIkewTSGNcFnCOiSOu5KrpwFfi1aVYXiHyR0RkgGmwxR3KXR cXaLgm7soQvtpANy5+aaojTB215L/sYQ7slAf+CLUZZq4mmKZMsn4dF8mK6bOTeSxC0H zM1qRVNPJau25GSBWf5/qpXLYIPuLt9ufWASft8zMKgUjGcAbixAwN3W9aw/HRPwiKpt dypzaV2a+oyH4/pA4Q5HIq1xi0E+SjntDFxCCiaq/wL2reGcI4/YijdKlcpaX9Orljs9 5a5sNHKlewDS2QSCIYuOAmcgsO+RoonLNKN0oON4TjdY0rtSZ4O4d1GGaN7/No5I2YBr ndKQ== X-Gm-Message-State: AOAM532MtD8EYKoy4waXhK1A+RkOqLqCWjNCyDQTV5QcmY9HPEMUn89s 8YFlcrYZ64OwchfPHWCu+srDBBsXLfT4S6IVFkDX0w== X-Google-Smtp-Source: ABdhPJwj1M4j43o7kMijydVIxSHfPn/hU6ZLgDrj/j/8bN1QoW81SNktGJDOqulholLG8jMiJC4JvTp2Hl1jFnfx4eQ= X-Received: by 2002:a25:41cd:: with SMTP id o196mr20775235yba.181.1589754550532; Sun, 17 May 2020 15:29:10 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 17 May 2020 15:29:10 -0700 From: Stefan Kangas MIME-Version: 1.0 Date: Sun, 17 May 2020 15:29:10 -0700 Message-ID: Subject: To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: retitle 41342 tab-bar-mode: Add context menu when right-clicking tab thanks Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.219.171 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (stefankangas[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.219.171 listed in wl.mailspike.net] 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines 2.0 BLANK_SUBJECT Subject is present but empty X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) retitle 41342 tab-bar-mode: Add context menu when right-clicking tab thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 09 03:23:09 2021 Received: (at control) by debbugs.gnu.org; 9 Aug 2021 07:23:09 +0000 Received: from localhost ([127.0.0.1]:55593 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCzcq-0004Ip-E7 for submit@debbugs.gnu.org; Mon, 09 Aug 2021 03:23:09 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:57027) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mCzcl-0004Hp-An; Mon, 09 Aug 2021 03:23:05 -0400 Received: (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 027401C000D; Mon, 9 Aug 2021 07:22:55 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#41343: tab-bar-mode: Close tab on mouse-2 click Organization: LINKOV.NET References: <87wnp2cg52.fsf@linkov.net> <83tuk5la2u.fsf@gnu.org> <877dh18lj3.fsf@mail.linkov.net> <83y29gjvjh.fsf@gnu.org> <8735rn8jz6.fsf@mail.linkov.net> <83sfznhywm.fsf@gnu.org> <87tuk356ia.fsf@mail.linkov.net> <83im0iiw8n.fsf@gnu.org> Date: Mon, 09 Aug 2021 10:03:28 +0300 In-Reply-To: <83im0iiw8n.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 06 Aug 2021 15:38:32 +0300") Message-ID: <877dgvkt1z.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: control Cc: 41343@debbugs.gnu.org, stefankangas@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain forcemerge 41343 41342 tags 41342 + patch tags 41343 + patch thanks > Are you talking about handle_tab_bar_click and the processing of > TAB_BAR_EVENT in make_lispy_event? Or are there other/additional > parts to this processing? So now I've completely redesigned the event processing on the tab bar. With the following patch 'down-mouse-1' is bound to 'tab-bar-mouse-select-tab' 'down-mouse-2' is bound to 'tab-bar-mouse-close-tab' 'down-mouse-3' is bound to 'tab-bar-mouse-context-menu' The context menu that pops up on down-mouse-3 was requested in bug#41342. Now also it should be possible even to implement drag-drop to move tabs with the mouse since they produce normal mouse events that now are accepted by the tab bar. All aforementioned bindings work on X, xterm, and even on console. For example, clicking mouse-3 on the tab bar displays a menu with blue background on a console terminal. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=tab-bar-events.patch diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 7459e1b78c..162dc43876 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -224,6 +224,11 @@ tab-bar-mode (tab-bar--define-keys) (tab-bar--undefine-keys))) +(defun tab--symbol-to-number (symbol) + (unless (eq symbol 'current-tab) + (string-to-number + (string-replace "tab-" "" (format "%S" symbol))))) + (defun tab-bar-handle-mouse (event) "Text-mode emulation of switching tabs on the tab bar. This command is used when you click the mouse in the tab bar @@ -238,18 +243,52 @@ tab-bar-handle-mouse (lambda (key binding) (when (eq (car-safe binding) 'menu-item) (when (> (+ column (length (nth 1 binding))) x-position) - (if (get-text-property (- x-position column) 'close-tab (nth 1 binding)) - (let* ((close-key (vector (intern (format "C-%s" key)))) - (close-def (lookup-key keymap close-key))) - (when close-def - (call-interactively close-def))) - (call-interactively (nth 2 binding))) + (if (get-text-property + (- x-position column) 'close-tab (nth 1 binding)) + (tab-bar-close-tab (tab--symbol-to-number key)) + (if (nth 2 binding) + (call-interactively (nth 2 binding)) + (tab-bar-select-tab (tab--symbol-to-number key)))) (throw 'done t)) (setq column (+ column (length (nth 1 binding)))))) keymap)) ;; Clicking anywhere outside existing tabs will add a new tab (tab-bar-new-tab))))) +(defun tab-bar-mouse-select-tab (event) + (interactive "e") + (if (posn-window (event-start event)) + (let* ((tab (posn-string (event-start event))) + (tab-symbol (nth 0 tab)) + (tab-number (tab--symbol-to-number tab-symbol))) + (if (nth 1 tab) + (tab-bar-close-tab tab-number) + (let ((binding (lookup-key (cons 'keymap (nreverse (current-active-maps))) + (vector 'tab-bar tab-symbol)))) + (if binding + (call-interactively binding) + (tab-bar-select-tab tab-number))))) + ;; TTY + (tab-bar-handle-mouse event))) + +(defun tab-bar-mouse-close-tab (event) + (interactive "e") + (tab-bar-close-tab (tab--symbol-to-number + (nth 0 (posn-string (event-start event)))))) + +(defun tab-bar-mouse-context-menu (event) + (interactive "e") + (let* ((tab (posn-string (event-start event))) + (tab-number (tab--symbol-to-number (nth 0 tab))) + (menu (make-sparse-keymap "Context Menu"))) + + (define-key-after menu [close] + `(menu-item "Close" (lambda () (interactive) + (tab-bar-close-tab ,tab-number)) + :help "Close the tab")) + + (popup-menu menu event))) + (defun toggle-tab-bar-mode-from-frame (&optional arg) "Toggle tab bar on or off, based on the status of the current frame. Used in the Show/Hide menu, to have the toggle reflect the current frame. @@ -614,19 +654,12 @@ tab-bar--format-tab `((,(intern (format "tab-%i" i)) menu-item ,(funcall tab-bar-tab-name-format-function tab i) - ,(or - (alist-get 'binding tab) - `(lambda () - (interactive) - (tab-bar-select-tab ,i))) + ,(alist-get 'binding tab) :help "Click to visit tab")))) - `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i))) - menu-item "" - ,(or - (alist-get 'close-binding tab) - `(lambda () - (interactive) - (tab-bar-close-tab ,i))))))) + (when (alist-get 'close-binding tab) + `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i))) + menu-item "" + ,(alist-get 'close-binding tab)))))) (defun tab-bar-format-tabs () (let ((i 0)) @@ -767,7 +800,11 @@ tab-bar-format-list (defun tab-bar-make-keymap-1 () "Generate an actual keymap from `tab-bar-map', without caching." (append - '(keymap (mouse-1 . tab-bar-handle-mouse)) + '(keymap (down-mouse-1 . tab-bar-mouse-select-tab) + (mouse-1 . ignore) + (down-mouse-2 . tab-bar-mouse-close-tab) + (mouse-2 . ignore) + (down-mouse-3 . tab-bar-mouse-context-menu)) (tab-bar-format-list tab-bar-format))) diff --git a/src/dispextern.h b/src/dispextern.h index 33fcaa4c07..f4c7575b35 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3415,8 +3415,8 @@ #define TTY_CAP_STRIKE_THROUGH 0x20 NativeRectangle *nr); extern Lisp_Object find_hot_spot (Lisp_Object, int, int); -extern void handle_tab_bar_click (struct frame *, - int, int, bool, int); +extern Lisp_Object handle_tab_bar_click (struct frame *, + int, int, bool, int); extern void handle_tool_bar_click (struct frame *, int, int, bool, int); diff --git a/src/keyboard.c b/src/keyboard.c index 820229cf8f..5dabad98a8 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -5647,6 +5647,12 @@ make_lispy_event (struct input_event *event) position = make_lispy_position (f, event->x, event->y, event->timestamp); + + if (CONSP (event->arg) && EQ (XCAR (event->arg), Qtab_bar)) + { + XSETCAR (XCDR (position), Qtab_bar); + position = nconc2(position, Fcons (XCDR (event->arg), Qnil)); + } } #ifndef USE_TOOLKIT_SCROLL_BARS else diff --git a/src/term.c b/src/term.c index c995a4499c..89b3568003 100644 --- a/src/term.c +++ b/src/term.c @@ -2568,21 +2568,8 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event) { f->mouse_moved = 0; term_mouse_click (&ie, event, f); - /* eassert (ie.kind == MOUSE_CLICK_EVENT); */ - if (tty_handle_tab_bar_click (f, event->x, event->y, - (ie.modifiers & down_modifier) != 0, &ie)) - { - /* eassert (ie.kind == MOUSE_CLICK_EVENT - * || ie.kind == TAB_BAR_EVENT); */ - /* tty_handle_tab_bar_click stores 2 events in the event - queue, so we are done here. */ - /* FIXME: Actually, `tty_handle_tab_bar_click` returns true - without storing any events, when - (ie.modifiers & down_modifier) != 0 */ - count += 2; - return count; - } - /* eassert (ie.kind == MOUSE_CLICK_EVENT); */ + ie.arg = tty_handle_tab_bar_click (f, event->x, event->y, + (ie.modifiers & down_modifier) != 0, &ie); kbd_buffer_store_event (&ie); count++; } diff --git a/src/termchar.h b/src/termchar.h index f50c1bfb6e..7ab9337fbe 100644 --- a/src/termchar.h +++ b/src/termchar.h @@ -234,7 +234,7 @@ #define FRAME_TTY(f) \ #define CURTTY() FRAME_TTY (SELECTED_FRAME()) struct input_event; -extern bool tty_handle_tab_bar_click (struct frame *, int, int, bool, - struct input_event *); +extern Lisp_Object tty_handle_tab_bar_click (struct frame *, int, int, bool, + struct input_event *); #endif /* EMACS_TERMCHAR_H */ diff --git a/src/w32inevt.c b/src/w32inevt.c index 1255072b7f..9a69b32bcb 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c @@ -586,9 +586,8 @@ do_mouse_event (MOUSE_EVENT_RECORD *event, int x = event->dwMousePosition.X; int y = event->dwMousePosition.Y; struct frame *f = get_frame (); - if (tty_handle_tab_bar_click (f, x, y, (button_state & mask) != 0, - emacs_ev)) - return 0; /* tty_handle_tab_bar_click adds the event to queue */ + emacs_ev->arg = tty_handle_tab_bar_click (f, x, y, (button_state & mask) != 0, + emacs_ev); emacs_ev->modifiers |= ((button_state & mask) ? down_modifier : up_modifier); @@ -597,7 +596,6 @@ do_mouse_event (MOUSE_EVENT_RECORD *event, XSETFASTINT (emacs_ev->x, x); XSETFASTINT (emacs_ev->y, y); XSETFRAME (emacs_ev->frame_or_window, f); - emacs_ev->arg = Qnil; return 1; } diff --git a/src/w32term.c b/src/w32term.c index ad4d1a3282..c9570b0c67 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -168,8 +168,8 @@ #define SM_CYVIRTUALSCREEN 79 int w32_message_fd = -1; #endif /* CYGWIN */ -static void w32_handle_tab_bar_click (struct frame *, - struct input_event *); +static Lisp_Object w32_handle_tab_bar_click (struct frame *, + struct input_event *); static void w32_handle_tool_bar_click (struct frame *, struct input_event *); static void w32_define_cursor (Window, Emacs_Cursor); @@ -3684,17 +3684,17 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, frame-relative coordinates X/Y. EVENT_TYPE is either ButtonPress or ButtonRelease. */ -static void +static Lisp_Object w32_handle_tab_bar_click (struct frame *f, struct input_event *button_event) { int x = XFIXNAT (button_event->x); int y = XFIXNAT (button_event->y); if (button_event->modifiers & down_modifier) - handle_tab_bar_click (f, x, y, 1, 0); + return handle_tab_bar_click (f, x, y, 1, 0); else - handle_tab_bar_click (f, x, y, 0, - button_event->modifiers & ~up_modifier); + return handle_tab_bar_click (f, x, y, 0, + button_event->modifiers & ~up_modifier); } @@ -5186,6 +5186,7 @@ w32_read_socket (struct terminal *terminal, { /* If we decide we want to generate an event to be seen by the rest of Emacs, we put it here. */ + Lisp_Object tab_bar_key = Qnil; bool tab_bar_p = 0; bool tool_bar_p = 0; int button = 0; @@ -5208,12 +5209,12 @@ w32_read_socket (struct terminal *terminal, if (EQ (window, f->tab_bar_window)) { - w32_handle_tab_bar_click (f, &inev); + tab_bar_key = w32_handle_tab_bar_click (f, &inev); tab_bar_p = 1; } } - if (tab_bar_p + if ((tab_bar_p && NILP (tab_bar_key)) || (dpyinfo->w32_focus_frame && f != dpyinfo->w32_focus_frame /* This does not help when the click happens in @@ -5221,6 +5222,9 @@ w32_read_socket (struct terminal *terminal, && !frame_ancestor_p (f, dpyinfo->w32_focus_frame))) inev.kind = NO_EVENT; + if (!NILP (tab_bar_key)) + inev.arg = tab_bar_key; + /* Is this in the tool-bar? */ if (WINDOWP (f->tool_bar_window) && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window))) diff --git a/src/xdisp.c b/src/xdisp.c index e62f7e3df6..0cbfa4bfff 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13745,7 +13745,7 @@ get_tab_bar_item (struct frame *f, int x, int y, struct glyph **glyph, false for button release. MODIFIERS is event modifiers for button release. */ -void +Lisp_Object handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, int modifiers) { @@ -13763,12 +13763,12 @@ handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, /* If the button is released on a tab other than the one where it was pressed, don't generate the tab-bar button click event. */ || (ts != 0 && !down_p)) - return; + return Qnil; /* If item is disabled, do nothing. */ enabled_p = AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_ENABLED_P); if (NILP (enabled_p)) - return; + return Qnil; if (down_p) { @@ -13779,24 +13779,15 @@ handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, } else { - Lisp_Object key, frame; - struct input_event event; - EVENT_INIT (event); - /* Show item in released state. */ if (!NILP (Vmouse_highlight)) show_mouse_face (hlinfo, DRAW_IMAGE_RAISED); - - key = AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_KEY); - - XSETFRAME (frame, f); - event.kind = TAB_BAR_EVENT; - event.frame_or_window = frame; - event.arg = key; - event.modifiers = close_p ? ctrl_modifier | modifiers : modifiers; - kbd_buffer_store_event (&event); f->last_tab_bar_item = -1; } + + return list3 (Qtab_bar, + AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_KEY), + close_p ? Qt : Qnil); } @@ -13920,14 +13911,14 @@ tty_get_tab_bar_item (struct frame *f, int x, int *idx, ptrdiff_t *end) structure, store it in keyboard queue, and return true; otherwise return false. MODIFIERS are event modifiers for generating the tab release event. */ -bool +Lisp_Object tty_handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, struct input_event *event) { /* Did they click on the tab bar? */ if (y < FRAME_MENU_BAR_LINES (f) || y >= FRAME_MENU_BAR_LINES (f) + FRAME_TAB_BAR_LINES (f)) - return false; + return Qnil; /* Find the tab-bar item where the X,Y coordinates belong. */ int prop_idx; @@ -13935,46 +13926,33 @@ tty_handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, Lisp_Object caption = tty_get_tab_bar_item (f, x, &prop_idx, &clen); if (NILP (caption)) - return false; + return Qnil; if (NILP (AREF (f->tab_bar_items, prop_idx * TAB_BAR_ITEM_NSLOTS + TAB_BAR_ITEM_ENABLED_P))) - return false; + return Qnil; if (down_p) f->last_tab_bar_item = prop_idx; else { - /* Force reset of up_modifier bit from the event modifiers. */ - if (event->modifiers & up_modifier) - event->modifiers &= ~up_modifier; - - /* Generate a TAB_BAR_EVENT event. */ - Lisp_Object frame; - Lisp_Object key = AREF (f->tab_bar_items, - prop_idx * TAB_BAR_ITEM_NSLOTS - + TAB_BAR_ITEM_KEY); - /* Kludge alert: we assume the last two characters of a tab - label are " x", and treat clicks on those 2 characters as a - Close Tab command. */ - eassert (STRINGP (caption)); - int lastc = SSDATA (caption)[SCHARS (caption) - 1]; - bool close_p = false; - if ((x == clen - 1 || (clen > 1 && x == clen - 2)) && lastc == 'x') - close_p = true; - - event->code = 0; - XSETFRAME (frame, f); - event->kind = TAB_BAR_EVENT; - event->frame_or_window = frame; - event->arg = key; - if (close_p) - event->modifiers |= ctrl_modifier; - kbd_buffer_store_event (event); f->last_tab_bar_item = -1; } - return true; + /* Generate a TAB_BAR_EVENT event. */ + Lisp_Object key = AREF (f->tab_bar_items, + prop_idx * TAB_BAR_ITEM_NSLOTS + + TAB_BAR_ITEM_KEY); + /* Kludge alert: we assume the last two characters of a tab + label are " x", and treat clicks on those 2 characters as a + Close Tab command. */ + eassert (STRINGP (caption)); + int lastc = SSDATA (caption)[SCHARS (caption) - 1]; + bool close_p = false; + if ((x == clen - 1 || (clen > 1 && x == clen - 2)) && lastc == 'x') + close_p = true; + + return list3 (Qtab_bar, key, close_p ? Qt : Qnil); } diff --git a/src/xterm.c b/src/xterm.c index 1887c3255d..80fa747b97 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -9166,6 +9166,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, { /* If we decide we want to generate an event to be seen by the rest of Emacs, we put it here. */ + Lisp_Object tab_bar_key = Qnil; bool tab_bar_p = false; bool tool_bar_p = false; @@ -9215,7 +9216,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, tab_bar_p = EQ (window, f->tab_bar_window); if (tab_bar_p && event->xbutton.button < 4) - handle_tab_bar_click + tab_bar_key = handle_tab_bar_click (f, x, y, event->xbutton.type == ButtonPress, x_x_to_emacs_modifiers (dpyinfo, event->xbutton.state)); } @@ -9239,7 +9240,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, } #endif /* !USE_GTK */ - if (!tab_bar_p && !tool_bar_p) + if (!(tab_bar_p && NILP (tab_bar_key)) && !tool_bar_p) #if defined (USE_X_TOOLKIT) || defined (USE_GTK) if (! popup_activated ()) #endif @@ -9257,6 +9258,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, } else x_construct_mouse_click (&inev.ie, &event->xbutton, f); + + if (!NILP (tab_bar_key)) + inev.ie.arg = tab_bar_key; } if (FRAME_X_EMBEDDED_P (f)) xembed_send_message (f, event->xbutton.time, --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 14 02:44:08 2021 Received: (at control) by debbugs.gnu.org; 14 Sep 2021 06:44:08 +0000 Received: from localhost ([127.0.0.1]:47358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQ2Aq-00074m-H1 for submit@debbugs.gnu.org; Tue, 14 Sep 2021 02:44:08 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:38437) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQ2Ao-00073m-91; Tue, 14 Sep 2021 02:44:06 -0400 Received: (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 703F0240008; Tue, 14 Sep 2021 06:43:57 +0000 (UTC) From: Juri Linkov To: Stefan Kangas Subject: Re: bug#41343: tab-bar-mode: Close tab on mouse-2 click Organization: LINKOV.NET References: <87wnp2cg52.fsf@linkov.net> <83tuk5la2u.fsf@gnu.org> <877dh18lj3.fsf@mail.linkov.net> <83y29gjvjh.fsf@gnu.org> <8735rn8jz6.fsf@mail.linkov.net> <83sfznhywm.fsf@gnu.org> <87tuk356ia.fsf@mail.linkov.net> <83im0iiw8n.fsf@gnu.org> <877dgvkt1z.fsf@mail.linkov.net> <83wnotfpak.fsf@gnu.org> <87k0ksecbq.fsf@mail.linkov.net> <83v94cdwk5.fsf@gnu.org> <87a6lepqqo.fsf@mail.linkov.net> <87mtorrlf5.fsf@mail.linkov.net> Date: Tue, 14 Sep 2021 09:43:06 +0300 In-Reply-To: (Stefan Kangas's message of "Mon, 6 Sep 2021 21:40:11 +0200") Message-ID: <878rzzu079.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: control Cc: Eli Zaretskii , 41343@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) tags 41343 fixed close 41343 28.0.50 thanks >> Now the branch 'feature/tab-bar-events' is ready for testing. >> Please help to find any possible problems. > > I have tested it on GNU/Linux and macOS, and it seems to work fine. > > One concern is that tabs close on mouse down, rather than release. > > In Firefox, tabs close instead on mouse release. This is good, > because it gives me a second to react and move the mouse cursor away > in case I misclick. > > This is currently less important in Emacs, as the buffer survives even > such a misclick. But maybe in the future users will want tabs to be > more strongly connected to their associated buffers, and work would > then easily be lost to a misclick. > > Could we change this to close on mouse release instead? Thanks for the suggestion. It was trivially easy to implement this with the new design of the event handling on the tab bar. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 15 02:40:36 2021 Received: (at 41342) by debbugs.gnu.org; 15 Sep 2021 06:40:36 +0000 Received: from localhost ([127.0.0.1]:50625 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQOay-0001xP-7g for submit@debbugs.gnu.org; Wed, 15 Sep 2021 02:40:36 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:50853) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQOav-0001xA-Su for 41342@debbugs.gnu.org; Wed, 15 Sep 2021 02:40:34 -0400 Received: (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id C62CE1BF204; Wed, 15 Sep 2021 06:40:25 +0000 (UTC) From: Juri Linkov To: Stefan Kangas Subject: Re: bug#41342: Add context menu when right-clicking tab in tab-bar-mode References: Date: Wed, 15 Sep 2021 09:37:24 +0300 In-Reply-To: (Stefan Kangas's message of "Sat, 16 May 2020 21:00:21 -0700") Message-ID: <8735q6cpjv.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 41342 Cc: 41342@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > Please consider adding a context menu to tab-bar-mode shown when > clicking a tab. This could including actions such as: > > - Close tab > - Close other tabs > - Duplicate tab These are added now. > Inspired by Firefox, one could also imagine. > > - Move tab > - Move to Start (of list) > - Move to End > - Move to New Frame This would be easy to add but I'm not sure if they are needed because it's easier to drag tabs to move them, and indeed Chromium has no such menu items. From unknown Fri Aug 15 02:02:02 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 13 Oct 2021 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator