From: Nik Clayton <nik@ngo.org.uk>
To: emacs-devel@gnu.org
Subject: Feature request: Easy customisation of sql-mode product keywords
Date: Tue, 7 May 2019 19:33:59 +0200 [thread overview]
Message-ID: <CAKJTzL4MhOv5PpNdYLdeoFsk_ABr=44q9rJjkQM=Bsgi8+0Kcw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1990 bytes --]
Hi, I've got a feature request for sql-mode.
[not 100% certain if this list was better than bug-gnu-emacs, but
https://www.emacswiki.org/emacs/MichaelMauger mentioned monitoring this
list, so I figured it was a better fit]
I'd like to be able to easily either:
1. Configure the mode to only recongnise keywords in uppercase, or
2. Customise the keywords associated with an SQL product in sql-mode.
The specific problem I have, and why this would solve it is as follows.
I produce some teaching material using Emacs and org-mode, exporting the
results to HTML. This uses the syntax highlighting in Emacs to generate
syntax highlighted SQL in the slides and course notes.
However, given a query like the following:
SELECT name
FROM track
WHERE trackid = 1222;
the "name" on the first line is highlighted as a keyword. Because it is, it
shows up in sql-mode-ansi-font-lock-keywords.
However, this means that it's rendered differently to "track" snd "trackid
= 1222;" in that example.
This is not easy behaviour to customise in my Emacs configuration (as far
as I can tell), for a few reasons.
The most important is that the code that creates
sql-mode-ansi-font-lock-keywords runs under eval-when-compile -- it's not a
function that I can call again after making some modifications, or provide
advice around to customise the behaviour.
Similarly, this means that I can't advise sql-font-lock-keywords-builder,
and change its arguments so that it only receives upper-case keywords -- by
the time my code runs its too late.
The actual list of keywords in sql.el aren't bound to a list, only the
resulting regexp is. Which means I can't take that list, modify it, and
create a new value for sql-mode-ansi-font-lock-keywords
So I resorted to this:
(setf (car (car sql-mode-ansi-font-lock-keywords))
(s-replace "n\\(?:ame\\|u\\(?:llable\\|mber\\)\\))"
"nu\\(?:llable\\|mber\\))"
(car (car sql-mode-ansi-font-lock-keywords))))
Best, N
[-- Attachment #2: Type: text/html, Size: 2437 bytes --]
next reply other threads:[~2019-05-07 17:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-07 17:33 Nik Clayton [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-06-03 2:17 Feature request: Easy customisation of sql-mode product keywords Michael Mauger
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKJTzL4MhOv5PpNdYLdeoFsk_ABr=44q9rJjkQM=Bsgi8+0Kcw@mail.gmail.com' \
--to=nik@ngo.org.uk \
--cc=emacs-devel@gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).