* riece.el (riece-buffer-alist): Init riece-debug-buffer.
[riece] / lisp / riece-debug.el
index abe461c..eaa1b9e 100644 (file)
 (require 'riece-globals)
 (require 'riece-options)
 
+(defun riece-debug (message &optional detail)
+  "Print a one-line debug MESSAGE at the bottom of the frame.
+If the optional 2nd argument DETAIL is specified, it is stored into
+`riece-debug-buffer'."
+  (message "riece-debug: %s" message)
+  (save-excursion
+    (set-buffer riece-debug-buffer)
+    (goto-char (point-max))
+    (let ((point (point)))
+      (if detail
+         (insert message "\n" detail "\n")
+       (insert message "\n"))
+      (goto-char point)
+      (beginning-of-line)
+      (while (not (eobp))
+       (insert "riece-debug: ")
+       (forward-line)))))
+
 (defun riece-debug-reset-standard-output ()
   "Reset `riece-temp-buffer' to be used as `standard-output'."
   (save-excursion
@@ -61,7 +79,8 @@ backtrace to standard-output."
            (goto-char (point-min))
            (if (re-search-forward "^  signal(" nil t)
                (delete-region (point-min) (match-beginning 0)))
-           (message "Error in `%s': %S\n%s" ,location error (buffer-string))))
+           (riece-debug (format "Error in `%s': %S" ,location error)
+                        (buffer-string))))
       nil)))
 
 (put 'riece-ignore-errors 'lisp-indent-function 1)