help-gnu-emacs
[Top][All Lists]
Advanced

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

sql-mode: strange syntax highlighting, Emacs 25.1.1


From: Aleksandar Simic
Subject: sql-mode: strange syntax highlighting, Emacs 25.1.1
Date: Mon, 26 Sep 2016 14:47:38 +0100

Hello

When using sql-mode to write SQL which uses parameter placeholders,
unexpected words are syntax highlighted. Or better, parts of the word.

For example, I have the following:

SELECT * FROM foo WHERE created_at = :created-at

This is under:
Emacs version 25.1.1
sql.el version 3.5 (that comes with Emacs 25.1.1)

The same behaviour is present in my customised Emacs or in Emacs invoked
with '--no-init-file'.

In the last word `:created-at', `at' is highlighted, whereas `:created-' is
not.

I can see in sql.el that `at' is listed as ANSI reserved keyword. But
the above `at' is part of a word.

Executing: C-u C-x =

on `a' in `at' I get the following properties:

There are text properties here:
  face                 font-lock-keyword-face
  fontified            t

The same properties are shown for `t' in `at'.


But when I execute: C-u C-x =
on any of the characters that make ':created-', I get just:

There are text properties here:
  fontified            t


The same issue is present if I have the following examples, all the
`at', have a different face to the rest of the word:

SELECT * FROM foo WHERE created_at = :created-at-at-at
SELECT * FROM foo WHERE created_at = :at-created

Looking at sql-font-lock-keywords-builder in sql.el, which takes three
arguments: face, boundaries and the optional third argument keywords,
there is the following:

(or boundaries '("\\b" . "\\b"))

I couldn't figure out a way of passing in the boundaries that I'd
want/need, short of re-creating a new `product' (i.e. adding all new
syntax highlighting for a new database).

DIRTY HACK: If I tweak the values of the `boundaries', directly in
sql-font-lock-keywords-builder, the `-at' part of the word is treated
as I'd expect: that part of the word doesn't have a different face to
the first part of the word.

But obviously that is not ideal. So what is the correct way of dealing
with something like this?

Thank you for your time,
Aleksandar


reply via email to

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