Commit 46be8ec4 authored by Yuanle Song's avatar Yuanle Song
Browse files

add a bound for *zero-debug* buffer size;

minor update on some debug message.
parent 5400a669
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -164,13 +164,18 @@ otherwise, next single quote insert close quote")
(defvar zero-enable-debug t
  "whether to enable debug.
if t, `zero-debug' will output debug msg in *zero-debug* buffer")
(defvar zero-debug-buffer-max-size 30000
  "max characters in *zero-debug* buffer. if reached, first half data will be deleted")

(defun zero-debug (string &rest objects)
  "log debug message in *zero-debug* buffer"
  (if zero-enable-debug
      (with-current-buffer (get-buffer-create "*zero-debug*")
	(goto-char (point-max))
	(insert (apply 'format string objects))
	(goto-char (point-max)))))
	(when (> (point) zero-debug-buffer-max-size)
	  (insert "removing old data\n")
	  (delete-region (point-min) (/ zero-debug-buffer-max-size 2))))))

;; (zero-debug "msg1\n")
;; (zero-debug "msg2: %s\n" "some obj")
@@ -215,7 +220,7 @@ if t, `zero-debug' will output debug msg in *zero-debug* buffer")
       ("page_number" ,(1+ zero-current-page))
       ("has_next_page" ,(or (> (length (or candidates zero-candidates)) (* zero-candidates-per-page (1+ zero-current-page))) (< zero-fetch-size (* zero-candidates-per-page (+ 2 zero-current-page)))))
       ("has_previous_page" ,(> zero-current-page 0))))
    (zero-debug "candidates:\n  %s\n  " (s-join "\n  " candidates-on-page))
    (zero-debug "candidates: %s\n" (s-join ", " candidates-on-page))
    (destructuring-bind (x y) (zero-get-point-position)
      (zero-panel-move x y))))

+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@
		     (nth (+ n (* zero-candidates-per-page zero-current-page)) zero-pinyin-used-preedit-str-lengths))))
    (when candidate
      (zero-debug
       "zero-pinyin-commit-nth-candidate n=%s candidate=%s used-len=%s zero-pinyin-pending-preedit-str=%s\n"
       "zero-pinyin-commit-nth-candidate n=%s candidate=%s used-len=%s zero-pinyin-pending-preedit-str=%S\n"
       n candidate used-len zero-pinyin-pending-preedit-str)
      (cond
       ((null zero-pinyin-state)