[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Patch to make elp use header-line-format
From: |
Tom Tromey |
Subject: |
Re: Patch to make elp use header-line-format |
Date: |
Mon, 31 Dec 2007 08:49:59 -0700 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.990 (gnu/linux) |
>>>>> "Tom" == Tom Tromey <address@hidden> writes:
Tom> I was trying out elp today and noticed that it inserts titles into the
Tom> buffer. This patch changes it to use header-line-format, unless elp
Tom> is printing to stdout.
I also noticed that point is at the end of the results buffer after
M-x elp-results. That seemed weird to me, so here is an updated patch
that moves point to the start of the buffer.
Tom
ChangeLog:
2007-12-28 Tom Tromey <address@hidden>
* emacs-lisp/elp.el (elp-results): Use header-line-format for
header.
Index: emacs-lisp/elp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/elp.el,v
retrieving revision 1.41
diff -u -r1.41 elp.el
--- emacs-lisp/elp.el 9 Nov 2007 09:45:30 -0000 1.41
+++ emacs-lisp/elp.el 31 Dec 2007 16:14:27 -0000
@@ -596,20 +596,39 @@
symname)))))
elp-all-instrumented-list))
) ; end let*
- (insert title)
- (if (> longest titlelen)
+ ;; If printing to stdout, insert the header so it will print.
+ ;; Otherwise use header-line-format.
+ (setq elp-field-len (max titlelen longest))
+ (if (or elp-use-standard-output noninteractive)
(progn
- (insert-char 32 (- longest titlelen))
- (setq elp-field-len longest)))
- (insert " " cc-header " " et-header " " at-header "\n")
- (insert-char ?= elp-field-len)
- (insert " ")
- (insert-char ?= elp-cc-len)
- (insert " ")
- (insert-char ?= elp-et-len)
- (insert " ")
- (insert-char ?= elp-at-len)
- (insert "\n")
+ (insert title)
+ (if (> longest titlelen)
+ (progn
+ (insert-char 32 (- longest titlelen))))
+ (insert " " cc-header " " et-header " " at-header "\n")
+ (insert-char ?= elp-field-len)
+ (insert " ")
+ (insert-char ?= elp-cc-len)
+ (insert " ")
+ (insert-char ?= elp-et-len)
+ (insert " ")
+ (insert-char ?= elp-at-len)
+ (insert "\n"))
+ (let ((column 0))
+ (setq header-line-format
+ (mapconcat
+ (lambda (title)
+ (prog1
+ (concat
+ (propertize " "
+ 'display (list 'space :align-to column)
+ 'face 'fixed-pitch)
+ title)
+ (setq column (+ column 1
+ (if (= column 0)
+ elp-field-len
+ (length title))))))
+ (list title cc-header et-header at-header) ""))))
;; if sorting is enabled, then sort the results list. in either
;; case, call elp-output-result to output the result in the
;; buffer
@@ -621,7 +640,8 @@
(pop-to-buffer resultsbuf)
;; copy results to standard-output?
(if (or elp-use-standard-output noninteractive)
- (princ (buffer-substring (point-min) (point-max))))
+ (princ (buffer-substring (point-min) (point-max)))
+ (goto-char (point-min)))
;; reset profiling info if desired
(and elp-reset-after-results
(elp-reset-all))))