From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Scheme Mode and Regular Expression Literals Date: Thu, 14 Mar 2024 10:40:09 +0200 Message-ID: <86edcdb40m.fsf@gnu.org> References: <87sf105cw1.fsf@niceume.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40406"; mail-complaints-to="usenet@ciao.gmane.io" Cc: jcubic@onet.pl, emacs-devel@gnu.org To: Toshi Umehara , Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Mar 14 09:41:05 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 1rkge9-000AID-71 for ged-emacs-devel@m.gmane-mx.org; Thu, 14 Mar 2024 09:41:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkgdP-0002nK-Hs; Thu, 14 Mar 2024 04:40:19 -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 1rkgdO-0002nA-2Z for emacs-devel@gnu.org; Thu, 14 Mar 2024 04:40:18 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkgdL-0000DR-8K; Thu, 14 Mar 2024 04:40:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=zXtW0BluZb72/jInRluA2AffJie4HyV67H/d3Bi3lUs=; b=bjMf3lwoGjxW G1tVhXPJY3l70e6fF5Hg5VyZvW/7MLId32c2bdGEd4B0CcFVl3BxisCs5lvTIfYF6g4g3nOmrjlI7 hrD3YhQQZqit8bNYG5wW79wh0pAECK9zW6IbecUOxTo+bYuBEG9apuOb6h1E/2iMXlT6zHozJatNS zI4ri18Oln5Cd7juPfq9QkkzUp9EYmGgeEvk4MK9DcmQDmAAXpwJ4QN/wJjB0+8+PXtQIfp2wt1jq R2J81L7vcRpnZ07excOtZWJE2mMLvmm9+4rzRodBo6f6fJ5daQ9zZmhQer1JfuiGiNaknF5O7saeC w6ytx2ZQVRSOLy8OjMZfuw==; In-Reply-To: <87sf105cw1.fsf@niceume.com> (message from Toshi Umehara on Sat, 09 Mar 2024 11:59:10 +0900) 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:317039 Archived-At: > From: Toshi Umehara > Cc: emacs-devel@gnu.org > Date: Sat, 09 Mar 2024 11:59:10 +0900 > > > Regular expression literals as exist in Gauche Scheme does not seem to > work in scheme mode. #/regexp/ is not dealt as a chunk. I looked for its > solution on the Web, and reached this web page, > https://ardggy.hatenablog.jp/entry/2015/11/24/143713 (in Japanese). The > solution on the page overwrites syntax-propertize-function and adds a > new rule for regular expression literals. I got a hint from it, and have > tried to manage backslash slash ( \/ ) not to finish the literal and > backshashes of even numbers (like \\\\ ) not to work as escapes. > > Currently, the following code in init.el works for me. > > #+BEGIN_SRC > (add-hook 'scheme-mode-hook > (lambda () > (setq-local > syntax-propertize-function > (lambda (start end) > (goto-char start) > (funcall > (syntax-propertize-rules > ;; For #/regexp/ syntax > ("\\(#\\)/\\(\\\\/\\|\\\\\\\\\\|.\\)*?\\(/\\)" > (1 "|") > (3 "|")) > ;; For #; comment syntax > ("\\(#\\);" > (1 (prog1 "< cn" > (scheme-syntax-propertize-sexp-comment > (point) end))))) > (point) end)) > )) > ) > #+END_SRC Thanks. Stefan, is the below the right fix? I'm confused by the call to scheme-syntax-propertize-sexp-comment that scheme-syntax-propertize does at its very beginning -- what is it for? diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index 67abab6..a83e5dc 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el @@ -412,6 +412,11 @@ scheme-syntax-propertize (scheme-syntax-propertize-sexp-comment (point) end) (funcall (syntax-propertize-rules + ;; For #/regexp/ syntax + ("\\(#\\)/\\(\\\\/\\|\\\\\\\\\\|.\\)*?\\(/\\)" + (1 "|") + (3 "|")) + ;; For #; comment syntax ("\\(#\\);" (1 (prog1 "< cn" (scheme-syntax-propertize-sexp-comment (point) end))))) (point) end))