From f4ad42936e0b83caca91389a977d7258b69ed40a Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 30 Apr 2015 02:27:10 +0100 Subject: * lisp/emacs-lisp/package.el: Some speed optimizations on menu refresh (package-menu--print-info): Obsolete. (package-menu--print-info-simple): New function. (package-menu--refresh): Use it, simplify code, and improve performance. * lisp/emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Tiny performance improvement. --- lisp/emacs-lisp/tabulated-list.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/tabulated-list.el') diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index 15a0914cb17..b12edc8c595 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -341,8 +341,10 @@ of column descriptors." (dotimes (n ncols) (setq x (tabulated-list-print-col n (aref cols n) x))) (insert ?\n) - (put-text-property beg (point) 'tabulated-list-id id) - (put-text-property beg (point) 'tabulated-list-entry cols))) + ;; Ever so slightly faster than calling `put-text-property' twice. + (add-text-properties + beg (point) + `(tabulated-list-id ,id tabulated-list-entry ,cols)))) (defun tabulated-list-print-col (n col-desc x) "Insert a specified Tabulated List entry at point. -- cgit v1.2.3 From a96731d7f0f0616e500583a1d3eaa912a7f0ec16 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 16 May 2015 09:52:53 +0100 Subject: * lisp/emacs-lisp/tabulated-list.el: Don't error on nil header-string (tabulated-list-init-header): Document new behavior. (tabulated-list-print-fake-header): No nothing if `tabulated-list--header-string' is nil. (tabulated-list--header-string): Add a docstring. * doc/lispref/modes.texi (Tabulated List Mode): Document it. * etc/NEWS: Document it. --- doc/lispref/modes.texi | 6 +++--- etc/NEWS | 4 ++++ lisp/emacs-lisp/tabulated-list.el | 24 ++++++++++++++---------- 3 files changed, 21 insertions(+), 13 deletions(-) (limited to 'lisp/emacs-lisp/tabulated-list.el') diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 8cb0f3db246..c325506da11 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -958,9 +958,9 @@ Menu,,, emacs, The GNU Emacs Manual}). way, specifying @code{tabulated-list-mode} as the second argument (@pxref{Derived Modes}). The body of the @code{define-derived-mode} form should specify the format of the tabulated data, by assigning -values to the variables documented below; then, it should call the -function @code{tabulated-list-init-header} to initialize the header -line. +values to the variables documented below; optionally, it can then call +the function @code{tabulated-list-init-header}, which will populate a +header with the names of the columns. The derived mode should also define a @dfn{listing command}. This, not the mode command, is what the user calls (e.g., @kbd{M-x diff --git a/etc/NEWS b/etc/NEWS index 2888c16a399..fdd0c874bad 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -205,6 +205,10 @@ font, and (iii) the specified window. `message' and related functions from displaying messages the Echo Area. The output is still logged to the *Messages* buffer. +** It is now safe for a mode that derives `tabulated-list-mode' to not +call `tabulated-list-init-header', in which case it will have no +header. + * Editing Changes in Emacs 25.1 diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index b12edc8c595..5d10b55d14c 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -179,7 +179,9 @@ If ADVANCE is non-nil, move forward by one line afterwards." table) "The `glyphless-char-display' table in Tabulated List buffers.") -(defvar tabulated-list--header-string nil) +(defvar tabulated-list--header-string nil + "Holds the header if `tabulated-list-use-header-line' is nil. +Populated by `tabulated-list-init-header'.") (defvar tabulated-list--header-overlay nil) (defun tabulated-list-init-header () @@ -243,15 +245,17 @@ If ADVANCE is non-nil, move forward by one line afterwards." (setq-local tabulated-list--header-string cols)))) (defun tabulated-list-print-fake-header () - "Insert a fake Tabulated List \"header line\" at the start of the buffer." - (goto-char (point-min)) - (let ((inhibit-read-only t)) - (insert tabulated-list--header-string "\n") - (if tabulated-list--header-overlay - (move-overlay tabulated-list--header-overlay (point-min) (point)) - (setq-local tabulated-list--header-overlay - (make-overlay (point-min) (point)))) - (overlay-put tabulated-list--header-overlay 'face 'underline))) + "Insert a fake Tabulated List \"header line\" at the start of the buffer. +Do nothing if `tabulated-list--header-string' is nil." + (when tabulated-list--header-string + (goto-char (point-min)) + (let ((inhibit-read-only t)) + (insert tabulated-list--header-string "\n") + (if tabulated-list--header-overlay + (move-overlay tabulated-list--header-overlay (point-min) (point)) + (setq-local tabulated-list--header-overlay + (make-overlay (point-min) (point)))) + (overlay-put tabulated-list--header-overlay 'face 'underline)))) (defun tabulated-list-revert (&rest ignored) "The `revert-buffer-function' for `tabulated-list-mode'. -- cgit v1.2.3