diff lisp/help.el @ 298:70ad99077275 r21-0b47

Import from CVS: tag r21-0b47
author cvs
date Mon, 13 Aug 2007 10:39:40 +0200
parents 558f606b08ae
children afd57c14dfc8
line wrap: on
line diff
--- a/lisp/help.el	Mon Aug 13 10:38:47 2007 +0200
+++ b/lisp/help.el	Mon Aug 13 10:39:40 2007 +0200
@@ -762,6 +762,26 @@
   :type 'integer
   :group 'help)
 
+(defun print-recent-messages (n)
+  "Print N most recent messages to standard-output, most recent first.
+If N is nil, all messages will be printed."
+  (save-excursion
+    (let ((buffer (get-buffer-create " *Message-Log*"))
+	  oldpoint extent)
+      (goto-char (point-max buffer) buffer)
+      (set-buffer standard-output)
+      (while (and (not (bobp buffer))
+		  (or (null n) (>= (decf n) 0)))
+	(setq oldpoint (point buffer))
+	(setq extent (extent-at oldpoint buffer
+				'message-multiline nil 'before))
+	;; If the message was multiline, move all the way to the
+	;; beginning.
+	(if extent
+	    (goto-char (extent-start-position extent) buffer)
+	  (forward-line -1 buffer))
+	(insert-buffer-substring buffer (point buffer) oldpoint)))))
+
 (defun view-lossage ()
   "Display recent input keystrokes and recent minibuffer messages.
 The number of keys shown is controlled by `view-lossage-key-count'.
@@ -781,24 +801,7 @@
      ;; reversing their order and handling multiline messages
      ;; correctly.
      (princ "\n\n\nRecent minibuffer messages (most recent first):\n\n")
-     (save-excursion
-       (let ((buffer (get-buffer-create " *Message-Log*"))
-	     (count 0)
-	     oldpoint extent)
-	 (goto-char (point-max buffer) buffer)
-	 (set-buffer standard-output)
-	 (while (and (not (bobp buffer))
-		     (< count view-lossage-message-count))
-	   (setq oldpoint (point buffer))
-	   (setq extent (extent-at oldpoint buffer
-				   'message-multiline nil 'before))
-	   ;; If the message was multiline, move all the way to the
-	   ;; beginning.
-	   (if extent
-	       (goto-char (extent-start-position extent) buffer)
-	     (forward-line -1 buffer))
-	   (insert-buffer-substring buffer (point buffer) oldpoint)
-	   (incf count)))))
+     (print-recent-messages view-lossage-message-count))
    "lossage"))
 
 (define-function 'help 'help-for-help)