From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: doltes Newsgroups: gmane.emacs.help Subject: Help on calling a function inside "ibuffer-formats" Date: Tue, 26 Jan 2021 17:35:25 -0500 Message-ID: <87bldbjphu.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4281"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.14; emacs 27.1 To: Emacs Help Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 26 23:39:25 2021 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 1l4Wzc-000129-V5 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Jan 2021 23:39:24 +0100 Original-Received: from localhost ([::1]:56888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4Wzc-0005Jf-0q for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Jan 2021 17:39:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4Wyv-0005JO-44 for help-gnu-emacs@gnu.org; Tue, 26 Jan 2021 17:38:41 -0500 Original-Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]:39619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l4Wyt-0008IL-Hp for help-gnu-emacs@gnu.org; Tue, 26 Jan 2021 17:38:40 -0500 Original-Received: by mail-qk1-x731.google.com with SMTP id k193so17672298qke.6 for ; Tue, 26 Jan 2021 14:38:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:date:message-id:mime-version; bh=gb23mjchEzsCcZAps6m0X9eo8YcLZX3FP6FVwOgPOrQ=; b=kJRbWyRzyyMbE+2CxV29Sq+5pw1KU0WnyW/iAtlpMjc7EgCpk38uIHvl72jnjCPi7v 7pU/bZS7ciu3alcYn4HcC1iHt6Li/iWtodVLA0sKDjKbVl8oK4gl4v8aBaHTcJutlE82 t3AWLmcPmmAyygD6a2Hoaxc0rPgi4m1qjzfpwbndW8MRmpZaPJs8TVihoaoYW0hlBHZ9 S3D+WL3Bsrs7B2C+dZkogDTR5PrhPWXXtWbuQIxKJMO+rcXgFSrd/31w/krSyu0PHezx ycAyTdNDa+jzuxKxegqqaZVvK/B+WHmJRTDaQhjTq/UM0oA35tkX3NoeVrMvNuod4H2L r2tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:date:message-id :mime-version; bh=gb23mjchEzsCcZAps6m0X9eo8YcLZX3FP6FVwOgPOrQ=; b=PgO37kuVidX2JRCGDyg+pdp87gA6Y0zpZvi3EoGhr0EsNpi44Bt0vf/ITWx2Qq0Jjw wgBMxzt4q+QL/l4P/b1Y+zsBXgKgjZSNfE0OLL6Cb7nosF8WEGcFUVzVbkoBLvLxJIg1 Or8KApG8ZNGCY3jM4O3PLglBwDJSAzZeJWcue1aB7pLewFKpeqb67AS2ue4psWfqzdec jr81a2823V2xMM6kSUHUw/cj4DfX38nMsPPAheausLgCna9WUc5fpqTwKyY15DnEU5XB g9Cl7DBGmOQyvSdIXN45xxc/Ax0elNRiv5WGuTGxDYfzhpsl32ifKmlLbABMV6/aO0EN B9pw== X-Gm-Message-State: AOAM5309Nl0GRhKoKX81yhr1Wo4pOjUwH27PT33W4sCdOPYvNIoXrBUv 6R0fsyjuqyujsW4bvy/vG0h0e/aO4HI= X-Google-Smtp-Source: ABdhPJzo0nu2BFgP/7/vR2n/NTlUU3L1cy6UF1reg+f5YfRLVyXPeDeaXh6IYzQPyYnw0jK2UhZ5rA== X-Received: by 2002:a37:7907:: with SMTP id u7mr8237442qkc.472.1611700717810; Tue, 26 Jan 2021 14:38:37 -0800 (PST) Original-Received: from localhost ([190.239.232.181]) by smtp.gmail.com with ESMTPSA id y26sm100142qth.53.2021.01.26.14.38.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 14:38:37 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::731; envelope-from=doltes512@gmail.com; helo=mail-qk1-x731.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.emacs.help:127376 Archived-At: I'm trying to make =ibuffer= don't truncate the =Name= column. To accomplish this, I've defined the following function. This function obtains the length of the longest buffer name. #+begin_src elisp (defun length-buffer-longest-name () (interactive) (apply 'max (mapcar #'length (mapcar #'buffer-name (buffer-list))))) (length-buffer-longest-name) #+end_src #+RESULTS: #+begin_example 77 #+end_example I want this function to be used as the =MIN-SIZE= and =MAX-SIZE= of the =name= column. For documentation on =MIN-SIZE= and =MAX-SIZE=, see the docstring of the variable =ibuffer-formats=. I've tried the following. #+begin_src elisp :results silent (setq ibuffer-formats '((mark modified read-only locked " " (name length-buffer-longest-name length-buffer-longest-name :left :elide) " " (size 9 -1 :right) " " (mode 16 16 :left :elide) " " filename-and-process) (mark " " (name 16 -1) " " filename))) #+end_src However, when calling =ibuffer=, I get the following error #+begin_example mapcar: Wrong type argument: number-or-marker-p, length-buffer-longest-name #+end_example I've also tried the following. However, as expected, the function =length-buffer-longest-name= is only called when the =setq= command is executed which is something I don't want to occur because that doesn't ensure that the rows of the =Name= column are always fully displayed. #+begin_src elisp (setq ibuffer-formats `((mark modified read-only locked " " (name ,(length-buffer-longest-name) ,(length-buffer-longest-name) :left :elide) " " (size 9 -1 :right) " " (mode 16 16 :left :elide) " " filename-and-process) (mark " " (name 16 -1) " " filename))) #+end_src My question is: 1. How can I make the =Name= column never be truncated? I know that I can set this value to a big number (e.g. 100, 200, 300) but I'd rather this value to be obtained through a function instead of hardcoding its value. This is the [[https://en.wikipedia.org/wiki/XY_problem][XY question]] 2. How can I call a function inside =ibuffer-formats= in order to ensure that =MIN-SIZE= and =MAX-SIZE= is always set to the length of the buffer with the longest name? -- Greetings, doltes.