From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#72309: propertized-buffer-identification with maximum width Date: Sun, 28 Jul 2024 12:18:32 +0000 Message-ID: References: <8eYtcka1bg4aOfbQVrzRShsG1EtNIu1JLO9XlRoQXZ4Q7yqojew5kxXcml4s-JdvwA7hgEdo_0-YEQf0zknb2wq9aS_-rgwEZB0ZT9y6QWM=@protonmail.com> <86plqz0z2g.fsf@gnu.org> <4NGOfJklhGgHco35Z3hgQLAbDA27v3FQW-VrjVbIMZ19Giduj_FYccq70KrUy7HlB2FgttLYBhiUJHL32RFS73-Ex6XnFwoaQqpdfQcn7_8=@protonmail.com> <86o76j0xps.fsf@gnu.org> <86bk2i15f4.fsf@gnu.org> Reply-To: Heime Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20027"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72309@debbugs.gnu.org, Eli Zaretskii To: Heime Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 28 14:19:05 2024 Return-path: Envelope-to: geb-bug-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 1sY2rg-00052o-AR for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 28 Jul 2024 14:19:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sY2rV-0002gg-CN; Sun, 28 Jul 2024 08:18:53 -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 1sY2rS-0002gT-RV for bug-gnu-emacs@gnu.org; Sun, 28 Jul 2024 08:18:50 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sY2rS-0006FI-IZ for bug-gnu-emacs@gnu.org; Sun, 28 Jul 2024 08:18:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:From:Date:To:Subject; bh=2/K4pGL6/yetXBTJzQ7XKWC87wTKaKA1eC0sYgO912o=; b=mzU/OY7hqANvTpJCDXZrNXeIVnb/RHnfGnI76KgsRKbRm/1XMBUVenXF47uZPGwceNLUsb2gD12i8yPXjIE0Iq+y5CPi+xckn1TvGbBM0TJNMv0yN5VsyesBfb25Ic/ycqq7Z7vuJo9AwwC2QBxt76nAJkg8/MPwDYTQtq6zy8NJr7uE4Bqh0XS7XO4NI6b3aoFFn70J+94T5sbIMScGFCGLRKdrjqaC4h8WxeimiIk/xcCM5XMARYHEf5pxxdvY4ajbPbB1bQf916sYPKmuSO4GNKSeI1mQgDzM8yXL+7RrductQEMTJ0UVuDd4CH1tHWqHVBYSpshb/MCJrmiCVw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sY2rd-000736-RL for bug-gnu-emacs@gnu.org; Sun, 28 Jul 2024 08:19:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Heime Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Jul 2024 12:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72309 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 72309-submit@debbugs.gnu.org id=B72309.172216913827086 (code B ref 72309); Sun, 28 Jul 2024 12:19:01 +0000 Original-Received: (at 72309) by debbugs.gnu.org; 28 Jul 2024 12:18:58 +0000 Original-Received: from localhost ([127.0.0.1]:42790 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sY2ra-00072o-06 for submit@debbugs.gnu.org; Sun, 28 Jul 2024 08:18:58 -0400 Original-Received: from mail-40135.protonmail.ch ([185.70.40.135]:56003) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sY2rY-00072X-2S for 72309@debbugs.gnu.org; Sun, 28 Jul 2024 08:18:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1722169117; x=1722428317; bh=2/K4pGL6/yetXBTJzQ7XKWC87wTKaKA1eC0sYgO912o=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=T1QiW6FKxM5NkO4WMoOp3++W7yDaEyRKnnfDvq/12XMykSHGsvEPc6oytIpMvC4uF ch8uV/kEA6Y1pr32Gn9qhbtgZKvbrKYvsrWLPcQvfOMntnh2UuHtyCmsnjZJAvfCtK vz+v5KO2gxmDeK7xcvFZa7NANXgABO3sTKhQIaeKUrq2H32YFSiThx384qlAjTjgjX xWVJ1r/AlxL1IeMN4H+Iy6vR80zSs7l2vy5KQctc/1GTe46F18iQ4XxRdgAdJa8+tK Gfn4o3XIbsdWsGKgIk6+2GTsXS86OPqZNL+u6yDm4pD58uDu+g2wCvsixsplE737Uk dXV0qsFeyrXWw== In-Reply-To: Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 3ad7f22bf55794cde96fd3700f1155d07b65610e X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:289465 Archived-At: Sent with Proton Mail secure email. On Sunday, July 28th, 2024 at 10:55 PM, Heime via "Bug reports for GNU Emac= s, the Swiss army knife of text editors" wrote: >=20 >=20 >=20 >=20 >=20 > Sent with Proton Mail secure email. >=20 >=20 > On Sunday, July 28th, 2024 at 4:55 PM, Eli Zaretskii eliz@gnu.org wrote: >=20 > > > Date: Sat, 27 Jul 2024 20:49:05 +0000 > > > From: Heime heimeborgia@protonmail.com > > > Cc: 72309@debbugs.gnu.org, Eli Zaretskii eliz@gnu.org > > >=20 > > > On Sunday, July 28th, 2024 at 3:27 AM, Heime via "Bug reports for GNU= Emacs, the Swiss army knife of text editors" bug-gnu-emacs@gnu.org wrote: > > >=20 > > > > Sent with Proton Mail secure email. > > > >=20 > > > > On Sunday, July 28th, 2024 at 2:56 AM, Heime via "Bug reports for G= NU Emacs, the Swiss army knife of text editors" bug-gnu-emacs@gnu.org wrote= : > > > >=20 > > > > > Sent with Proton Mail secure email. > > > > >=20 > > > > > On Sunday, July 28th, 2024 at 1:29 AM, Eli Zaretskii eliz@gnu.org= wrote: > > > > >=20 > > > > > > > Date: Sat, 27 Jul 2024 13:08:31 +0000 > > > > > > > From: Heime heimeborgia@protonmail.com > > > > > > > Cc: 72309@debbugs.gnu.org > > > > > > >=20 > > > > > > > On Sunday, July 28th, 2024 at 1:00 AM, Eli Zaretskii eliz@gnu= .org wrote: > > > > > > >=20 > > > > > > > > Yes, but the (WIDTH something) construct is not for truncat= ing long > > > > > > > > names, it's for ensuring the string produced by "something"= doesn't > > > > > > > > take too many columns. So you are using this for a wrong pu= rpose. If > > > > > > > > you want to truncate a buffer's name, use truncate-string-t= o-width > > > > > > > > instead, which is also capable of showing the ellipsis at t= he end. > > > > > > >=20 > > > > > > > I do not know how to access the buffer name and apply truncat= e-string-to-width > > > > > > > when setting mode-line-buffer-identification on propertized-b= uffer-identification. > > > > > >=20 > > > > > > Use :eval. > > > > >=20 > > > > > I have done it without success > > > > >=20 > > > > > (defun vodil-rtgbfn (wmin) > > > > > (setq-default mode-line-buffer-identification > > > > > (propertized-buffer-identification (format " %%%db " wmin)))) > > > > >=20 > > > > > (vodil-rtgbfn 8) > > > > >=20 > > > > > (setq-default mode-line-format > > > > > '( "%e" (:eval (truncate-string-to-width mode-line-buffer-identif= ication 13)) > > > > > vodil-panelit-bfselec)) > > > >=20 > > > > Have now done, but now the buffer name is not displayed. Why has th= ere > > > > to be so much torture to change the defaults ! > > > >=20 > > > > (defun vodil-tkbfn-ellipses (wmax) > > > > "Get the buffer name truncated to WMAX width with ellipsis." > > > >=20 > > > > (let* ( (bfname (buffer-name (window-buffer))) > > > > (tkname (if (> (length bfname) wmax) > > > >=20 > > > > (truncate-string-to-width bfname wmax nil nil "...") > > > > bfname))) > > > > (propertized-buffer-identification (format " %s " tkname)))) > > > >=20 > > > > (defun vodil-tkbfn (wmax) > > > > "Set mode-line-buffer-identification with WMAX maximum width." > > > >=20 > > > > (setq-default mode-line-buffer-identification > > > > '(:eval (vodil-tkbfn-ellipses wmax)))) > > >=20 > > > What is the big problem of showing how to implement this, buffer name > > > with truncation ellipses using mode-line-buffer-identification ? > >=20 > > We don't have people here whose job is to write code for others. This > > is a volunteer-based project, where people help you with ideas, but > > the actual job of writing and debugging the code is yours. > >=20 > > So please take the ideas, read the documentation, and work on the > > implementation you want. If you have questions about the > > implementation, please ask them on help-gnu-emacs, which is where > > user-level help should be sought. =20 The implementations do not work. =20 For instance, using=20 (name (buffer-name)) or with=20 (buffer-name (window-buffer)) See (setq-default mode-line-buffer-identification (propertized-buffer-identification (format " %s " (let ( (name (buffer-name)) ) (if (> (length name) wmax) (concat (substring name 0 (- wmax 3)) "...") name))))) ) And neither does this (let* ( (bfname (buffer-name (window-buffer))) (tkname (if (> (length bfname) wmax) (truncate-string-to-width bfname wmax nil nil "...") bfname))) (propertized-buffer-identification (format " %s " tkname)))) So there is no option other than using %b, where one has no control about how it gets displayed.=20