Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppressing errors in activities-mode-timer #25

Closed
karthink opened this issue Feb 11, 2024 · 3 comments
Closed

Suppressing errors in activities-mode-timer #25

karthink opened this issue Feb 11, 2024 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@karthink
Copy link

karthink commented Feb 11, 2024

Hi @alphapapa,

I often use Emacs with toggle-debug-on-error turned on, usually when developing a package. When the idle timer for activities fires (every five seconds by default), I get a backtrace popup for a buffer that could not be bookmarked -- eldoc for instance:

Debugger entered--Lisp error: (error "Buffer not visiting a file or directory")
  (error "Buffer not visiting a file or directory")
  (bookmark-buffer-file-name)
  (bookmark-make-record-default)
  (bookmark-make-record)
  (#f(compiled-function (buffer) "Return `activities-buffer' struct for BUFFER." #<bytecode 0x14b6006c580da493>) #<buffer *eldoc*>)
  (apply #f(compiled-function (buffer) "Return `activities-buffer' struct for BUFFER." #<bytecode 0x14b6006c580da493>) #<buffer *eldoc*> nil)
  (activity--serialize #<buffer *eldoc*>)
  (#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_25> (leaf (last . t) (pixel-width . 1135) (pixel-height . 84) (total-width . 142) (total-height . 4) (normal-height . 0.07619477006311992) (normal-width . 1.0) (parameters (window-preserved-size #<buffer *eldoc*> nil nil) (no-other-window . t) (mode-line-format . none)) (buffer "*eldoc*" (selected) (hscroll . 0) (fringes 8 8 t nil) (margins nil) (scroll-bars nil 0 t nil 0 t nil) (vscroll . 0) (dedicated) (point . 1) (start . 1))))
;; stacks omitted here
  (activities--window-state #<frame karthinks:networked_oscillators.org 0x3f95c78>)
  (activities-state)
;; stacks omitted here
  (activities-save-all)
  (apply activities-save-all nil)
  (timer-event-handler [t 0 5 0 t activities-save-all nil idle 0 nil])

I understand that activities-save-all demotes errors (via condition-case-unless-debug), so this is only a problem because I've turned on debugging. But the result is that I've had to turn off activities-mode whenever I'm working on an Emacs lisp package, which sort of defeats the purpose of using it to save state.

Is it possible to make it (via a user option perhaps) so that the idle-timer function optionally uses condition-case instead of condition-case-unless-debug?

I understand that this is not an error on the part of activities.el, so feel free to close this issue if it's out of scope.

@alphapapa
Copy link
Owner

Hi Karthik,

Believe me, I have encountered this myself, usually at the most inconvenient time, so I forgot to file an issue about it.

I thought that the new activities-anti-save-predicates option would solve this:

activities.el/activities.el

Lines 277 to 285 in 6ef5924

(defcustom activities-anti-save-predicates
'(active-minibuffer-window activities--backtrace-visible-p)
"Predicates which prevent an activity's state from being saved.
Each predicate is called without arguments, with the activity to
be saved having been activated. If any predicate returns
non-nil, the activity's state is not saved."
:type '(set (function-item active-minibuffer-window)
(function-item activities--backtrace-visible-p)
(function :tag "Other predicate")))

It calls this function:

activities.el/activities.el

Lines 734 to 740 in 6ef5924

(defun activities--backtrace-visible-p ()
"Return non-nil if a visible window is in `backtrace-mode'."
(catch :found
(walk-windows (lambda (window)
(with-selected-window window
(when (derived-mode-p 'backtrace-mode)
(throw :found t)))))))

Which should prevent it from trying to save an activity if a backtrace is visible.

Since adding that, I haven't seen the problem again. Are you sure you're using the latest version?

@alphapapa
Copy link
Owner

Well, it just happened to me again, so now I understand what you meant. :) I think the fix I just pushed should solve it. Please let me know if it happens again.

@alphapapa alphapapa added this to the 0.5 milestone Feb 11, 2024
@alphapapa alphapapa added the bug Something isn't working label Feb 11, 2024
@alphapapa alphapapa self-assigned this Feb 11, 2024
@karthink
Copy link
Author

Just updated, it appears to be fixed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants