GNU bug report logs - #73411
31.0.50; sql-mode interacts poorly with package gnu-elpa

Previous Next

Package: emacs;

Reported by: Stephen Berman <stephen.berman <at> gmx.net>

Date: Sat, 21 Sep 2024 14:33:01 UTC

Severity: normal

Found in version 31.0.50

To reply to this bug, email your comments to 73411 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#73411; Package emacs. (Sat, 21 Sep 2024 14:33:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stephen Berman <stephen.berman <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 21 Sep 2024 14:33:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; sql-mode interacts poorly with package gnu-elpa
Date: Sat, 21 Sep 2024 16:32:05 +0200
[Message part 1 (text/plain, inline)]
0. Install the GNU ELPA package gnu-elpa.
1. emacs -Q
2. M-x package-initialize
3. Visit an SQL file (one with the extension .sql, like the attached
   file test.sql, so it will be visited in sql-mode).
4. At the prompt "Install package sql-indent? (yes or no) " type "no".
5. Now the current buffer displays the SQL file and the mode line
   displays "(SQL[ANSI])", but the buffer is not fontified and the echo
   area displays "File mode specification error: (error Abort!)".

This also happens in emacs-29 and emacs-30.  Typing `M-x
font-lock-fontify-buffer' makes the buffer correctly fontified.

When I add `M-x toggle-debug-on-error' to step 2 above and repeat the
recipe, I get the attached backtrace. According to this, running
sql-mode-hook invokes sql-indent-enable, whose definition is:

(when (fboundp 'sqlind-minor-mode)
    (sqlind-minor-mode (if sql-use-indent-support +1 -1)))

Further, the activated gnu-elpa package loads the feature
sqlind-minor-mode, so the above when-clause condition is satisfied, but
since the package sql-indent was not installed, sqlind-minor-mode is not
defined, causing the file mode specification error.  It's not clear to
me from this why the SQL file is not fontified, since IIUC the mode hook
is run at the end of the mode definition, so the mode fontification code
should already have been executed; and indeed, when I instrument
sql-mode, carry out the above recipe and step through sql-mode, the SQL
file gets fontified and there is no error.  Nevertheless, without
instrumentation the above recipe reliably results in the error and
unfontified display.  The following patch prevents the error and
displays the SQL file correctly fontified:

[Message part 2 (text/x-patch, inline)]
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 5273ba2bee1..ffb29075cce 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -734,8 +734,10 @@ sql-use-indent-support

 (defun sql-indent-enable ()
   "Enable `sqlind-minor-mode' if available and requested."
-  (when (fboundp 'sqlind-minor-mode)
-    (sqlind-minor-mode (if sql-use-indent-support +1 -1))))
+  (condition-case nil
+      (when (fboundp 'sqlind-minor-mode)
+        (sqlind-minor-mode (if sql-use-indent-support +1 -1)))
+    (error nil)))

 ;; Secure Password wallet

[Message part 3 (text/plain, inline)]
I haven't yet tested what happens on answering yes in step 4 of the
recipe, but assuming that then the sql-indent package is installed and
the file is visited with correct fontification, the patch shouldn't
change that.  However, if you answer no in step 4, then next time you
visit a SQL file you get prompted again, and the patch doesn't change
that either.  It may be desirable to limit the prompting, but I'm not
sure if the required changes should be in sql.el, the gnu-elpa package,
or both.


In GNU Emacs 31.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version
 3.24.43, cairo version 1.18.2) of 2024-09-12 built on strobelfssd
Repository revision: 31e8500b061b6963708e66468fc89db1006226d7
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101013
System Description: Linux From Scratch r12.2-5-systemd

Configured using:
 'configure -C 'CFLAGS=-Og -g3''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

[test.sql (application/octet-stream, attachment)]
[backtrace (application/octet-stream, attachment)]

This bug report was last modified 273 days ago.

Previous Next


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