all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Pogonyshev <pogonyshev@gmail.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: Signal `quit' in a `font-lock-fontify-region-function'
Date: Fri, 17 May 2019 00:20:04 +0200	[thread overview]
Message-ID: <CAG7Bpaon-bQfYLzbDTNPR0Fe-1i1y49dLxmek34-=UBSa1R+Kg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1803 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 2330 bytes --]

             reply	other threads:[~2019-05-16 22:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16 22:20 Paul Pogonyshev [this message]
2019-05-16 23:20 ` Signal `quit' in a `font-lock-fontify-region-function' Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2019-05-28 16:24 Paul Pogonyshev
2019-05-28 17:50 ` Stefan Monnier
2019-05-28 18:14   ` Paul Pogonyshev
2019-05-28 18:24     ` Stefan Monnier
2019-06-29 17:50 Paul Pogonyshev
2019-06-29 21:26 ` Stefan Monnier
2019-06-29 23:49   ` Paul Pogonyshev
2019-06-30  0:18     ` Stefan Monnier
2019-06-30 10:51       ` Paul Pogonyshev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAG7Bpaon-bQfYLzbDTNPR0Fe-1i1y49dLxmek34-=UBSa1R+Kg@mail.gmail.com' \
    --to=pogonyshev@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.