summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2020-03-28 11:00:53 +0200
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2020-03-28 11:06:37 +0200
commit935874dfc3c6a501e2b32c144c4464ebf083991c (patch)
treefa1660a46df3a5ebb98824087c5c5942e617cb0d
parentfaef1792ccb8da3471bc1765a4c49c05ab81a38b (diff)
mu4e: make logging a bit faster
-rw-r--r--mu4e/mu4e-utils.el16
1 files changed, 6 insertions, 10 deletions
diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el
index 9e7d4b7..d0b4f2e 100644
--- a/mu4e/mu4e-utils.el
+++ b/mu4e/mu4e-utils.el
@@ -987,11 +987,10 @@ in the background; otherwise, pop up a window."
;;; Logging / debugging
-(defvar mu4e~log-max-lines 1200
- "*internal* Last <n> number of lines to keep around in the buffer.")
+(defconst mu4e~log-max-size 100000
+ "Max number of characters to keep around in the log buffer.")
(defconst mu4e~log-buffer-name "*mu4e-log*"
"*internal* Name of the logging buffer.")
-
(defun mu4e-log (type frm &rest args)
"Write a message of TYPE with format-string FRM and ARGS in
*mu4e-log* buffer, if the variable mu4e-debug is non-nil. Type is
@@ -1023,13 +1022,10 @@ either 'to-server, 'from-server or 'misc. This function is meant for debugging."
;; if `mu4e-log-max-lines is specified and exceeded, clearest the oldest
;; lines
- (when (numberp mu4e~log-max-lines)
- (let ((lines (count-lines (point-min) (point-max))))
- (when (> lines mu4e~log-max-lines)
- (goto-char (point-max))
- (forward-line (- mu4e~log-max-lines lines))
- (beginning-of-line)
- (delete-region (point-min) (point)))))))))
+ (when (> (buffer-size) mu4e~log-max-size)
+ (goto-char (- (buffer-size) mu4e~log-max-size))
+ (beginning-of-line)
+ (delete-region (point-min) (point)))))))
(defun mu4e-toggle-logging ()
"Toggle between enabling/disabling debug-mode (in debug-mode,