emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Signal `quit' in a `font-lock-fontify-region-function'


From: Paul Pogonyshev
Subject: Signal `quit' in a `font-lock-fontify-region-function'
Date: Fri, 17 May 2019 00:20:04 +0200

Hi,

I'm having the following, unfortunately unreproducible problem: inside a custom font-locking function condition `quit' _sometimes_ cannot be triggered with C-g. I'm sure it has nothing to do with `inhibit-quit'. For the same function in one Emacs instance it is triggerable, in another --- not. If in a certain instance it "breaks" (i.e. C-g no longer triggers `quit'), it seems to stay broken forever.

This is notoriously difficult to investigate. I came up with the following pseudo-mode (usage: M-x pretend-fontification-mode RET in a large buffer):

(define-derived-mode pretend-fontification-mode nil "PRETEND-FONTIFICATION"
  "..."
  (setq font-lock-defaults '(nil))
  (set (make-local-variable 'font-lock-fontify-region-function)
       (lambda (from to _verbose)
         ;; (message ...) doesn't seem to do anything
         (with-current-buffer "*Messages*" (with-silent-modifications (insert (format "\nPRETEND-FONTIFYING %s-%s\n" from to))))
         (let (x)
           (dotimes (k 10000000)  ; long delay in pure Lisp, i.e. not `sleep-for'
             (setq x k))))))

but as I said it is not reproducible: sometimes mashing C-g results in the following in *Messages* buffer:

Error during redisplay: (jit-lock-function ##) signaled (quit)

sometimes it doesn't. I also tried `(condition-case ... (quit ...))' inside font-locking function, but result is the same: sometimes the handler is triggered, sometimes it is not and I cannot work out any pattern. I also tried printing out values that could be relevant (inhibit-quit, quit-flag, (input-pending-p), unread-command-events), but they appear to be the same regardless of whether `quit' is still triggerable or not.

Does anyone has any idea what's going on?

Paul

P.S.: I'm not subscribed to the list, please CC answers to me.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]