emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Feature request: Easy customisation of sql-mode product keywords


From: Michael Mauger
Subject: Feature request: Easy customisation of sql-mode product keywords
Date: Mon, 03 Jun 2019 02:17:34 +0000

On Tue, 7 May 2019 19:33:59 +0200, Nic Clayton said:
> 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]>

Sorry for the delay in responding-- I've been laid up for a while...

> 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.
>
> ...
>
>  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.
>

There are two ways to alter the keyword locking in your case:

1) Set `sql-mode-ansi-font-lock-keywords` to nil and rely upon only on the
dialect keywords

    (setq sql-mode-ansi-font-lock-keywords nil)

2) Add keyword matching rules that override the default settings so that you get
highlighting that you want.

    (sql-add-product-keywords 'mysql
      (cons
        (regexp-opt '("name" "table_name" "index_name" "constraint_name")
                    'symbols)
        '(quote default)))       

I am looking to add more sophisticated font locking to sql-mode to avoid
highlighting keywords in places where the syntax isn't looking for one.

>
> Best, N

Hopefully this helps. Happy Hacking!

--
address@hidden // FSF and EFF member // GNU Emacs sql.el maintainer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]