; Unimportant tweaks

This commit is contained in:
Chris Feng 2018-08-19 00:00:00 +00:00
parent 33dec8d1a3
commit b6a3b7b3ad
3 changed files with 14 additions and 20 deletions

View file

@ -33,9 +33,6 @@
(require 'xcb-ewmh) (require 'xcb-ewmh)
(require 'exwm-debug) (require 'exwm-debug)
(eval-and-compile
(defvar exwm-debug-on nil "Non-nil to turn on debug for EXWM."))
(defvar exwm--connection nil "X connection.") (defvar exwm--connection nil "X connection.")
(defvar exwm--wmsn-window nil (defvar exwm--wmsn-window nil
@ -294,8 +291,8 @@ least SECS seconds later."
(exwm--debug (exwm--debug
(let ((map exwm-mode-map)) (let ((map exwm-mode-map))
(define-key map "\C-c\C-l" #'exwm-debug--clear) (define-key map "\C-c\C-l" #'exwm-debug-clear)
(define-key map "\C-c\C-m" #'exwm-debug--mark))) (define-key map "\C-c\C-m" #'exwm-debug-mark)))
(define-derived-mode exwm-mode nil "EXWM" (define-derived-mode exwm-mode nil "EXWM"
"Major mode for managing X windows. "Major mode for managing X windows.

View file

@ -1,9 +1,8 @@
;;; exwm-debug.el --- Debugging helpers for EXWM -*- lexical-binding: t -*- ;;; exwm-debug.el --- Debugging helpers for EXWM -*- lexical-binding: t -*-
;; Copyright (C) 2015-2016 Free Software Foundation, Inc. ;; Copyright (C) 2018 Free Software Foundation, Inc.
;; Author: Chris Feng <chris.w.feng@gmail.com> ;; Author: Adrián Medraño Calvo <adrian@medranocalvo.com>
;; Adrián Medraño Calvo <adrian@medranocalvo.com>
;; This file is part of GNU Emacs. ;; This file is part of GNU Emacs.
@ -29,18 +28,16 @@
(eval-and-compile (eval-and-compile
(defvar exwm-debug-on nil "Non-nil to turn on debug for EXWM.")) (defvar exwm-debug-on nil "Non-nil to turn on debug for EXWM."))
(defvar exwm-debug-buffer (defvar exwm-debug-buffer "*EXWM-DEBUG*" "Buffer to write debug messages to.")
(when exwm-debug-on
(let ((buffer (get-buffer-create "*EXWM-DEBUG*"))) (defvar exwm-debug-backtrace-start-frame 5
(buffer-disable-undo buffer) "From which frame to start collecting backtraces.")
buffer))
"Buffer to write debug messages to.")
(defun exwm-debug--call-stack () (defun exwm-debug--call-stack ()
"Return the current call stack frames." "Return the current call stack frames."
(let (frames frame (let (frames frame
;; No need to acount for our setq, while, let, ... ;; No need to acount for our setq, while, let, ...
(index 5)) (index exwm-debug-backtrace-start-frame))
(while (setq frame (backtrace-frame index)) (while (setq frame (backtrace-frame index))
(push frame frames) (push frame frames)
(cl-incf index)) (cl-incf index))
@ -64,7 +61,7 @@
(defmacro exwm-debug--with-debug-buffer (&rest forms) (defmacro exwm-debug--with-debug-buffer (&rest forms)
"Evaluate FORMS making sure `exwm-debug-buffer' is correctly updated." "Evaluate FORMS making sure `exwm-debug-buffer' is correctly updated."
`(with-current-buffer exwm-debug-buffer `(with-current-buffer (get-buffer-create exwm-debug-buffer)
(let (windows-eob) (let (windows-eob)
;; Note windows whose point is at EOB. ;; Note windows whose point is at EOB.
(dolist (w (get-buffer-window-list exwm-debug-buffer t t)) (dolist (w (get-buffer-window-list exwm-debug-buffer t t))
@ -97,13 +94,13 @@ the passed OBJECTS. See `format' for details."
(debugger (lambda (&rest _) (exwm-debug--backtrace)))) (debugger (lambda (&rest _) (exwm-debug--backtrace))))
,@forms)) ,@forms))
(defun exwm-debug--clear () (defun exwm-debug-clear ()
"Clear the debug buffer." "Clear the debug buffer."
(interactive) (interactive)
(exwm-debug--with-debug-buffer (exwm-debug--with-debug-buffer
(erase-buffer))) (erase-buffer)))
(defun exwm-debug--mark () (defun exwm-debug-mark ()
"Insert a mark in the debug buffer." "Insert a mark in the debug buffer."
(interactive) (interactive)
(exwm-debug--with-debug-buffer (exwm-debug--with-debug-buffer