summary history branches tags files
commit:bbccda37dbcab6182a5f9a74eb4e643a8fbd540f
author:Trevor Bentley
committer:Trevor Bentley
date:Tue Dec 8 00:29:42 2020 +0100
parents:64bbd67e158252d796127fc661a7b3cce9116279
fix all errors and warnings when byte compiled
diff --git a/snitch-backtrace.el b/snitch-backtrace.el
line changes: +19/-15
index 743e9b2..8b1ad50
--- a/snitch-backtrace.el
+++ b/snitch-backtrace.el
@@ -199,20 +199,26 @@ 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* ((frames (backtrace-get-frames))
+         ;; 5 is the magic number of frames to skip out of the
+         ;; snitch-related calls (0 indexed, so idx > 4):
+         ;;
+         ;; 1) backtrace-get-frames
+         ;; 2) let (here in snitch--backtrace)
+         ;; 3) snitch--backtrace
+         ;; 4) let* (in snitch wrapper functions)
+         ;; 5) snitch wrapper fn (ex: snitch--wrap-make-network-process)
+         ;;
+         ;; This only works correctly if all of snitch’s hooking
+         ;;functions immediately call (snitch-backtrace) in a let block.
+         ;;
+         ;; The second frame, ’let’, is mysteriously absent when this
+         ;; package is byte-compiled.
+         (skip-frames (if (eq 'let* (backtrace-frame-fun (nth 1 frames)))
+                          4
+                        3)))
     (dotimes (idx (length frames))
-      ;; 5 is the magic number of frames to skip out of the
-      ;; snitch-related calls (0 indexed, so idx > 4):
-      ;;
-      ;; 1) backtrace-get-frames
-      ;; 2) let (here in snitch--backtrace)
-      ;; 3) snitch--backtrace
-      ;; 4) let* (in snitch wrapper functions)
-      ;; 5) snitch wrapper fn (ex: snitch--wrap-make-network-process)
-      ;;
-      ;; This only works correctly if all of snitch’s hooking
-      ;;functions immediately call (snitch-backtrace) in a let block.
-      (if (> idx 4) ; skip frames in snitch
+      (if (> idx skip-frames)
           (let* ((frame (nth idx frames))
                  (fun (backtrace-frame-fun frame))
                  ;; if function is a lambda, just send back the
@@ -235,8 +241,6 @@ concatenated together."
                               'compiled-function)
                              (t fun)))
                  (path (snitch--find-function-file fun))
-                 (file (if path (file-name-base path) nil))
-                 (dir (if path (file-name-directory path) nil))
                  (package (if path (snitch--package-from-path path) nil)))
             ;; if function is the timer handler, save its timer object
             ;; to lookup the backtrace for that timer later

diff --git a/snitch-log.el b/snitch-log.el
line changes: +68/-65
index 683f929..173ce96
--- a/snitch-log.el
+++ b/snitch-log.el
@@ -114,7 +114,7 @@ log message. "
    ;; process events
    ((snitch-process-entry-p event)
     (propertize logmsg
-                'snitch-class snitch-process-entry
+                'snitch-class 'snitch-process-entry
                 'snitch-src-fn (oref event src-fn)
                 'snitch-src-path (oref event src-path)
                 'snitch-src-pkg (oref event src-pkg)
@@ -124,7 +124,7 @@ log message. "
    ;; network events
    ((snitch-network-entry-p event)
     (propertize logmsg
-                'snitch-class snitch-network-entry
+                'snitch-class 'snitch-network-entry
                 'snitch-src-fn (oref event src-fn)
                 'snitch-src-path (oref event src-path)
                 'snitch-src-pkg (oref event src-pkg)
@@ -294,13 +294,15 @@ the filter to the customization variable if appropriate."
   (when (null snitch--log-filter-buffer)
     (snitch--init-log-filter-buffer))
   ;; set initial contents of buffer so it opens to the correct size
-  (snitch--redraw-log-filter-buffer event fields)
+  (snitch--redraw-log-filter-buffer event nil)
   ;; display window
   (snitch--show-log-filter-window)
   ;; read user input continuously until saved or aborted
-  (setq finished nil)
-  (setq fields '())
-  (let ((key-map (snitch--log-filter-map event)))
+  (let ((fields nil)
+        (finished nil)
+        (slot-value-alist nil)
+        (black-white nil)
+        (key-map (snitch--log-filter-map event)))
     (while (not finished)
       ;; redraw to update font properties
       (snitch--redraw-log-filter-buffer event fields)
@@ -322,40 +324,38 @@ the filter to the customization variable if appropriate."
             (when slot
               (if (member slot fields)
                   (setq fields (delete slot fields))
-                (setq fields (cons slot fields))))))))))
-  ;; close filter window
-  (snitch--hide-log-filter-window snitch--log-filter-buffer)
-  ;; generate filter
-  (when fields
-    (setq slot-value-alist '())
-    ;; make an alist of (slot . value) pairs for the filter function
-    ;; to match against
-    (cl-loop for slot in fields
-             do
-             (setq slot-value-alist
-                   (cons (cons slot (eieio-oref event slot)) slot-value-alist)))
-    ;; query user for whether this should go in blacklist or whitelist
-    (setq black-white nil)
-    (while (null black-white)
-      (let* ((key (read-key-sequence "[b]lacklist or [w]hitelist? ")))
-        (cond
-         ;; ignore, probably a control character (arrow keys, etc)
-         ;; must come first to short-circuit before string comparisons
-         ((not (stringp key)) nil)
-         ((string-equal key "b") (setq black-white "blacklist"))
-         ((string-equal key "w") (setq black-white "whitelist")))))
-    ;; append the new entry to the correct defcustom list, and
-    ;; save as default customization.
-    (let* ((filter (cons #'snitch-filter/log-filter slot-value-alist))
-           (orig-list (cond
-                       ((snitch-network-entry-p event)
-                        (intern-soft (format "snitch-network-%s" black-white)))
-                       ((snitch-process-entry-p event)
-                        (intern-soft (format "snitch-process-%s" black-white)))
-                       (t nil)))
-           (orig-val (eval orig-list))
-           (new-list (cons filter orig-val)))
-      (customize-save-variable orig-list new-list))))
+                (setq fields (cons slot fields)))))))))
+    ;; close filter window
+    (snitch--hide-log-filter-window snitch--log-filter-buffer)
+    ;; generate filter
+    (when fields
+      ;; make an alist of (slot . value) pairs for the filter function
+      ;; to match against
+      (cl-loop for slot in fields
+               do
+               (setq slot-value-alist
+                     (cons (cons slot (eieio-oref event slot)) slot-value-alist)))
+      ;; query user for whether this should go in blacklist or whitelist
+      (while (null black-white)
+        (let* ((key (read-key-sequence "[b]lacklist or [w]hitelist? ")))
+          (cond
+           ;; ignore, probably a control character (arrow keys, etc)
+           ;; must come first to short-circuit before string comparisons
+           ((not (stringp key)) nil)
+           ((string-equal key "b") (setq black-white "blacklist"))
+           ((string-equal key "w") (setq black-white "whitelist")))))
+      ;; append the new entry to the correct defcustom list, and
+      ;; save as default customization.
+      (let* ((filter (cons #'snitch-filter/log-filter slot-value-alist))
+             (orig-list (cond
+                         ((snitch-network-entry-p event)
+                          (intern-soft (format "snitch-network-%s" black-white)))
+                         ((snitch-process-entry-p event)
+                          (intern-soft (format "snitch-process-%s" black-white)))
+                         (t nil)))
+             (orig-val (eval orig-list))
+             (new-list (cons filter orig-val)))
+        (customize-save-variable orig-list new-list)))))
 
 (defun snitch--log-filter-map-slot-from-key (map key)
   "Given a map from ‘snitch--log-filter-map’, returns the slot
@@ -373,31 +373,34 @@ brackets.  The correct set of fields is returned based on the
 given event type.  All of this stuff is used to display the
 fields, and to interpret which field to select when receiving
 user keypresses."
-  (setq common-alist
-        '((src-fn . (key "f" name "function"
-                         mnemonic-name "[f]unction"))
-          (src-path . (key "p" name "path"
-                           mnemonic-name "[p]ath"))
-          (src-pkg . (key "k" name "package"
-                          mnemonic-name "pac[k]age"))
-          (proc-name . (key "n" name "name"
-                          mnemonic-name "[n]ame"))))
-  (setq network-alist
-        '((host . (key "h" name "host"
-                       mnemonic-name "[h]ost"))
-          (port . (key "o" name "port"
-                       mnemonic-name "p[o]rt"))
-          (family . (key "m" name "family"
-                       mnemonic-name "fa[m]ily"))))
-  (setq process-alist
-        '((executable . (key "x"name "executable"
-                             mnemonic-name "e[x]ecutable"))
-          (args . (key "g" name "args"
-                       mnemonic-name "ar[g]s"))))
-  (cond
-   ((snitch-network-entry-p event) (append common-alist network-alist))
-   ((snitch-process-entry-p event) (append common-alist process-alist))
-   (t common-alist)))
+  (let ((common-alist nil)
+        (network-alist nil)
+        (process-alist nil))
+    (setq common-alist
+          '((src-fn . (key "f" name "function"
+                           mnemonic-name "[f]unction"))
+            (src-path . (key "p" name "path"
+                             mnemonic-name "[p]ath"))
+            (src-pkg . (key "k" name "package"
+                            mnemonic-name "pac[k]age"))
+            (proc-name . (key "n" name "name"
+                              mnemonic-name "[n]ame"))))
+    (setq network-alist
+          '((host . (key "h" name "host"
+                         mnemonic-name "[h]ost"))
+            (port . (key "o" name "port"
+                         mnemonic-name "p[o]rt"))
+            (family . (key "m" name "family"
+                           mnemonic-name "fa[m]ily"))))
+    (setq process-alist
+          '((executable . (key "x"name "executable"
+                               mnemonic-name "e[x]ecutable"))
+            (args . (key "g" name "args"
+                         mnemonic-name "ar[g]s"))))
+    (cond
+     ((snitch-network-entry-p event) (append common-alist network-alist))
+     ((snitch-process-entry-p event) (append common-alist process-alist))
+     (t common-alist))))
 
 (defun snitch--redraw-log-filter-buffer (evt selected)
   "Draw the text contents of the log-filter menu based on the

diff --git a/snitch-timer.el b/snitch-timer.el
line changes: +2/-2
index 346a5c7..ad2517d
--- a/snitch-timer.el
+++ b/snitch-timer.el
@@ -194,7 +194,7 @@ modification and returns the result."
 (defun snitch--remove-timed-out-timers ()
   "Iterate of all of snitch's saved timer backtraces and remove
 any that have timed out."
-  (cl-loop for (timer . (bt . timeout-fn)) in snitch--timer-alist
+  (cl-loop for (timer . (_bt . timeout-fn)) in snitch--timer-alist
            when (funcall timeout-fn)
            do
            (let ((match (assq timer snitch--timer-alist)))
@@ -308,7 +308,7 @@ log.  If ALIST is t, also prints the currently cached timers."
   (message "timer missed: %d" snitch--timer-missed-count)
   (when alist
     (message "timer alist: %s" snitch--timer-alist)
-    (cl-loop for (timer . (bt . timeout-fn)) in snitch--timer-alist
+    (cl-loop for (_timer . (_bt . timeout-fn)) in snitch--timer-alist
              do (message "timeout? %s" (funcall timeout-fn)))))
 
 (defun snitch--activate-timer-trace ()