GNU bug report logs - #54704
29.0.50; Broken code assistance for Scheme libraries

Previous Next

Package: emacs;

Reported by: Rudolf Adamkovič <salutis <at> me.com>

Date: Mon, 4 Apr 2022 05:34:01 UTC

Severity: normal

Found in version 29.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Rudolf Adamkovič <salutis <at> me.com>
To: 54704 <at> debbugs.gnu.org
Subject: bug#54704: [PATCH] 29.0.50; Broken code assistance for Scheme libraries
Date: Sat, 24 Dec 2022 01:31:24 +0100
[Message part 1 (text/plain, inline)]
Rudolf Adamkovič via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:

> Hello there!

Hello to myself from the future! :-)

> The bug applies to both
>
> - R6RS libraries ("library") and
> - R7RS libraries ("define-library").
>
> A possible fix:
>
> [...]

Please see the attached patch that makes Emacs recognize R6RS/R7RS
library files, as well as, makes Emacs recognize their members.

To the Emacs maintainers: Please see the attached patch.

Thank you!

Rudy

[0001-Improve-support-for-Scheme-R6RS-and-R7RS-libraries-b.patch (text/x-patch, inline)]
From 858a6d376f94616b0ec347ed36487befb0871482 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis <at> me.com>
Date: Sat, 24 Dec 2022 01:00:32 +0100
Subject: [PATCH] Improve support for Scheme R6RS and R7RS libraries
 (bug#54704)

* etc/NEWS (Scheme mode): Document improved file-type auto-detection
and Imenu support for R6RS and R7RS Scheme libraries.
* lisp/files.el (auto-mode-alist): Associate the '.sls' (R6RS Scheme
Library Source) and '.sld' (R7RS Scheme Library Definition) file name
extensions with the Scheme mode.
* lisp/progmodes/scheme.el (scheme-imenu-generic-expression): Make
Imenu recognize the members nested (and so indented) inside of
'library' (R6RS) or 'define-library' (R7RS) forms.
---
 etc/NEWS                 | 14 ++++++++++++++
 lisp/files.el            |  2 +-
 lisp/progmodes/scheme.el | 20 +++++++++++++-------
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index af7f1050b7..ae12847ea9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -93,6 +93,20 @@ This command either fills a single paragraph in a defun, such as a
 doc-string, or a comment, or (re)indents the surrounding defun if
 point is not in a comment or a string.  It is by default bound to
 'M-q' in 'prog-mode' and all its descendants.
+
+** Scheme mode
+
++++
+*** Auto-detection of Scheme library files
+Emacs now automatically enables the Scheme mode for R6RS library
+sources ('.sls') and R7RS library definitions ('.sld').
+
++++
+*** Imenu members for R6RS and R7RS library members
+Imenu now lists the library members, such as methods and record types,
+nested inside R6RS library sources ('library') and R7RS library
+definitions ('define-library').
+
 
 * New Modes and Packages in Emacs 30.1
 
diff --git a/lisp/files.el b/lisp/files.el
index f352d3a9a7..522e4fbf93 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2850,7 +2850,7 @@ auto-mode-alist
      ("\\.emacs-places\\'" . lisp-data-mode)
      ("\\.el\\'" . emacs-lisp-mode)
      ("Project\\.ede\\'" . emacs-lisp-mode)
-     ("\\.\\(scm\\|stk\\|ss\\|sch\\)\\'" . scheme-mode)
+     ("\\.\\(scm\\|sls\\|sld\\|stk\\|ss\\|sch\\)\\'" . scheme-mode)
      ("\\.l\\'" . lisp-mode)
      ("\\.li?sp\\'" . lisp-mode)
      ("\\.[fF]\\'" . fortran-mode)
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index 8454f24356..f45d799252 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -115,7 +115,8 @@ 'scheme-mode-abbrev-table
 
 (defvar scheme-imenu-generic-expression
   `((nil
-     ,(rx bol "(define"
+     ,(rx bol (zero-or-more space)
+          "(define"
           (zero-or-one "*")
           (zero-or-one "-public")
           (one-or-more space)
@@ -123,36 +124,41 @@ scheme-imenu-generic-expression
           (group (one-or-more (or word (syntax symbol)))))
      1)
     ("Methods"
-     ,(rx bol "(define-"
+     ,(rx bol (zero-or-more space)
+          "(define-"
           (or "generic" "method" "accessor")
           (one-or-more space)
           (zero-or-one "(")
           (group (one-or-more (or word (syntax symbol)))))
      1)
     ("Classes"
-     ,(rx bol "(define-class"
+     ,(rx bol (zero-or-more space)
+          "(define-class"
           (one-or-more space)
           (zero-or-one "(")
           (group (one-or-more (or word (syntax symbol)))))
      1)
     ("Records"
-     ,(rx bol "(define-record-type"
+     ,(rx bol (zero-or-more space)
+          "(define-record-type"
           (zero-or-one "*")
           (one-or-more space)
           (group (one-or-more (or word (syntax symbol)))))
      1)
     ("Conditions"
-     ,(rx bol "(define-condition-type"
+     ,(rx bol (zero-or-more space)
+          "(define-condition-type"
           (one-or-more space)
           (group (one-or-more (or word (syntax symbol)))))
      1)
     ("Modules"
-     ,(rx bol "(define-module"
+     ,(rx bol (zero-or-more space)
+          "(define-module"
           (one-or-more space)
           (group "(" (one-or-more any) ")"))
      1)
     ("Macros"
-     ,(rx bol "("
+     ,(rx bol (zero-or-more space) "("
           (or (and "defmacro"
                    (zero-or-one "*")
                    (zero-or-one "-public"))
-- 
2.39.0

[Message part 3 (text/plain, inline)]
-- 
"Programming reliably -- must be an activity of an undeniably
mathematical nature […] You see, mathematics is about thinking, and
doing mathematics is always trying to think as well as possible."
-- Edsger W. Dijkstra, 1981

Rudolf Adamkovič <salutis <at> me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia

This bug report was last modified 2 years and 145 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.