[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Signal `quit' in a `font-lock-fontify-region-function'
From: |
Stefan Monnier |
Subject: |
Re: Signal `quit' in a `font-lock-fontify-region-function' |
Date: |
Sat, 29 Jun 2019 20:18:55 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> So, basically, as I understand, C-g handler in your proposal would
> look like (I know it is in C code, but...), simplified:
>
> (defun handle-C-g (...)
> (when registered-many-C-g-callback ; variable set by e.g.
> font-locking code
> (setq num-C-g-presses (1+ num-C-g-presses))
> (when (> num-C-g-presses 3)
> (funcall registered-many-C-g-callback))))
Not quite, more like:
(defvar registered-many-C-g-callback (lambda () (signal 'quit nil)))
(defvar registered-many-C-g nil)
(defun handle-C-g (...)
(when registered-many-C-g
(setq num-C-g-presses (1+ num-C-g-presses))
(when (> num-C-g-presses 3)
(funcall registered-many-C-g-callback))))
> and font-locking code would be roughly
>
> (let ((registered-many-C-g-callback (lambda () (setq font-lock-mode
> nil))))
> ; call fontification function, process its result etc.
> )
More like:
(let ((registered-many-C-g (cons "font-locking..." registered-many-C-g)))
; call fontification function, process its result etc.
)
But, yes, maybe it would provide a callback to disable font-lock-mode,
or just catch the `quit` signal and disable font-lock-mode.
> `count-C-g-presses' to t. The idea is to not invoke the "abort"
> callback immediately when the 3rd C-g is pressed, but instead let the
> iteration finish gracefully and _then_ let the higher-level code
Your bounds-extension code could re-bind registered-many-C-g-callback to
do something less drastic than disable font-lock-mode (or exit brutally
from font-lock).
Stefan