all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: emacs-devel@gnu.org
Subject: Re: Patch to make elp use header-line-format
Date: Mon, 31 Dec 2007 08:49:59 -0700	[thread overview]
Message-ID: <m37iiueue0.fsf@fleche.redhat.com> (raw)
In-Reply-To: <m3bq8bic3t.fsf@fleche.redhat.com> (Tom Tromey's message of "Thu\, 27 Dec 2007 23\:09\:58 -0700")

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> 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  <tromey@redhat.com>

	* 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))))

  reply	other threads:[~2007-12-31 15:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-28  6:09 Patch to make elp use header-line-format Tom Tromey
2007-12-31 15:49 ` Tom Tromey [this message]
2007-12-31 22:30   ` Richard Stallman
2007-12-31 23:26     ` Nick Roberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m37iiueue0.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.