From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Toshi Umehara Newsgroups: gmane.emacs.devel Subject: [PATCH] Scheme-mode: Add support for regular expression literal Date: Sat, 23 Mar 2024 11:40:47 +0900 Message-ID: <87msqpfz68.fsf@niceume.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18135"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, Eli Zaretskii , jcubic@onet.pl To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Mar 23 03:42:11 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 1rnrKj-0004XD-Lz for ged-emacs-devel@m.gmane-mx.org; Sat, 23 Mar 2024 03:42:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnrJi-0003N5-Aq; Fri, 22 Mar 2024 22:41:06 -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 1rnrJd-0003M7-VT for emacs-devel@gnu.org; Fri, 22 Mar 2024 22:41:01 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnrJZ-0001Jp-Fe; Fri, 22 Mar 2024 22:41:00 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 12B175C006A; Fri, 22 Mar 2024 22:40:53 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 22 Mar 2024 22:40:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niceume.com; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s= mesmtp; t=1711161653; x=1711248053; bh=3j15F1jCutFvRhr4DYVBmaUHa 02siuUD5KUG7AozHhU=; b=FLYPEBpkgHMUfjnd2E8vmYF1KAJMjHPou9aqj/EUW ndhYV6/pgZkk5/M3xxP6Kbpn1Kq02f71FoWiwY5l+8bhdfDqLkClEc24Ds/P8uKB ickf36h++gavulfN4d8UZw6x9jL6OLGnSQQu6vGDwH0gKfzCP4fKT+GFwMivqdhk cE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1711161653; x=1711248053; bh=3j15F1jCutFvRhr4DYVBmaUHa02siuUD5KU G7AozHhU=; b=m02Uo7RY6s2WntVzp9kS70YaSA63SSYkWAztE/xA/HcR4mfW8pu GIFnNkNj5jaXlMbg3pRHeNck3WAE5cmMybWA2bn2Px/JoU8qbIWQ5sxTjeOmE1H9 XnqxG2JBh7d7NGqEE5/oSww4SUQ8ME2LT4jvAJhqUr5Nm+mIoWoZzsfT5V5oObM0 Js7RsTFkVVgEwB803NIIOp2ZSKh16XDqXQYb5WHAHmZ+ha8w6qsYp0TMQMOnzUMp 5kFaYLbvVbe++LBPiy8clDvxJSbzZ7jw/4A7qqXxIqGT+D/HpmjTyWSTHXvRNhTR LZTuFsBUqr9nCVrkl7zVvqnLYT6ijKv7U6Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddtfedghedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufevfffkgggtsehmtderredttddtnecuhfhrohhmpefvohhshhhiucgf mhgvhhgrrhgruceothhoshhhihesnhhitggvuhhmvgdrtghomheqnecuggftrfgrthhtvg hrnhepvedtffejhfdtvdefieefkefgteelgeelfedvuedtheekiefgudduffdtjefgtdel necuffhomhgrihhnpehgnhhurdhorhhgpdhprhgrtghtihgtrghlqdhstghhvghmvgdrnh gvthenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpeht ohhshhhisehnihgtvghumhgvrdgtohhm X-ME-Proxy: Feedback-ID: iaf1147ca:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Mar 2024 22:40:51 -0400 (EDT) Received-SPF: pass client-ip=66.111.4.28; envelope-from=toshi@niceume.com; helo=out4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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:317240 Archived-At: --=-=-= Content-Type: text/plain This patch against 'scheme.el' enables scheme-mode to handle regular expression literal #/regexp/ that is availabe in some Scheme implementations such as GNU Kawa [1] and Gauche [2]. Its need was posted by Jakub [3] and init configuration was first proposed [4]. To allow multiline regular expression literal and to make the code sophisticated, Stephan has given many advices [5-7]. These advices are incorporated, and now the code works fine. Thanks Reference [1] https://www.gnu.org/software/kawa/Regular-expressions.html [2] https://practical-scheme.net/gauche/man/gauche-refe/Regular-expressions.html [3] https://lists.gnu.org/archive/html/emacs-devel/2024-02/msg00896.html [4] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00282.html [5] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00397.html [6] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00478.html [7] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00538.html --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Scheme-mode-update-for-regular-expression-literal.patch Content-Description: Enable dealing with scheme regular expression literal >From dc502360d9310408a8a72bafc2f8fa4fb120f30c Mon Sep 17 00:00:00 2001 From: niceume Date: Sun, 17 Mar 2024 09:12:32 +0900 Subject: [PATCH] Scheme-mode update for regular expression literal --- etc/NEWS | 6 ++++++ lisp/progmodes/scheme.el | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index f4b4c30855c..d2c258bc6d8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1188,6 +1188,12 @@ instead of: This allows the user to specify command line arguments to the non interactive Python interpreter specified by 'python-interpreter'. +** Scheme mode + +Scheme mode now handles regular expression literal #/regexp/ that is +available in some Scheme implementations. + + ** use-package +++ diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index 67abab6913d..d3fb40ea471 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el @@ -410,10 +410,22 @@ scheme-sexp-comment-syntax-table (defun scheme-syntax-propertize (beg end) (goto-char beg) (scheme-syntax-propertize-sexp-comment (point) end) + (scheme-syntax-propertize-regexp (point) end) (funcall (syntax-propertize-rules ("\\(#\\);" (1 (prog1 "< cn" - (scheme-syntax-propertize-sexp-comment (point) end))))) + (scheme-syntax-propertize-sexp-comment (point) end)))) + ("\\(#\\)/" (1 (when (null (nth 8 (save-excursion + (syntax-ppss + (match-beginning 0))))) + (put-text-property + (match-beginning 0) + (1+ (match-beginning 0)) + 'syntax-table (string-to-syntax "|")) + (scheme-syntax-propertize-regexp + (point) end) + nil) + ))) (point) end)) (defun scheme-syntax-propertize-sexp-comment (_ end) @@ -430,6 +442,29 @@ scheme-syntax-propertize-sexp-comment '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 t) + (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 "|")) + ))) + )) + ;;;###autoload (define-derived-mode dsssl-mode scheme-mode "DSSSL" "Major mode for editing DSSSL code. -- 2.44.0 --=-=-= Content-Type: text/plain -- Toshi (Toshihiro Umehara) --=-=-=--