From unknown Mon Jun 23 07:52:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#75497: [PATCH] ibuffer: Display column titles in header line Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Jan 2025 16:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 75497 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 75497@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.173661128618217 (code B ref -1); Sat, 11 Jan 2025 16:02:01 +0000 Received: (at submit) by debbugs.gnu.org; 11 Jan 2025 16:01:26 +0000 Received: from localhost ([127.0.0.1]:44556 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tWdvR-0004ji-SM for submit@debbugs.gnu.org; Sat, 11 Jan 2025 11:01:26 -0500 Received: from lists.gnu.org ([2001:470:142::17]:59352) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tWdvP-0004ie-3N for submit@debbugs.gnu.org; Sat, 11 Jan 2025 11:01:23 -0500 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 1tWdvH-0000dy-Et for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2025 11:01:15 -0500 Received: from server.qxqx.de ([2a01:4f8:c012:9177::1] helo=mail.qxqx.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tWdvD-0000UY-B0 for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2025 11:01:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date: Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Ou5anRgopSxifuY2OJsb0UwTdf1YjXhqZBnerCOKfs4=; b=fRlgwy3/6pThNMh78POtraSwhH N6f5uH7U2EjJeyvaUOibA6eYfIL1UYkrW9hN+umBKMHQTWXdk0fjrF2qqxKkJQU+LbseBqDYPBfBX D312ObVlpu2Xdzh0f7H4av/dhOr8IHDSHW3+gRslPtEqRUwR+FhuZRkmQtXrOuN4zcMs=; From: Daniel Mendler Date: Sat, 11 Jan 2025 17:01:04 +0100 Message-ID: <87cygt9w73.fsf@daniel-mendler.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a01:4f8:c012:9177::1; envelope-from=mail@daniel-mendler.de; helo=mail.qxqx.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) 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: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch Add new option value `title' to the customization option `ibuffer-use-header-line'. For this value show the column titles in the Ibuffer header line. --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-ibuffer-Display-column-titles-in-header-line.patch >From d4f745ce0409f1d9ae956ca8cbaf102eecea8563 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 11 Jan 2025 16:36:56 +0100 Subject: [PATCH] ibuffer: Display column titles in header line If the option `ibuffer-use-header-line' is set to `title', display column titles in the header line. * lisp/ibuffer.el (ibuffer--format-title) (ibuffer--format-summary): New functions extracted from `ibuffer-update-title-and-summary'. (ibuffer-update-title-and-summary): Use them. (ibuffer-update): Do not always override `header-line-format'. (ibuffer-use-header-line): Update docstring and option `:type'. * etc/NEWS: Announce the change. --- etc/NEWS | 4 ++ lisp/ibuffer.el | 166 ++++++++++++++++++++++++++---------------------- 2 files changed, 94 insertions(+), 76 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index d20c71897bc..46925cd8a4f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -338,6 +338,10 @@ modal editing packages. The variable 'ibuffer-formats' configures the Ibuffer formats. Add 'recency' to the format to display the column. +*** New value 'title' for the user option 'ibuffer-use-header-line'. +Display column titles in the header line if 'ibuffer-use-header-line' is +set to 'title'. + *** New user option 'ibuffer-human-readable-size'. When non-nil, buffer sizes are shown in human readable format. diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index 65f8ca53693..014d8c59b25 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -308,8 +308,10 @@ ibuffer-jump-offer-only-visible-buffers :type 'boolean) (defcustom ibuffer-use-header-line t - "If non-nil, display a header line containing current filters." - :type 'boolean) + "If non-nil, display a header line. +If the variable has the value t, the header line displays the current +filters. For the value `title', the column titles are displayed." + :type '(choice boolean (const :tag "Column titles" :value title))) (defcustom ibuffer-default-directory nil "The default directory to use for a new Ibuffer buffer. @@ -2045,59 +2047,90 @@ ibuffer-switch-format (ibuffer-update-format) (ibuffer-redisplay t)) +(defun ibuffer--format-title (element &optional header-line) + (if (stringp element) + element + (pcase-let ((`(,sym ,min ,_max ,align) element)) + ;; Ignore a negative min when we're inserting the title + (when (cl-minusp min) + (setq min (- min))) + (let* ((name (or (get sym 'ibuffer-column-name) + (error "Unknown column %s in ibuffer-formats" sym))) + (len (length name)) + (hmap (get sym 'header-mouse-map)) + (strname (if (< len min) + (ibuffer-format-column name + (- min len) + align) + name))) + (when hmap + (setq + strname + (propertize strname 'mouse-face 'highlight 'keymap + (if header-line + (define-keymap "" hmap) + hmap)))) + strname)))) + +(defun ibuffer--format-summary (element) + (if (stringp element) + (make-string (length element) ?\s) + (pcase-let ((`(,sym ,min ,_max ,align) element)) + ;; Ignore a negative min when we're inserting the title. + (when (cl-minusp min) + (setq min (- min))) + (let* ((summary + (if (get sym 'ibuffer-column-summarizer) + (funcall (get sym 'ibuffer-column-summarizer) + (get sym 'ibuffer-column-summary)) + (make-string + (length (get sym 'ibuffer-column-name)) + ?\s))) + (len (length summary))) + (if (< len min) + (ibuffer-format-column summary + (- min len) + align) + summary))))) + (defun ibuffer-update-title-and-summary (format) (ibuffer-assert-ibuffer-mode) ;; Don't do funky font-lock stuff here (let ((inhibit-modification-hooks t)) - (if (get-text-property (point-min) 'ibuffer-title) - (delete-region (point-min) - (next-single-property-change - (point-min) 'ibuffer-title))) - (goto-char (point-min)) - (add-text-properties - (point) - (progn - (let ((opos (point))) - ;; Insert the title names. - (dolist (element format) - (insert - (if (stringp element) - element - (pcase-let ((`(,sym ,min ,_max ,align) element)) - ;; Ignore a negative min when we're inserting the title - (when (cl-minusp min) - (setq min (- min))) - (let* ((name (or (get sym 'ibuffer-column-name) - (error "Unknown column %s in ibuffer-formats" sym))) - (len (length name)) - (hmap (get sym 'header-mouse-map)) - (strname (if (< len min) - (ibuffer-format-column name - (- min len) - align) - name))) - (when hmap - (setq - strname - (propertize strname 'mouse-face 'highlight 'keymap hmap))) - strname))))) - (add-text-properties opos (point) '(ibuffer-title-header t)) - (insert "\n") - ;; Add the underlines - (let ((str (save-excursion - (forward-line -1) - (beginning-of-line) - (buffer-substring (point) (line-end-position))))) - (apply #'insert (mapcar - (lambda (c) - (if (not (or (eq c ?\s) - (eq c ?\n))) - ?- - ?\s)) - str))) - (insert "\n")) - (point)) - `(ibuffer-title t font-lock-face ,ibuffer-title-face)) + ;; Insert the title names. + (if (eq ibuffer-use-header-line 'title) + (setq header-line-format + `("" header-line-indent + ,(propertize " " 'display + '(space :align-to header-line-indent-width)) + ,@(mapcar (lambda (e) (ibuffer--format-title e t)) format))) + (if (get-text-property (point-min) 'ibuffer-title) + (delete-region (point-min) + (next-single-property-change + (point-min) 'ibuffer-title))) + (goto-char (point-min)) + (add-text-properties + (point) + (progn + (let ((opos (point))) + (apply #'insert (mapcar #'ibuffer--format-title format)) + (add-text-properties opos (point) '(ibuffer-title-header t)) + (insert "\n") + ;; Add the underlines + (let ((str (save-excursion + (forward-line -1) + (beginning-of-line) + (buffer-substring (point) (line-end-position))))) + (apply #'insert (mapcar + (lambda (c) + (if (not (or (eq c ?\s) + (eq c ?\n))) + ?- + ?\s)) + str))) + (insert "\n")) + (point)) + `(ibuffer-title t font-lock-face ,ibuffer-title-face))) ;; Now, insert the summary columns. (goto-char (point-max)) (if (get-text-property (1- (point-max)) 'ibuffer-summary) @@ -2109,27 +2142,7 @@ ibuffer-update-title-and-summary (point) (progn (insert "\n") - (dolist (element format) - (insert - (if (stringp element) - (make-string (length element) ?\s) - (pcase-let ((`(,sym ,min ,_max ,align) element)) - ;; Ignore a negative min when we're inserting the title. - (when (cl-minusp min) - (setq min (- min))) - (let* ((summary - (if (get sym 'ibuffer-column-summarizer) - (funcall (get sym 'ibuffer-column-summarizer) - (get sym 'ibuffer-column-summary)) - (make-string - (length (get sym 'ibuffer-column-name)) - ?\s))) - (len (length summary))) - (if (< len min) - (ibuffer-format-column summary - (- min len) - align) - summary)))))) + (apply #'insert (mapcar #'ibuffer--format-summary format)) (point)) '(ibuffer-summary t))))) @@ -2194,10 +2207,11 @@ ibuffer-update ;; I tried to update this automatically from the mode-line-process format, ;; but changing nil-ness of header-line-format while computing ;; mode-line-format is asking a bit too much it seems. --Stef - (setq header-line-format - (and ibuffer-use-header-line - ibuffer-filtering-qualifiers - ibuffer-header-line-format))) + (unless (eq ibuffer-use-header-line 'title) + (setq header-line-format + (and ibuffer-use-header-line + ibuffer-filtering-qualifiers + ibuffer-header-line-format)))) (defun ibuffer-sort-bufferlist (bmarklist) (unless ibuffer-sorting-functions-alist -- 2.45.2 --=-=-=-- From unknown Mon Jun 23 07:52:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#75497: [PATCH] ibuffer: Display column titles in header line Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Jan 2025 12:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75497 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 75497@debbugs.gnu.org Received: via spool by 75497-submit@debbugs.gnu.org id=B75497.173668538910593 (code B ref 75497); Sun, 12 Jan 2025 12:37:02 +0000 Received: (at 75497) by debbugs.gnu.org; 12 Jan 2025 12:36:29 +0000 Received: from localhost ([127.0.0.1]:46367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tWxCe-0002km-Ny for submit@debbugs.gnu.org; Sun, 12 Jan 2025 07:36:29 -0500 Received: from server.qxqx.de ([2a01:4f8:c012:9177::1]:52681 helo=mail.qxqx.de) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tWxCc-0002kW-VQ for 75497@debbugs.gnu.org; Sun, 12 Jan 2025 07:36:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:To:From:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=eZ4vYJP4LgDPOpAUaRPZgi7RO3IFDYgP0787YGHDFv4=; b=NHZwqFOJMW1RlZ+GGElyKmWWn0 6sns3+qyI332tTqA4VBVFS1CWOvgu6nnV1rgwik8zpFmIYQQkDo41JsM2zt5iK2Dy60HqblQrqN3p tWCrIDyqGqrzLkg4/kodoiHy5dHW6+gGIrSdVOZK+5jM1UfY0xTEWYbrkHXFxd57V06U=; From: Daniel Mendler In-Reply-To: <87cygt9w73.fsf@daniel-mendler.de> (Daniel Mendler's message of "Sat, 11 Jan 2025 17:01:04 +0100") References: <87cygt9w73.fsf@daniel-mendler.de> Date: Sun, 12 Jan 2025 13:36:19 +0100 Message-ID: <87ed18p5to.fsf@daniel-mendler.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) 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 Daniel Mendler writes: > Add new option value `title' to the customization option > `ibuffer-use-header-line'. For this value show the column titles in the > Ibuffer header line. I have attached an improved version of the patch to this mail. I have added an "@" interactive spec to the sort commands, such that clicking on the header line works when the Ibuffer window is not selected. Daniel --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-ibuffer-Display-column-titles-in-header-line.patch >From 2a71b53364aae3566e2669647fc69ec8357f3263 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 11 Jan 2025 16:36:56 +0100 Subject: [PATCH 2/2] ibuffer: Display column titles in header line If the option `ibuffer-use-header-line' is set to `title', display column titles in the header line. * lisp/ibuffer.el (ibuffer--format-title) (ibuffer--format-summary): New functions extracted from `ibuffer-update-title-and-summary'. (ibuffer-update-title-and-summary): Use them. (ibuffer-update): Do not always override `header-line-format'. (ibuffer-use-header-line): Update docstring and option `:type'. * lisp/ibuf-macs.el (define-ibuffer-sorter): Add "@" to the interactive specification for clicks on the header line. * etc/NEWS: Announce the change. --- etc/NEWS | 4 ++ lisp/ibuf-macs.el | 2 +- lisp/ibuffer.el | 166 +++++++++++++++++++++++++--------------------- 3 files changed, 95 insertions(+), 77 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index d20c71897bc..46925cd8a4f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -338,6 +338,10 @@ modal editing packages. The variable 'ibuffer-formats' configures the Ibuffer formats. Add 'recency' to the format to display the column. +*** New value 'title' for the user option 'ibuffer-use-header-line'. +Display column titles in the header line if 'ibuffer-use-header-line' is +set to 'title'. + *** New user option 'ibuffer-human-readable-size'. When non-nil, buffer sizes are shown in human readable format. diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el index ff3dc755c36..7dbc9b4125a 100644 --- a/lisp/ibuf-macs.el +++ b/lisp/ibuf-macs.el @@ -146,7 +146,7 @@ define-ibuffer-sorter `(progn (defun ,(intern (concat "ibuffer-do-sort-by-" (symbol-name name))) () ,(or documentation "No :documentation specified for this sorting method.") - (interactive) + (interactive "@") (setq ibuffer-sorting-mode ',name) (when (eq ibuffer-sorting-mode ibuffer-last-sorting-mode) (setq ibuffer-sorting-reversep (not ibuffer-sorting-reversep))) diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index cb69915e6b7..0f3600ea1ff 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -308,8 +308,10 @@ ibuffer-jump-offer-only-visible-buffers :type 'boolean) (defcustom ibuffer-use-header-line t - "If non-nil, display a header line containing current filters." - :type 'boolean) + "If non-nil, display a header line. +If the variable has the value t, the header line displays the current +filters. For the value `title', the column titles are displayed." + :type '(choice boolean (const :tag "Column titles" :value title))) (defcustom ibuffer-default-directory nil "The default directory to use for a new Ibuffer buffer. @@ -2046,59 +2048,90 @@ ibuffer-switch-format (ibuffer-update-format) (ibuffer-redisplay t)) +(defun ibuffer--format-title (element &optional header-line) + (if (stringp element) + element + (pcase-let ((`(,sym ,min ,_max ,align) element)) + ;; Ignore a negative min when we're inserting the title + (when (cl-minusp min) + (setq min (- min))) + (let* ((name (or (get sym 'ibuffer-column-name) + (error "Unknown column %s in ibuffer-formats" sym))) + (len (length name)) + (hmap (get sym 'header-mouse-map)) + (strname (if (< len min) + (ibuffer-format-column name + (- min len) + align) + name))) + (when hmap + (setq + strname + (propertize strname 'mouse-face 'highlight 'keymap + (if header-line + (define-keymap "" hmap) + hmap)))) + strname)))) + +(defun ibuffer--format-summary (element) + (if (stringp element) + (make-string (length element) ?\s) + (pcase-let ((`(,sym ,min ,_max ,align) element)) + ;; Ignore a negative min when we're inserting the title. + (when (cl-minusp min) + (setq min (- min))) + (let* ((summary + (if (get sym 'ibuffer-column-summarizer) + (funcall (get sym 'ibuffer-column-summarizer) + (get sym 'ibuffer-column-summary)) + (make-string + (length (get sym 'ibuffer-column-name)) + ?\s))) + (len (length summary))) + (if (< len min) + (ibuffer-format-column summary + (- min len) + align) + summary))))) + (defun ibuffer-update-title-and-summary (format) (ibuffer-assert-ibuffer-mode) ;; Don't do funky font-lock stuff here (let ((inhibit-modification-hooks t)) - (if (get-text-property (point-min) 'ibuffer-title) - (delete-region (point-min) - (next-single-property-change - (point-min) 'ibuffer-title))) - (goto-char (point-min)) - (add-text-properties - (point) - (progn - (let ((opos (point))) - ;; Insert the title names. - (dolist (element format) - (insert - (if (stringp element) - element - (pcase-let ((`(,sym ,min ,_max ,align) element)) - ;; Ignore a negative min when we're inserting the title - (when (cl-minusp min) - (setq min (- min))) - (let* ((name (or (get sym 'ibuffer-column-name) - (error "Unknown column %s in ibuffer-formats" sym))) - (len (length name)) - (hmap (get sym 'header-mouse-map)) - (strname (if (< len min) - (ibuffer-format-column name - (- min len) - align) - name))) - (when hmap - (setq - strname - (propertize strname 'mouse-face 'highlight 'keymap hmap))) - strname))))) - (add-text-properties opos (point) '(ibuffer-title-header t)) - (insert "\n") - ;; Add the underlines - (let ((str (save-excursion - (forward-line -1) - (beginning-of-line) - (buffer-substring (point) (line-end-position))))) - (apply #'insert (mapcar - (lambda (c) - (if (not (or (eq c ?\s) - (eq c ?\n))) - ?- - ?\s)) - str))) - (insert "\n")) - (point)) - `(ibuffer-title t font-lock-face ,ibuffer-title-face)) + ;; Insert the title names. + (if (eq ibuffer-use-header-line 'title) + (setq header-line-format + `("" header-line-indent + ,(propertize " " 'display + '(space :align-to header-line-indent-width)) + ,@(mapcar (lambda (e) (ibuffer--format-title e t)) format))) + (if (get-text-property (point-min) 'ibuffer-title) + (delete-region (point-min) + (next-single-property-change + (point-min) 'ibuffer-title))) + (goto-char (point-min)) + (add-text-properties + (point) + (progn + (let ((opos (point))) + (apply #'insert (mapcar #'ibuffer--format-title format)) + (add-text-properties opos (point) '(ibuffer-title-header t)) + (insert "\n") + ;; Add the underlines + (let ((str (save-excursion + (forward-line -1) + (beginning-of-line) + (buffer-substring (point) (line-end-position))))) + (apply #'insert (mapcar + (lambda (c) + (if (not (or (eq c ?\s) + (eq c ?\n))) + ?- + ?\s)) + str))) + (insert "\n")) + (point)) + `(ibuffer-title t font-lock-face ,ibuffer-title-face))) ;; Now, insert the summary columns. (goto-char (point-max)) (if (get-text-property (1- (point-max)) 'ibuffer-summary) @@ -2110,27 +2143,7 @@ ibuffer-update-title-and-summary (point) (progn (insert "\n") - (dolist (element format) - (insert - (if (stringp element) - (make-string (length element) ?\s) - (pcase-let ((`(,sym ,min ,_max ,align) element)) - ;; Ignore a negative min when we're inserting the title. - (when (cl-minusp min) - (setq min (- min))) - (let* ((summary - (if (get sym 'ibuffer-column-summarizer) - (funcall (get sym 'ibuffer-column-summarizer) - (get sym 'ibuffer-column-summary)) - (make-string - (length (get sym 'ibuffer-column-name)) - ?\s))) - (len (length summary))) - (if (< len min) - (ibuffer-format-column summary - (- min len) - align) - summary)))))) + (apply #'insert (mapcar #'ibuffer--format-summary format)) (point)) '(ibuffer-summary t))))) @@ -2195,10 +2208,11 @@ ibuffer-update ;; I tried to update this automatically from the mode-line-process format, ;; but changing nil-ness of header-line-format while computing ;; mode-line-format is asking a bit too much it seems. --Stef - (setq header-line-format - (and ibuffer-use-header-line - ibuffer-filtering-qualifiers - ibuffer-header-line-format))) + (unless (eq ibuffer-use-header-line 'title) + (setq header-line-format + (and ibuffer-use-header-line + ibuffer-filtering-qualifiers + ibuffer-header-line-format)))) (defun ibuffer-sort-bufferlist (bmarklist) (unless ibuffer-sorting-functions-alist -- 2.45.2 --=-=-=-- From unknown Mon Jun 23 07:52:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#75497: [PATCH] ibuffer: Display column titles in header line Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Jan 2025 10:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75497 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Daniel Mendler Cc: 75497@debbugs.gnu.org Received: via spool by 75497-submit@debbugs.gnu.org id=B75497.173719541326158 (code B ref 75497); Sat, 18 Jan 2025 10:17:02 +0000 Received: (at 75497) by debbugs.gnu.org; 18 Jan 2025 10:16:53 +0000 Received: from localhost ([127.0.0.1]:40287 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tZ5sr-0006no-BC for submit@debbugs.gnu.org; Sat, 18 Jan 2025 05:16:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38230) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tZ5so-0006nT-9u for 75497@debbugs.gnu.org; Sat, 18 Jan 2025 05:16:52 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tZ5si-0000u7-Ga; Sat, 18 Jan 2025 05:16:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=mxm7cMZO6BmYq3dmZWYonqWIdWTB91f6rmkOoBGMki0=; b=rxkHTmM3ChZt ZFhYymljPZZjrhs7Tnm9Loy4QyDuPb9zt22EjKgV8TkmiYMaa3/np/KsZKSvHXJmWP6XjZllNnIqr +nqq+8ekmbNvPpVghNKGyOj+3klG1FG15MREabDo744VkimMIcR+mFzXObIEF/5YtKnITjBwhqoR1 Osl1fL6R5KIFtmzQLrIiM8bLkGpdHuUmRcJCfsxGwI1NRIdVYFuA63RQdLd9mOuKdTe925PTiA7gY nx+ZeXL8kxRSGMw7bgvY1xmAUPInc6Y1g7fGltsnL6jG0KE0hsSxAyejrQVCNcewLer/5vwpKxEhQ NV+77gL9Ux9b729T3/3Egg==; Date: Sat, 18 Jan 2025 12:16:40 +0200 Message-Id: <86ed10bf5j.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87ed18p5to.fsf@daniel-mendler.de> (bug-gnu-emacs@gnu.org) References: <87cygt9w73.fsf@daniel-mendler.de> <87ed18p5to.fsf@daniel-mendler.de> X-Spam-Score: -2.3 (--) 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: -3.3 (---) > Date: Sun, 12 Jan 2025 13:36:19 +0100 > From: Daniel Mendler via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Daniel Mendler writes: > > > Add new option value `title' to the customization option > > `ibuffer-use-header-line'. For this value show the column titles in the > > Ibuffer header line. > > I have attached an improved version of the patch to this mail. I have > added an "@" interactive spec to the sort commands, such that clicking > on the header line works when the Ibuffer window is not selected. Thanks. > (defcustom ibuffer-use-header-line t > - "If non-nil, display a header line containing current filters." > - :type 'boolean) > + "If non-nil, display a header line. > +If the variable has the value t, the header line displays the current "Variable has value" sounds weird. I suggest "If the variable's value is t, ..." instead. > +filters. For the value `title', the column titles are displayed." ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Passive tense alert! > + (pcase-let ((`(,sym ,min ,_max ,align) element)) > + ;; Ignore a negative min when we're inserting the title Please end this comment with a period, to make it a complete sentence. Also, this comment explains what the code does, but not why (yes, I know the original code did that as well). If you know the reason, please add that to the comment. From unknown Mon Jun 23 07:52:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#75497: [PATCH] ibuffer: Display column titles in header line Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Jan 2025 10:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75497 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: 75497@debbugs.gnu.org Received: via spool by 75497-submit@debbugs.gnu.org id=B75497.17371964528817 (code B ref 75497); Sat, 18 Jan 2025 10:35:02 +0000 Received: (at 75497) by debbugs.gnu.org; 18 Jan 2025 10:34:12 +0000 Received: from localhost ([127.0.0.1]:40342 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tZ69b-0002I8-3Z for submit@debbugs.gnu.org; Sat, 18 Jan 2025 05:34:11 -0500 Received: from server.qxqx.de ([2a01:4f8:c012:9177::1]:52211 helo=mail.qxqx.de) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tZ69X-0002HZ-VI for 75497@debbugs.gnu.org; Sat, 18 Jan 2025 05:34:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=E42wz6FpVT+o4pucK5EYS7rQPlsrrqV/IME8xVfQFQ8=; b=GLnlCjlwCiF0DgLIVhP0twWlWF P4yH9f+CXSFNRpKnJy33Vgn8518tQf9Gh193NZT8Oef67t6jEWyoIntdqZqSdnxyYOLXm3ZMEQdYs CY36F4RSHw+EqQONq7wuxAzEisRZAL8YEAVgzzNnHQExiw+xBX0P2oRxm0wNoh+u+MoI=; From: Daniel Mendler In-Reply-To: <86ed10bf5j.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 18 Jan 2025 12:16:40 +0200") References: <87cygt9w73.fsf@daniel-mendler.de> <87ed18p5to.fsf@daniel-mendler.de> <86ed10bf5j.fsf@gnu.org> Date: Sat, 18 Jan 2025 11:34:01 +0100 Message-ID: <87bjw4csx2.fsf@daniel-mendler.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) 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 Eli Zaretskii writes: >> Date: Sun, 12 Jan 2025 13:36:19 +0100 >> From: Daniel Mendler via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> Daniel Mendler writes: >> >> > Add new option value `title' to the customization option >> > `ibuffer-use-header-line'. For this value show the column titles in the >> > Ibuffer header line. >> >> I have attached an improved version of the patch to this mail. I have >> added an "@" interactive spec to the sort commands, such that clicking >> on the header line works when the Ibuffer window is not selected. > > Thanks. > >> (defcustom ibuffer-use-header-line t >> - "If non-nil, display a header line containing current filters." >> - :type 'boolean) >> + "If non-nil, display a header line. >> +If the variable has the value t, the header line displays the current > > "Variable has value" sounds weird. I suggest "If the variable's value > is t, ..." instead. > >> +filters. For the value `title', the column titles are displayed." > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Passive tense alert! >> + (pcase-let ((`(,sym ,min ,_max ,align) element)) >> + ;; Ignore a negative min when we're inserting the title > > Please end this comment with a period, to make it a complete sentence. > > Also, this comment explains what the code does, but not why (yes, I > know the original code did that as well). If you know the reason, > please add that to the comment. Thank you. I have attached an updated patch to this mail. Daniel --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-ibuffer-Display-column-titles-in-header-line.patch >From 0eb3fdb89eba4138bd361c09ec596d7d9366cb3f Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 11 Jan 2025 16:36:56 +0100 Subject: [PATCH 2/2] ibuffer: Display column titles in header line If the option `ibuffer-use-header-line' is set to `title', display column titles in the header line. * lisp/ibuffer.el (ibuffer--format-title) (ibuffer--format-summary): New functions extracted from `ibuffer-update-title-and-summary'. (ibuffer-update-title-and-summary): Use them. (ibuffer-update): Do not always override `header-line-format'. (ibuffer-use-header-line): Update docstring and option `:type'. * lisp/ibuf-macs.el (define-ibuffer-sorter): Add "@" to the interactive specification for clicks on the header line. * etc/NEWS: Announce the change. --- etc/NEWS | 4 ++ lisp/ibuf-macs.el | 2 +- lisp/ibuffer.el | 166 +++++++++++++++++++++++++--------------------- 3 files changed, 95 insertions(+), 77 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index ad099f34541..ab59d3484e6 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -353,6 +353,10 @@ You can now set `asm-comment-char' from 'asm-mode-hook' instead. The variable 'ibuffer-formats' configures the Ibuffer formats. Add 'recency' to the format to display the column. +*** New value 'title' for the user option 'ibuffer-use-header-line'. +Display column titles in the header line if 'ibuffer-use-header-line' is +set to 'title'. + *** New user option 'ibuffer-human-readable-size'. When non-nil, buffer sizes are shown in human readable format. diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el index ff3dc755c36..7dbc9b4125a 100644 --- a/lisp/ibuf-macs.el +++ b/lisp/ibuf-macs.el @@ -146,7 +146,7 @@ define-ibuffer-sorter `(progn (defun ,(intern (concat "ibuffer-do-sort-by-" (symbol-name name))) () ,(or documentation "No :documentation specified for this sorting method.") - (interactive) + (interactive "@") (setq ibuffer-sorting-mode ',name) (when (eq ibuffer-sorting-mode ibuffer-last-sorting-mode) (setq ibuffer-sorting-reversep (not ibuffer-sorting-reversep))) diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index c0033af8435..406f1ce688c 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -310,8 +310,10 @@ ibuffer-jump-offer-only-visible-buffers :type 'boolean) (defcustom ibuffer-use-header-line t - "If non-nil, display a header line containing current filters." - :type 'boolean) + "If non-nil, display a header line. +If the variable's value is t, the header line displays the current +filters. For the value `title', display the column titles." + :type '(choice boolean (const :tag "Column titles" :value title))) (defcustom ibuffer-default-directory nil "The default directory to use for a new Ibuffer buffer. @@ -2048,59 +2050,90 @@ ibuffer-switch-format (ibuffer-update-format) (ibuffer-redisplay t)) +(defun ibuffer--format-title (element &optional header-line) + (if (stringp element) + element + (pcase-let ((`(,sym ,min ,_max ,align) element)) + ;; Ignore negative MIN, since the titles are left-aligned. + (when (cl-minusp min) + (setq min (- min))) + (let* ((name (or (get sym 'ibuffer-column-name) + (error "Unknown column %s in ibuffer-formats" sym))) + (len (length name)) + (hmap (get sym 'header-mouse-map)) + (strname (if (< len min) + (ibuffer-format-column name + (- min len) + align) + name))) + (when hmap + (setq + strname + (propertize strname 'mouse-face 'highlight 'keymap + (if header-line + (define-keymap "" hmap) + hmap)))) + strname)))) + +(defun ibuffer--format-summary (element) + (if (stringp element) + (make-string (length element) ?\s) + (pcase-let ((`(,sym ,min ,_max ,align) element)) + ;; Ignore negative MIN, since the summaries are left-aligned. + (when (cl-minusp min) + (setq min (- min))) + (let* ((summary + (if (get sym 'ibuffer-column-summarizer) + (funcall (get sym 'ibuffer-column-summarizer) + (get sym 'ibuffer-column-summary)) + (make-string + (length (get sym 'ibuffer-column-name)) + ?\s))) + (len (length summary))) + (if (< len min) + (ibuffer-format-column summary + (- min len) + align) + summary))))) + (defun ibuffer-update-title-and-summary (format) (ibuffer-assert-ibuffer-mode) ;; Don't do funky font-lock stuff here (let ((inhibit-modification-hooks t)) - (if (get-text-property (point-min) 'ibuffer-title) - (delete-region (point-min) - (next-single-property-change - (point-min) 'ibuffer-title))) - (goto-char (point-min)) - (add-text-properties - (point) - (progn - (let ((opos (point))) - ;; Insert the title names. - (dolist (element format) - (insert - (if (stringp element) - element - (pcase-let ((`(,sym ,min ,_max ,align) element)) - ;; Ignore a negative min when we're inserting the title - (when (cl-minusp min) - (setq min (- min))) - (let* ((name (or (get sym 'ibuffer-column-name) - (error "Unknown column %s in ibuffer-formats" sym))) - (len (length name)) - (hmap (get sym 'header-mouse-map)) - (strname (if (< len min) - (ibuffer-format-column name - (- min len) - align) - name))) - (when hmap - (setq - strname - (propertize strname 'mouse-face 'highlight 'keymap hmap))) - strname))))) - (add-text-properties opos (point) '(ibuffer-title-header t)) - (insert "\n") - ;; Add the underlines - (let ((str (save-excursion - (forward-line -1) - (beginning-of-line) - (buffer-substring (point) (line-end-position))))) - (apply #'insert (mapcar - (lambda (c) - (if (not (or (eq c ?\s) - (eq c ?\n))) - ?- - ?\s)) - str))) - (insert "\n")) - (point)) - `(ibuffer-title t font-lock-face ,ibuffer-title-face)) + ;; Insert the title names. + (if (eq ibuffer-use-header-line 'title) + (setq header-line-format + `("" header-line-indent + ,(propertize " " 'display + '(space :align-to header-line-indent-width)) + ,@(mapcar (lambda (e) (ibuffer--format-title e t)) format))) + (if (get-text-property (point-min) 'ibuffer-title) + (delete-region (point-min) + (next-single-property-change + (point-min) 'ibuffer-title))) + (goto-char (point-min)) + (add-text-properties + (point) + (progn + (let ((opos (point))) + (apply #'insert (mapcar #'ibuffer--format-title format)) + (add-text-properties opos (point) '(ibuffer-title-header t)) + (insert "\n") + ;; Add the underlines + (let ((str (save-excursion + (forward-line -1) + (beginning-of-line) + (buffer-substring (point) (line-end-position))))) + (apply #'insert (mapcar + (lambda (c) + (if (not (or (eq c ?\s) + (eq c ?\n))) + ?- + ?\s)) + str))) + (insert "\n")) + (point)) + `(ibuffer-title t font-lock-face ,ibuffer-title-face))) ;; Now, insert the summary columns. (goto-char (point-max)) (if (get-text-property (1- (point-max)) 'ibuffer-summary) @@ -2112,27 +2145,7 @@ ibuffer-update-title-and-summary (point) (progn (insert "\n") - (dolist (element format) - (insert - (if (stringp element) - (make-string (length element) ?\s) - (pcase-let ((`(,sym ,min ,_max ,align) element)) - ;; Ignore a negative min when we're inserting the title. - (when (cl-minusp min) - (setq min (- min))) - (let* ((summary - (if (get sym 'ibuffer-column-summarizer) - (funcall (get sym 'ibuffer-column-summarizer) - (get sym 'ibuffer-column-summary)) - (make-string - (length (get sym 'ibuffer-column-name)) - ?\s))) - (len (length summary))) - (if (< len min) - (ibuffer-format-column summary - (- min len) - align) - summary)))))) + (apply #'insert (mapcar #'ibuffer--format-summary format)) (point)) '(ibuffer-summary t))))) @@ -2197,10 +2210,11 @@ ibuffer-update ;; I tried to update this automatically from the mode-line-process format, ;; but changing nil-ness of header-line-format while computing ;; mode-line-format is asking a bit too much it seems. --Stef - (setq header-line-format - (and ibuffer-use-header-line - ibuffer-filtering-qualifiers - ibuffer-header-line-format))) + (unless (eq ibuffer-use-header-line 'title) + (setq header-line-format + (and ibuffer-use-header-line + ibuffer-filtering-qualifiers + ibuffer-header-line-format)))) (defun ibuffer-sort-bufferlist (bmarklist) (unless ibuffer-sorting-functions-alist -- 2.45.2 --=-=-=-- From unknown Mon Jun 23 07:52:15 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Daniel Mendler Subject: bug#75497: closed (Re: bug#75497: [PATCH] ibuffer: Display column titles in header line) Message-ID: References: <86zfjfuszh.fsf@gnu.org> <87cygt9w73.fsf@daniel-mendler.de> X-Gnu-PR-Message: they-closed 75497 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 75497@debbugs.gnu.org Date: Sat, 25 Jan 2025 09:46:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1737798363-7817-1" This is a multi-part message in MIME format... ------------=_1737798363-7817-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #75497: [PATCH] ibuffer: Display column titles in header line which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 75497@debbugs.gnu.org. --=20 75497: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D75497 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1737798363-7817-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 75497-done) by debbugs.gnu.org; 25 Jan 2025 09:45:47 +0000 Received: from localhost ([127.0.0.1]:48546 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tbcjb-00021Q-0E for submit@debbugs.gnu.org; Sat, 25 Jan 2025 04:45:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52722) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tbcjY-000219-Uy for 75497-done@debbugs.gnu.org; Sat, 25 Jan 2025 04:45:45 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tbcjT-0001k8-MW; Sat, 25 Jan 2025 04:45:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=GbWVAqo9pkESUBlHidkMwSOla2XeSphj2dvwtAIceV8=; b=fNUkTAilyZl7 ZrZFmqPePFJ1UKljqqMtiyQcDoqgWlycCO3wre6OA0jVzRAF8R5Sg1cHYdxrkijg1BfWG/pVVU9SA nIyvdkiX8vaQ72jM/oeLbK+tsd23TbtxBkwKFwWtdYOsMTTCPu2UkYTb6qLQ6PIUU+k9JpNDXSSA5 pMEWo0/D1+1KWJykPD4XKrHO5aA9oY0qqxbap7d7g1ET1VrZTPYtpFQSlneuEl3ptEhvJ7mKFCWHG DqnlohggyHClREy9w4W7n2RG4aqwLnbk7L519JHgDjZtWsT3YH4IJlgSi6uj9lq54ZDhGJvpT5x0D qmY7Fq5uO/QdLw6LcoBRQQ==; Date: Sat, 25 Jan 2025 11:45:38 +0200 Message-Id: <86zfjfuszh.fsf@gnu.org> From: Eli Zaretskii To: Daniel Mendler In-Reply-To: <87bjw4csx2.fsf@daniel-mendler.de> (message from Daniel Mendler on Sat, 18 Jan 2025 11:34:01 +0100) Subject: Re: bug#75497: [PATCH] ibuffer: Display column titles in header line References: <87cygt9w73.fsf@daniel-mendler.de> <87ed18p5to.fsf@daniel-mendler.de> <86ed10bf5j.fsf@gnu.org> <87bjw4csx2.fsf@daniel-mendler.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75497-done Cc: 75497-done@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: -3.3 (---) > From: Daniel Mendler > Cc: 75497@debbugs.gnu.org > Date: Sat, 18 Jan 2025 11:34:01 +0100 > > Eli Zaretskii writes: > > >> Date: Sun, 12 Jan 2025 13:36:19 +0100 > >> From: Daniel Mendler via "Bug reports for GNU Emacs, > >> the Swiss army knife of text editors" > >> > >> Daniel Mendler writes: > >> > >> > Add new option value `title' to the customization option > >> > `ibuffer-use-header-line'. For this value show the column titles in the > >> > Ibuffer header line. > >> > >> I have attached an improved version of the patch to this mail. I have > >> added an "@" interactive spec to the sort commands, such that clicking > >> on the header line works when the Ibuffer window is not selected. > > > > Thanks. > > > >> (defcustom ibuffer-use-header-line t > >> - "If non-nil, display a header line containing current filters." > >> - :type 'boolean) > >> + "If non-nil, display a header line. > >> +If the variable has the value t, the header line displays the current > > > > "Variable has value" sounds weird. I suggest "If the variable's value > > is t, ..." instead. > > > >> +filters. For the value `title', the column titles are displayed." > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > Passive tense alert! > >> + (pcase-let ((`(,sym ,min ,_max ,align) element)) > >> + ;; Ignore a negative min when we're inserting the title > > > > Please end this comment with a period, to make it a complete sentence. > > > > Also, this comment explains what the code does, but not why (yes, I > > know the original code did that as well). If you know the reason, > > please add that to the comment. > > Thank you. I have attached an updated patch to this mail. Thanks, installed on master, and closing the bug. ------------=_1737798363-7817-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 11 Jan 2025 16:01:26 +0000 Received: from localhost ([127.0.0.1]:44556 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tWdvR-0004ji-SM for submit@debbugs.gnu.org; Sat, 11 Jan 2025 11:01:26 -0500 Received: from lists.gnu.org ([2001:470:142::17]:59352) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tWdvP-0004ie-3N for submit@debbugs.gnu.org; Sat, 11 Jan 2025 11:01:23 -0500 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 1tWdvH-0000dy-Et for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2025 11:01:15 -0500 Received: from server.qxqx.de ([2a01:4f8:c012:9177::1] helo=mail.qxqx.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tWdvD-0000UY-B0 for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2025 11:01:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date: Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Ou5anRgopSxifuY2OJsb0UwTdf1YjXhqZBnerCOKfs4=; b=fRlgwy3/6pThNMh78POtraSwhH N6f5uH7U2EjJeyvaUOibA6eYfIL1UYkrW9hN+umBKMHQTWXdk0fjrF2qqxKkJQU+LbseBqDYPBfBX D312ObVlpu2Xdzh0f7H4av/dhOr8IHDSHW3+gRslPtEqRUwR+FhuZRkmQtXrOuN4zcMs=; From: Daniel Mendler To: bug-gnu-emacs@gnu.org Subject: [PATCH] ibuffer: Display column titles in header line Date: Sat, 11 Jan 2025 17:01:04 +0100 Message-ID: <87cygt9w73.fsf@daniel-mendler.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a01:4f8:c012:9177::1; envelope-from=mail@daniel-mendler.de; helo=mail.qxqx.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) 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: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch Add new option value `title' to the customization option `ibuffer-use-header-line'. For this value show the column titles in the Ibuffer header line. --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-ibuffer-Display-column-titles-in-header-line.patch >From d4f745ce0409f1d9ae956ca8cbaf102eecea8563 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 11 Jan 2025 16:36:56 +0100 Subject: [PATCH] ibuffer: Display column titles in header line If the option `ibuffer-use-header-line' is set to `title', display column titles in the header line. * lisp/ibuffer.el (ibuffer--format-title) (ibuffer--format-summary): New functions extracted from `ibuffer-update-title-and-summary'. (ibuffer-update-title-and-summary): Use them. (ibuffer-update): Do not always override `header-line-format'. (ibuffer-use-header-line): Update docstring and option `:type'. * etc/NEWS: Announce the change. --- etc/NEWS | 4 ++ lisp/ibuffer.el | 166 ++++++++++++++++++++++++++---------------------- 2 files changed, 94 insertions(+), 76 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index d20c71897bc..46925cd8a4f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -338,6 +338,10 @@ modal editing packages. The variable 'ibuffer-formats' configures the Ibuffer formats. Add 'recency' to the format to display the column. +*** New value 'title' for the user option 'ibuffer-use-header-line'. +Display column titles in the header line if 'ibuffer-use-header-line' is +set to 'title'. + *** New user option 'ibuffer-human-readable-size'. When non-nil, buffer sizes are shown in human readable format. diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index 65f8ca53693..014d8c59b25 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -308,8 +308,10 @@ ibuffer-jump-offer-only-visible-buffers :type 'boolean) (defcustom ibuffer-use-header-line t - "If non-nil, display a header line containing current filters." - :type 'boolean) + "If non-nil, display a header line. +If the variable has the value t, the header line displays the current +filters. For the value `title', the column titles are displayed." + :type '(choice boolean (const :tag "Column titles" :value title))) (defcustom ibuffer-default-directory nil "The default directory to use for a new Ibuffer buffer. @@ -2045,59 +2047,90 @@ ibuffer-switch-format (ibuffer-update-format) (ibuffer-redisplay t)) +(defun ibuffer--format-title (element &optional header-line) + (if (stringp element) + element + (pcase-let ((`(,sym ,min ,_max ,align) element)) + ;; Ignore a negative min when we're inserting the title + (when (cl-minusp min) + (setq min (- min))) + (let* ((name (or (get sym 'ibuffer-column-name) + (error "Unknown column %s in ibuffer-formats" sym))) + (len (length name)) + (hmap (get sym 'header-mouse-map)) + (strname (if (< len min) + (ibuffer-format-column name + (- min len) + align) + name))) + (when hmap + (setq + strname + (propertize strname 'mouse-face 'highlight 'keymap + (if header-line + (define-keymap "" hmap) + hmap)))) + strname)))) + +(defun ibuffer--format-summary (element) + (if (stringp element) + (make-string (length element) ?\s) + (pcase-let ((`(,sym ,min ,_max ,align) element)) + ;; Ignore a negative min when we're inserting the title. + (when (cl-minusp min) + (setq min (- min))) + (let* ((summary + (if (get sym 'ibuffer-column-summarizer) + (funcall (get sym 'ibuffer-column-summarizer) + (get sym 'ibuffer-column-summary)) + (make-string + (length (get sym 'ibuffer-column-name)) + ?\s))) + (len (length summary))) + (if (< len min) + (ibuffer-format-column summary + (- min len) + align) + summary))))) + (defun ibuffer-update-title-and-summary (format) (ibuffer-assert-ibuffer-mode) ;; Don't do funky font-lock stuff here (let ((inhibit-modification-hooks t)) - (if (get-text-property (point-min) 'ibuffer-title) - (delete-region (point-min) - (next-single-property-change - (point-min) 'ibuffer-title))) - (goto-char (point-min)) - (add-text-properties - (point) - (progn - (let ((opos (point))) - ;; Insert the title names. - (dolist (element format) - (insert - (if (stringp element) - element - (pcase-let ((`(,sym ,min ,_max ,align) element)) - ;; Ignore a negative min when we're inserting the title - (when (cl-minusp min) - (setq min (- min))) - (let* ((name (or (get sym 'ibuffer-column-name) - (error "Unknown column %s in ibuffer-formats" sym))) - (len (length name)) - (hmap (get sym 'header-mouse-map)) - (strname (if (< len min) - (ibuffer-format-column name - (- min len) - align) - name))) - (when hmap - (setq - strname - (propertize strname 'mouse-face 'highlight 'keymap hmap))) - strname))))) - (add-text-properties opos (point) '(ibuffer-title-header t)) - (insert "\n") - ;; Add the underlines - (let ((str (save-excursion - (forward-line -1) - (beginning-of-line) - (buffer-substring (point) (line-end-position))))) - (apply #'insert (mapcar - (lambda (c) - (if (not (or (eq c ?\s) - (eq c ?\n))) - ?- - ?\s)) - str))) - (insert "\n")) - (point)) - `(ibuffer-title t font-lock-face ,ibuffer-title-face)) + ;; Insert the title names. + (if (eq ibuffer-use-header-line 'title) + (setq header-line-format + `("" header-line-indent + ,(propertize " " 'display + '(space :align-to header-line-indent-width)) + ,@(mapcar (lambda (e) (ibuffer--format-title e t)) format))) + (if (get-text-property (point-min) 'ibuffer-title) + (delete-region (point-min) + (next-single-property-change + (point-min) 'ibuffer-title))) + (goto-char (point-min)) + (add-text-properties + (point) + (progn + (let ((opos (point))) + (apply #'insert (mapcar #'ibuffer--format-title format)) + (add-text-properties opos (point) '(ibuffer-title-header t)) + (insert "\n") + ;; Add the underlines + (let ((str (save-excursion + (forward-line -1) + (beginning-of-line) + (buffer-substring (point) (line-end-position))))) + (apply #'insert (mapcar + (lambda (c) + (if (not (or (eq c ?\s) + (eq c ?\n))) + ?- + ?\s)) + str))) + (insert "\n")) + (point)) + `(ibuffer-title t font-lock-face ,ibuffer-title-face))) ;; Now, insert the summary columns. (goto-char (point-max)) (if (get-text-property (1- (point-max)) 'ibuffer-summary) @@ -2109,27 +2142,7 @@ ibuffer-update-title-and-summary (point) (progn (insert "\n") - (dolist (element format) - (insert - (if (stringp element) - (make-string (length element) ?\s) - (pcase-let ((`(,sym ,min ,_max ,align) element)) - ;; Ignore a negative min when we're inserting the title. - (when (cl-minusp min) - (setq min (- min))) - (let* ((summary - (if (get sym 'ibuffer-column-summarizer) - (funcall (get sym 'ibuffer-column-summarizer) - (get sym 'ibuffer-column-summary)) - (make-string - (length (get sym 'ibuffer-column-name)) - ?\s))) - (len (length summary))) - (if (< len min) - (ibuffer-format-column summary - (- min len) - align) - summary)))))) + (apply #'insert (mapcar #'ibuffer--format-summary format)) (point)) '(ibuffer-summary t))))) @@ -2194,10 +2207,11 @@ ibuffer-update ;; I tried to update this automatically from the mode-line-process format, ;; but changing nil-ness of header-line-format while computing ;; mode-line-format is asking a bit too much it seems. --Stef - (setq header-line-format - (and ibuffer-use-header-line - ibuffer-filtering-qualifiers - ibuffer-header-line-format))) + (unless (eq ibuffer-use-header-line 'title) + (setq header-line-format + (and ibuffer-use-header-line + ibuffer-filtering-qualifiers + ibuffer-header-line-format)))) (defun ibuffer-sort-bufferlist (bmarklist) (unless ibuffer-sorting-functions-alist -- 2.45.2 --=-=-=-- ------------=_1737798363-7817-1-- From unknown Mon Jun 23 07:52:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#75497: [PATCH] ibuffer: Display column titles in header line Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Jan 2025 09:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75497 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: 75497-done@debbugs.gnu.org Received: via spool by 75497-done@debbugs.gnu.org id=D75497.173788252410568 (code D ref 75497); Sun, 26 Jan 2025 09:09:02 +0000 Received: (at 75497-done) by debbugs.gnu.org; 26 Jan 2025 09:08:44 +0000 Received: from localhost ([127.0.0.1]:54375 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tbydH-0002kO-MJ for submit@debbugs.gnu.org; Sun, 26 Jan 2025 04:08:43 -0500 Received: from server.qxqx.de ([2a01:4f8:c012:9177::1]:36619 helo=mail.qxqx.de) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tbydF-0002jx-N7 for 75497-done@debbugs.gnu.org; Sun, 26 Jan 2025 04:08:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=f1VCrI4vOQqThwvopGYIjTiLFjO+DqrXmyXg5mi0ayU=; b=LlUG6YBc49Ri0SyaSicoqnJ3Qq zAJtKAuBvilM8IWbjb0JulbvOe5nc4ZMpo8SGidk7Hq/TnpVb9BmmNypZF+cbH3s2Sge0kKqJpoYo KadKvwz/4w63ZLpXqj4BLLajz1UAAvh0LpxUVHVBwT3yRwAdduhyz21Kz2wMgelTUuz4=; From: Daniel Mendler In-Reply-To: <86zfjfuszh.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 25 Jan 2025 11:45:38 +0200") References: <87cygt9w73.fsf@daniel-mendler.de> <87ed18p5to.fsf@daniel-mendler.de> <86ed10bf5j.fsf@gnu.org> <87bjw4csx2.fsf@daniel-mendler.de> <86zfjfuszh.fsf@gnu.org> Date: Sun, 26 Jan 2025 10:08:32 +0100 Message-ID: <87ed0q7xin.fsf@daniel-mendler.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) 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 (-) Eli Zaretskii writes: > Thanks, installed on master, and closing the bug. Thank you for installing the patches. Daniel