From 7e581611fb1744cf5bc77f5729f3fa3461582be4 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sat, 15 Apr 2023 20:45:15 -0700 Subject: [PATCH] [oni-core] Add function to debug more hidden errors https://gist.github.com/jdtsmith/1fbcacfe677d74bbe510aec80ac0050c --- oni-core.el | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/oni-core.el b/oni-core.el index 531eac6..a0a20a5 100644 --- a/oni-core.el +++ b/oni-core.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2023.0401.230128 +;; Version: 2023.0415.204431 ;; Package-Requires: (oni-data-dir oni-embrace oni-hydra expand-region multiple-cursors gcmh diminish ws-butler which-key insert-char-preview mixed-pitch ace-window vertico marginalia orderless consult embark docstr) ;; This program is free software; you can redistribute it and/or modify @@ -452,6 +452,28 @@ _s_: String list" (slot . 0) (window-width . oni-core-fit-window-to-buffer))) +;;; Extra debugging + +;;; From https://gist.github.com/jdtsmith/1fbcacfe677d74bbe510aec80ac0050c +(defun oni-core-reraise-error (func &rest args) + "Call function FUNC with ARGS and re-raise any error which occurs. +Useful for debugging post-command hooks and filter functions, +which normally have their errors suppressed." + (condition-case err + (apply func args) + ((debug error) (signal (car err) (cdr err))))) + +(defun toggle-debug-on-hidden-errors (func) + "Toggle hidden error debugging for function FUNC." + (interactive "a") + (cond + ((advice-member-p #'oni-core-reraise-error func) + (advice-remove func #'oni-core-reraise-error) + (message "Debug on hidden errors disabled for %s" func)) + (t + (advice-add func :around #'oni-core-reraise-error) + (message "Debug on hidden errors enabled for %s" func)))) + ;;; Native Compilation (setq native-comp-async-report-warnings-errors 'silent)