fix more warnings when byte compiling
mkdir "$PKG"
sh gen_readme.sh
cp snitch*.el "$PKG"
+rm "$PKG/snitch-test.el"
cp README.md "$PKG"
tar -cf "$PKG.tar" "$PKG"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
+(require 'cl-macs) ; cl loops
+(require 'package) ; backtrace package sources
+(require 'backtrace)
+
+(require 'snitch-timer)
;; Since the backtrace functions might be called extremely often,
;; particularly when timer tracing is enabled, much of the metadata
‘snitch-trace-timers’ must be t for this to have any effect. If
it is enabled, and a matching timer is found, the backtraces are
concatenated together."
- (setq stack '())
- (setq timer-args 'nil)
- (let* ((frames (backtrace-get-frames))
+ (let* ((stack '())
+ (timer-args nil)
+ (frames (backtrace-get-frames))
;; 5 is the magic number of frames to skip out of the
;; snitch-related calls (0 indexed, so idx > 4):
;;
(if (eq fun #'timer-event-handler)
(setq timer-args (car (backtrace-frame-args frame))))
;;(message "frame %d: %s (%s) [%s]" idx fun path package)
- (push (list clean-fun path package) stack)))))
- (if follow-timer
- (snitch--maybe-add-timer-backtrace stack timer-args)
- (nreverse stack)))
+ (push (list clean-fun path package) stack))))
+ (if follow-timer
+ (snitch--maybe-add-timer-backtrace stack timer-args)
+ (nreverse stack))))
(defun snitch--package-type-more-important (a b)
"Return t if package type of 'a' is more important than the
;; standard output stream to a function that consumes the output
;; char by char. This must be reversed and concatenated to
;; produce the final string.
- (setq pretty-obj nil)
- (let ((old-std standard-output))
+ (let ((pretty-obj nil)
+ (old-std standard-output))
(setq standard-output (lambda (c) (setq pretty-obj (cons c pretty-obj))))
(object-write event)
(setq pretty-obj (concat (nreverse pretty-obj)))
- (setq standard-output old-std))
- pretty-obj)
+ (setq standard-output old-std)
+ pretty-obj))
(defun snitch--propertize (logmsg event)
"Add text properties to LOGMSG with elements from EVENT. This
(defun snitch--remove-timers (timers)
"Remove all timers in TIMERS from the timer backtrace cache, if
present."
- (setq total-timers (length timers))
- (setq removed-timers 0)
- (cl-loop
- for timer in timers
- do (let ((match (assq timer snitch--timer-alist)))
- (when (and (null match)
- snitch-print-timer-warnings)
- (message "*snitch warning* remove unknown timer: %s"
- (snitch--fn-repr (timer--function timer)))
- (setq snitch--timer-missed-count
- (+ snitch--timer-missed-count 1)))
- (when match
- (setq snitch--timer-removed-count
- (+ snitch--timer-removed-count 1))
- (setq removed-timers (1+ removed-timers))
- (setq snitch--timer-alist
- (delq match snitch--timer-alist)))))
- ;;(message "removed %d of %d timers" removed-timers total-timers)
- (list removed-timers total-timers))
+ (let ((total-timers (length timers))
+ (removed-timers 0))
+ (cl-loop
+ for timer in timers
+ do (let ((match (assq timer snitch--timer-alist)))
+ (when (and (null match)
+ snitch-print-timer-warnings)
+ (message "*snitch warning* remove unknown timer: %s"
+ (snitch--fn-repr (timer--function timer)))
+ (setq snitch--timer-missed-count
+ (+ snitch--timer-missed-count 1)))
+ (when match
+ (setq snitch--timer-removed-count
+ (+ snitch--timer-removed-count 1))
+ (setq removed-timers (1+ removed-timers))
+ (setq snitch--timer-alist
+ (delq match snitch--timer-alist)))))
+ ;;(message "removed %d of %d timers" removed-timers total-timers)
+ (list removed-timers total-timers)))
(defun snitch--remove-timer-backtrace (orig-fn timer)
"Remove a timer from snitch’s cache. This function is wrapped