about summary refs log tree commit diff
path: root/exwm-core.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2018-09-16T00·00+0000
committerChris Feng <chris.w.feng@gmail.com>2018-09-16T00·00+0000
commit472f7cb82b67b98843f10c12e6bda9b8ae7262bc (patch)
tree3334598fdbf61f3964a039dbbd767d49c644ee3c /exwm-core.el
parent5903080b6efba91f6809c2a505a1069e46d8c277 (diff)
Simplify debugging and fix dynamic-scoping `eval'
* exwm-core.el (exwm-debug): New global minor mode to replace
`exwm-debug-on' and `exwm-debug-toggle'.

* exwm-manage.el (exwm-manage--get-configurations): Use
lexical-scoping `eval'.
Diffstat (limited to 'exwm-core.el')
-rw-r--r--exwm-core.el20
1 files changed, 6 insertions, 14 deletions
diff --git a/exwm-core.el b/exwm-core.el
index 365e24b42681..66eb98cf905f 100644
--- a/exwm-core.el
+++ b/exwm-core.el
@@ -68,10 +68,12 @@
 (declare-function exwm-workspace-move-window "exwm-workspace.el"
                   (frame-or-index &optional id))
 
-(defvar exwm-debug-on nil "Non-nil to turn on debug for EXWM.")
+(define-minor-mode exwm-debug
+  "Debug-logging enabled if non-nil"
+  :global t)
 
 (defmacro exwm--debug (&rest forms)
-  (when exwm-debug-on `(progn ,@forms)))
+  (when exwm-debug `(progn ,@forms)))
 
 (defmacro exwm--log (&optional format-string &rest objects)
   "Emit a message prepending the name of the function being executed.
@@ -79,22 +81,12 @@
 FORMAT-STRING is a string specifying the message to output, as in
 `format'.  The OBJECTS arguments specify the substitutions."
   (unless format-string (setq format-string ""))
-  `(when exwm-debug-on
+  `(when exwm-debug
      (xcb-debug:message ,(concat "%s:\t" format-string "\n")
                         (xcb-debug:compile-time-function-name)
                         ,@objects)
      nil))
 
-(defun exwm-debug-toggle (&optional arg)
-  "Toggle EXWM debugging output.
-When ARG is positive, turn debugging on; when negative off.  When
-ARG is nil, toggle debugging output."
-  (interactive
-   (list (or current-prefix-arg 'toggle)))
-  (setq exwm-debug-on (if (eq arg 'toggle)
-                          (not exwm-debug-on)
-                        (> 0 arg))))
-
 (defsubst exwm--id->buffer (id)
   "X window ID => Emacs buffer."
   (cdr (assoc id exwm--id-buffer-alist)))
@@ -201,7 +193,7 @@ least SECS seconds later."
   (let ((map (make-sparse-keymap)))
     (define-key map "\C-c\C-d\C-l" #'xcb-debug:clear)
     (define-key map "\C-c\C-d\C-m" #'xcb-debug:mark)
-    (define-key map "\C-c\C-d\C-t" #'exwm-debug-toggle)
+    (define-key map "\C-c\C-d\C-t" #'exwm-debug)
     (define-key map "\C-c\C-f" #'exwm-layout-set-fullscreen)
     (define-key map "\C-c\C-h" #'exwm-floating-hide)
     (define-key map "\C-c\C-k" #'exwm-input-release-keyboard)