From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matthias Meulien Newsgroups: gmane.emacs.devel Subject: Re: Fix width tabs Date: Mon, 21 Feb 2022 13:38:36 +0100 Message-ID: <87wnho9yyb.fsf@gmail.com> References: <87wnhtfad7.fsf@gmail.com> <865ypcmx6s.fsf@mail.linkov.net> <87sfsgfd2b.fsf@gmail.com> <86mtimzt13.fsf@mail.linkov.net> <86fsock4f1.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8172"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Feb 21 14:42:05 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nM8x0-0001s1-Tv for ged-emacs-devel@m.gmane-mx.org; Mon, 21 Feb 2022 14:42:02 +0100 Original-Received: from localhost ([::1]:34398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nM8wz-0008TD-9o for ged-emacs-devel@m.gmane-mx.org; Mon, 21 Feb 2022 08:42:01 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nM7xh-0003Mx-T7 for emacs-devel@gnu.org; Mon, 21 Feb 2022 07:38:41 -0500 Original-Received: from [2a00:1450:4864:20::42e] (port=43740 helo=mail-wr1-x42e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nM7xg-0007hI-4b for emacs-devel@gnu.org; Mon, 21 Feb 2022 07:38:41 -0500 Original-Received: by mail-wr1-x42e.google.com with SMTP id s1so409225wrg.10 for ; Mon, 21 Feb 2022 04:38:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=zu+oTa+h8STuKEw57QDSNMJEuL+DbD1NlpbwHDSj8iU=; b=BecE3HBvZFJfiO/YKwGKc/1V+PzgMo0Rw8p1RncL2vLa4YTMAedDK9oaVnXGHMdr0P ENxF7j2xBy5Ua4iOZmpCIZ3OyTif9DKq9sA0BlZR9TC2Jg2cgdggBZMl66rnpdC/lMvm 0fLVRamiymxb1lnbfyRWVeD2powxbk4ea8iRkwfxCemylc/B9Zf+movMmdXFs0c6F/l3 5QMWMzZew9j4gfAwa3TNpAjQ8dfrhciEFQhm8Q/bkzxKNCb/YVINSEI+fQ2qlmd2yU52 FKv7AE4Ve9TZw3nhDWiSFRJrhEO6O9E11z3MGriV1KPX2QEPwNkPBGyD5Bf0EIWdWPLs hciA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=zu+oTa+h8STuKEw57QDSNMJEuL+DbD1NlpbwHDSj8iU=; b=1+djfH5lPLQ4Ix7HTGXLRAuIAbB/YGnTakpbHFNgR1TIOJGfDVbl6Jr0nEev2yBz9N 6Jfg8PlZTO9pMBDxe+6QyNGDteDFZ9CZLhI9C2JXIC+1xLRcFWXPm75PbEkCyMwzLVvg vjh0XuEPfK86tzfB+Es1Pr+4CgqMksYXTg6EQ9mO8YM0P6BmoIjaewaJmgUGnrobWVQF lFDqf3wHelc6oXNtHPxdlYnFtlEeGt0mU8YjXS0GlwPYeMWIvVGw574/T6MXSxMucq8r Nr+jEMfBMQSe6JtkihkWXCKjhUKovSKgAXC6I4FHqiSn/vVecpZIGQjn5V+dKs6Cn5IJ 3lCw== X-Gm-Message-State: AOAM5308k1RT8Akh/6g/WwSfzPGv37PEJxoRo05yDYx1sf8AsGvI/5kb lHGtUilGjzP/E84m+nYYMF99DV3rgho= X-Google-Smtp-Source: ABdhPJwVACLaF2gDUiarfpJW3ekkMYScIzM0qNrV+MTiNOVT73T8/p7UWN1JPENbEQj2njlihqMiiw== X-Received: by 2002:a5d:4645:0:b0:1e3:3a94:66dc with SMTP id j5-20020a5d4645000000b001e33a9466dcmr15401769wrs.330.1645447117885; Mon, 21 Feb 2022 04:38:37 -0800 (PST) Original-Received: from carbon.localdomain ([2a01:e0a:245:c850:98f5:429a:aa8e:95bb]) by smtp.gmail.com with ESMTPSA id az2sm18653992wmb.2.2022.02.21.04.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 04:38:37 -0800 (PST) In-Reply-To: <86fsock4f1.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 21 Feb 2022 10:30:27 +0200") X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42e (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=orontee@gmail.com; helo=mail-wr1-x42e.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:286560 Archived-At: Juri Linkov writes: >>>> If you want, you could try experimenting by writing a function >>>> for tab-bar-tab-name-function with padding every tab name >>>> by proportional amount of space. >>> >>> I'll try this. Thanks a lot! >> >> If you need the fixed width also for tabs with explicit names, >> then a better option would be write a formatting function for >> tab-bar-tab-name-format-function. I tried the following (not trying to dynamically compute the tabs width to start with and disabling support for close buttons): (defun my-tab-bar-tab-name-format (tab i) (propertize (truncate-string-to-width (format (concat "%-" (number-to-string tab-bar-tab-name-truncated-max) "s") (alist-get 'name tab)) tab-bar-tab-name-truncated-max 0 ?m t) 'face (funcall tab-bar-tab-face-function tab))) (setq tab-bar-tab-name-format-function 'my-tab-bar-tab-name-format) Unfortunately it doesn't play well with variable pitch font, and the display property "min-width" isn't honored in tab-bar. I guess my naive approach won't be sufficient... > OTOH, I can't imagine how you could implement a formatting function > without requiring two-pass tabs generation that is highly inefficient: > after the first pass you get the number of tabs, groups of tabs, > and their names. Then on the second pass you can pad names > with required amount of space proportional to the total number of tabs. > > So a more efficient implementation would be to modify the strings > that represent the tab names in the result of tab-bar-format-list > (e.g. by using advice-add for experimentation). But a drawback is > that then you need to rely on the details of implementation of the > internal data structure. I understand. -- Matthias