# HG changeset patch # User Nick Roberts # Date 1199143419 0 # Node ID b8ae06eabc3393d5d00d2eeb147a6d3edc8f30f9 # Parent c0ec1f746e1523087f1294137255276ba8f721f4 (elp-results): Use header-line-format for header. Move point to the start of the buffer. diff -r c0ec1f746e15 -r b8ae06eabc33 lisp/emacs-lisp/elp.el --- a/lisp/emacs-lisp/elp.el Mon Dec 31 23:21:45 2007 +0000 +++ b/lisp/emacs-lisp/elp.el Mon Dec 31 23:23:39 2007 +0000 @@ -596,20 +596,39 @@ symname))))) elp-all-instrumented-list)) ) ; end let* - (insert title) - (if (> longest titlelen) - (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") + ;; 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 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))))