all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 73411@debbugs.gnu.org
Subject: bug#73411: 31.0.50; sql-mode interacts poorly with package gnu-elpa
Date: Sat, 21 Sep 2024 16:32:05 +0200	[thread overview]
Message-ID: <875xqpnkm2.fsf@gmx.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 1693 bytes --]

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sql-indent-enable patch --]
[-- Type: text/x-patch, Size: 580 bytes --]

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


[-- Attachment #3: Type: text/plain, Size: 1182 bytes --]


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


[-- Attachment #4: test.sql --]
[-- Type: application/octet-stream, Size: 745 bytes --]

CREATE TABLE weather (
    city            varchar(80),
    temp_lo         int,           -- low temperature
    temp_hi         int,           -- high temperature
    prcp            real,          -- precipitation
    date            date
);

CREATE TABLE cities (
    name            varchar(80),
    location        point
);

INSERT INTO weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');
INSERT INTO cities VALUES ('San Francisco', '(-194.0, 53.0)');
INSERT INTO weather (city, temp_lo, temp_hi, prcp, date)
    VALUES ('San Francisco', 43, 57, 0.0, '1994-11-29');
INSERT INTO weather (date, city, temp_hi, temp_lo)
    VALUES ('1994-11-29', 'Hayward', 54, 37);

SELECT city, (temp_hi+temp_lo)/2 AS temp_avg, date FROM weather;

[-- Attachment #5: backtrace --]
[-- Type: application/octet-stream, Size: 2498 bytes --]

Debugger entered--Lisp error: (error "Abort!")
  error("Abort!")
  gnu-elpa--perform-autoload()
  byte-code("\300\301!\210\302 \207" [require gnu-elpa-utils gnu-elpa--perform-autoload] 2)
  sqlind-minor-mode(1)
  sql-indent-enable()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook sql-mode-hook)
  apply(run-hooks change-major-mode-after-body-hook (prog-mode-hook sql-mode-hook))
  run-mode-hooks(sql-mode-hook)
  sql-mode()
  set-auto-mode-0(sql-mode nil)
  set-auto-mode--apply-alist((("\\.hva\\'" . LaTeX-mode) ("\\.ipynb\\'" . code-cells-convert-ipynb) ("\\.djvu\\'" . djvu-init-mode) ("\\.ipynb\\'" . ein:ipynb-mode) ("\\.[Ss][Aa][Ss]\\'" . SAS-mode) ("\\.Sout\\'" . S-transcript-mode) ("\\.[Ss]t\\'" . S-transcript-mode) ("\\.Rd\\'" . Rd-mode) ("DESCRIPTION\\'" . conf-colon-mode) ("/Makevars\\(\\.win\\)?\\'" . makefile-mode) ("\\.[Rr]out\\'" . ess-r-transcript-mode) ("CITATION\\'" . ess-r-mode) ("NAMESPACE\\'" . ess-r-mode) ("\\.[rR]profile\\'" . ess-r-mode) ("\\.[rR]\\'" . ess-r-mode) ("/R/.*\\.q\\'" . ess-r-mode) ("\\.[Jj][Aa][Gg]\\'" . ess-jags-mode) ("\\.[Bb][Mm][Dd]\\'" . ess-bugs-mode) ("\\.[Bb][Oo][Gg]\\'" . ess-bugs-mode) ("\\.[Bb][Uu][Gg]\\'" . ess-bugs-mode) ("\\.wy\\'" . wisitoken-grammar-mode) ("\\.vcl\\'" . vcl-mode) ("\\.[Vv][Cc][Ff]\\'" . vcard-mode) ("\\.s\\(ml\\|ig\\)\\'" . sml-mode) ("\\.cm\\'" . sml-cm-mode) ("\\.grm\\'" . sml-yacc-mode) ("\\.st\\'" . smalltalk-mode) ("\\.ss[imt]\\'" . sisu-mode) ("\\.shen\\'" . shen-mode) ("\\.sed\\'" . sed-mode) ("\\.rnc\\'" . rnc-mode) ("\\.pomn\\'" . omn-mode) ("\\.omn\\'" . omn-mode) ("\\.elmc\\'" . lmc-asm-mode) ("\\.json\\'" . json-mode) ("\\.jgr\\'" . jgraph-mode) ("\\.gle\\'" . gle-mode) ("\\.fountain\\'" . fountain-mode) ("\\.dtsi?\\'" . dts-mode) ("\\.djvu\\'" . djvu-dummy-mode) ("\\.[Cc][Ss][Vv]\\'" . csv-mode) ("\\.tsv\\'" . tsv-mode) ("\\.coffee\\'" . coffee-mode) ("Cakefile" . coffee-mode) ("\\.pgn\\'" . chess-pgn-mode) ("\\.bnf\\'" . bnf-mode) ("\\.trf?\\'" . arbitools-mode) ("\\.\\(?:md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)\\'" . markdown-mode) ("\\.gpg\\(~\\|\\.~[0-9]+~\\)?\\'" nil epa-file) ("\\.zst\\'" nil jka-compr) ...) nil nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer test.sql> "~/temp/test.sql" nil nil "/datadisk/steve/temp/test.sql" (214207655 2049))
  find-file-noselect("~/temp/test.sql" nil nil t)
  find-file("~/temp/test.sql" t)
  funcall-interactively(find-file "~/temp/test.sql" t)
  command-execute(find-file)

                 reply	other threads:[~2024-09-21 14:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875xqpnkm2.fsf@gmx.net \
    --to=bug-gnu-emacs@gnu.org \
    --cc=73411@debbugs.gnu.org \
    --cc=stephen.berman@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.