From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Jakub T. Jankiewicz" Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Scheme-mode: Add support for regular expression literal Date: Fri, 29 Mar 2024 00:43:23 +0100 Message-ID: <20240329004323.44c31a8d@jcubic> References: <87msqpfz68.fsf@niceume.com> <20240328123354.17588d57@jcubic> <6d79d884-e691-4223-be1b-ada141ad8f37@app.fastmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39026"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Stefan Monnier" , emacs-devel@gnu.org, "Eli Zaretskii" To: "Toshi Umehara" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 29 06:26:15 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rq4kp-0009uv-B7 for ged-emacs-devel@m.gmane-mx.org; Fri, 29 Mar 2024 06:26:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rq4jr-0004Sk-AZ; Fri, 29 Mar 2024 01:25:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rpzPG-0007RA-OI for emacs-devel@gnu.org; Thu, 28 Mar 2024 19:43:38 -0400 Original-Received: from smtpo94.poczta.onet.pl ([213.180.149.147]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rpzPE-0002Ld-0Y; Thu, 28 Mar 2024 19:43:38 -0400 Original-Received: from jcubic (unknown [185.129.113.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jcubic@onet.pl) by smtp.poczta.onet.pl (Onet) with ESMTPSA id 4V5KqJ4Sckzgr9; Fri, 29 Mar 2024 00:43:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onet.pl; s=2011; t=1711669406; bh=WZMycflUPyC0ttOP2B3iN5YiQ22Tc71P3ZgkzWdGRUU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EoCQi92TBhK0JZqTDprSpJF5adBJCKEt4Ero1XX/AX5PcB3Vl/AA/h+hnqHB9Z+vE GxPlmLkLP3Gdi6e6IFXlQq+s6W9r/pkQXnG5BegyRAAZIHRBo4092iZpGx0rXWTGXE sKqq9kL2kRC/wkwds0OPqb0h4gRMj55LX+hcgZ0o= In-Reply-To: <6d79d884-e691-4223-be1b-ada141ad8f37@app.fastmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-redhat-linux-gnu) Received-SPF: pass client-ip=213.180.149.147; envelope-from=jcubic@onet.pl; helo=smtpo94.poczta.onet.pl X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 29 Mar 2024 01:25:14 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317371 Archived-At: Yes, I can confirm it works. The comments works after a delay, it first highlight single line immediately and after a second i highlight whole expression. On Thu, 28 Mar 2024 21:40:11 +0900 "Toshi Umehara" wrote: > The code below, which works in init.el, corresponds to the updated > scheme.el . Could you try it ? > > (add-hook > 'scheme-mode-hook > (lambda () > (setq-local > syntax-propertize-function > (lambda (beg end) > (goto-char beg) > (scheme-syntax-propertize-sexp-comment2 end) > (scheme-syntax-propertize-regexp end) > (funcall > (syntax-propertize-rules > ("\\(#\\);" (1 (prog1 "< cn" > (scheme-syntax-propertize-sexp-comment2 end)))) > ("\\(#\\)/" (1 (when (null (nth 8 (save-excursion > (syntax-ppss > (match-beginning 0))))) > (put-text-property > (match-beginning 1) > (match-end 1) > 'syntax-table (string-to-syntax "|")) > (scheme-syntax-propertize-regexp end) > nil) > ))) > (point) end))))) > > (defun scheme-syntax-propertize-sexp-comment2 (end) > (let ((state (syntax-ppss))) > (when (eq 2 (nth 7 state)) > ;; It's a sexp-comment. Tell parse-partial-sexp where it ends. > (condition-case nil > (progn > (goto-char (+ 2 (nth 8 state))) > ;; FIXME: this doesn't handle the case where the sexp > ;; itself contains a #; comment. > (forward-sexp 1) > (put-text-property (1- (point)) (point) > 'syntax-table (string-to-syntax "> cn"))) > (scan-error (goto-char end)))))) > > (defun scheme-syntax-propertize-regexp (end) > (let* ((state (syntax-ppss)) > (within-str (nth 3 state)) > (start-delim-pos (nth 8 state))) > (when (and within-str > (char-equal ?# (char-after start-delim-pos))) > (while > (and > (re-search-forward "/" end 'move) > (eq -1 > (% (save-excursion > (backward-char) > (skip-chars-backward "\\\\")) 2)))) > (when (< (point) end) > (progn > (put-text-property > (match-beginning 0) > (match-end 0) > 'syntax-table (string-to-syntax "|")) > ))) > )) > -- Jakub T. Jankiewicz, Senior Front-End Developer https://jcubic.pl/me https://lips.js.org https://koduj.org