From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Signal `quit' in a `font-lock-fontify-region-function' Date: Sat, 29 Jun 2019 20:18:55 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="207865"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Emacs developers To: Paul Pogonyshev Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 30 02:19:33 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hhNZ6-000ryM-Qj for ged-emacs-devel@m.gmane.org; Sun, 30 Jun 2019 02:19:33 +0200 Original-Received: from localhost ([::1]:42508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhNZ5-0003N8-7V for ged-emacs-devel@m.gmane.org; Sat, 29 Jun 2019 20:19:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43910) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhNYe-0003N0-QT for emacs-devel@gnu.org; Sat, 29 Jun 2019 20:19:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hhNYa-0007f6-NO for emacs-devel@gnu.org; Sat, 29 Jun 2019 20:19:03 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:43946) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hhNYZ-0007ds-WD for emacs-devel@gnu.org; Sat, 29 Jun 2019 20:19:00 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id DEB01100A37; Sat, 29 Jun 2019 20:18:57 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 95E86100955; Sat, 29 Jun 2019 20:18:56 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1561853936; bh=YAeLJ0qcJUh2+ZxFcUKJb+UOCmZCRxDdsGsmj9DGE1g=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=R27Yf7QF9PFZQqnhyZ81SqJwqKfLf0fRSoSe4n/yswxMNELGv/rIjmNbV/MHBGVyH yawPa8Cxs/mtytK3xjU/vU6ieG533LYzAyJeb/7nhg+3056zlm/GjTLUR89LLrhaif IMF2BGQWTJUBaSEcnIZnFY68S8ZVM7Qo+c8910/eE+/Dc5bqax1HYuRDZ7i0zcfnvp 34GHVacLB14GIRbJRQs9PSnIPNYZwEsy9jYrWH6kymFrUXtRbDww4Lsd08u+5ZJ6mF skJs8QaUvri/fxulcs0e1F5JgPECIocqDeFwR301jgoR5cQGEluYtAnCawDCE7/bnY Q8+C6tv1xTmlA== Original-Received: from alfajor (76-10-151-214.dsl.teksavvy.com [76.10.151.214]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4DB761207A2; Sat, 29 Jun 2019 20:18:56 -0400 (EDT) In-Reply-To: (Paul Pogonyshev's message of "Sun, 30 Jun 2019 01:49:46 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:238247 Archived-At: > 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