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: Scheme Mode and Regular Expression Literals Date: Sat, 9 Mar 2024 14:37:12 +0100 Message-ID: <20240309143712.7d81d781@jcubic> References: <87sf105cw1.fsf@niceume.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="13160"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Mar 09 14:48: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 1rix3e-0003GP-U7 for ged-emacs-devel@m.gmane-mx.org; Sat, 09 Mar 2024 14:48:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rix2t-0000Zn-M8; Sat, 09 Mar 2024 08:47:27 -0500 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 1rix2k-0000Yq-Sg for emacs-devel@gnu.org; Sat, 09 Mar 2024 08:47:19 -0500 Original-Received: from smtpo45.poczta.onet.pl ([213.180.142.176]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rix2i-0005pR-W3 for emacs-devel@gnu.org; Sat, 09 Mar 2024 08:47:18 -0500 Original-Received: from jcubic (unknown [178.218.193.140]) (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 4TsPGd2FJZzlgSFX for ; Sat, 9 Mar 2024 14:37:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onet.pl; s=2011; t=1709991433; bh=7Ar+557mLlQh3b/K4CsnPWTZC7eBjSFCMuy9SgZbYR8=; h=Date:From:To:Subject:In-Reply-To:References:From; b=Y/7Yi/bgqlSDeLFzmpFSeVxSZRrGb79CfAkz8dgwgLn+X0radQLBOFjXsq+tA9jnG KGDGn3uHCygs7FGXPtOQIDMu973OIHD5V3kU1lPNe7FYk1u45hfYcZsHeRlefbRRVZ qWuQ/6RG+jSH1nSLPrYdvHqPD2Miv2TvMjgTaxi8= In-Reply-To: <87sf105cw1.fsf@niceume.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-redhat-linux-gnu) X-ONET_PL-MDA-SEGREGATION: 0 Received-SPF: pass client-ip=213.180.142.176; envelope-from=jcubic@onet.pl; helo=smtpo45.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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:316946 Archived-At: This is perfect, thank you. I also just noticed (while reading the docs) that GNU Kawa also have the same syntax for regular expressions. On Sat, 09 Mar 2024 11:59:10 +0900 Toshi Umehara wrote: > 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 > > Hope this helps. > -- Jakub T. Jankiewicz, Senior Front-End Developer https://jcubic.pl/me https://lips.js.org https://koduj.org