all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Paul Pogonyshev <pogonyshev@gmail.com>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Signal `quit' in a `font-lock-fontify-region-function'
Date: Sat, 29 Jun 2019 20:18:55 -0400	[thread overview]
Message-ID: <jwv7e94kk2y.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAG7Bpaq3_LkrDQ3qrd19pKtJcWT0GOa0YJTjnGopYrJc8K-hwQ@mail.gmail.com> (Paul Pogonyshev's message of "Sun, 30 Jun 2019 01:49:46 +0200")

> 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




  reply	other threads:[~2019-06-30  0:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-29 17:50 Signal `quit' in a `font-lock-fontify-region-function' Paul Pogonyshev
2019-06-29 21:26 ` Stefan Monnier
2019-06-29 23:49   ` Paul Pogonyshev
2019-06-30  0:18     ` Stefan Monnier [this message]
2019-06-30 10:51       ` Paul Pogonyshev
  -- 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-05-16 22:20 Paul Pogonyshev
2019-05-16 23:20 ` Stefan Monnier

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=jwv7e94kk2y.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=pogonyshev@gmail.com \
    /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.