From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Nik Clayton Newsgroups: gmane.emacs.devel Subject: Feature request: Easy customisation of sql-mode product keywords Date: Tue, 7 May 2019 19:33:59 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000d6e34905884f9fe9" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="235486"; mail-complaints-to="usenet@blaine.gmane.org" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 07 19:48:16 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hO4CM-000yzR-LA for ged-emacs-devel@m.gmane.org; Tue, 07 May 2019 19:48:14 +0200 Original-Received: from localhost ([127.0.0.1]:50743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO4CL-0004Gl-L2 for ged-emacs-devel@m.gmane.org; Tue, 07 May 2019 13:48:13 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:35044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hO3yt-0006QP-B1 for emacs-devel@gnu.org; Tue, 07 May 2019 13:34:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hO3yr-0002kN-5a for emacs-devel@gnu.org; Tue, 07 May 2019 13:34:19 -0400 Original-Received: from mail-it1-x134.google.com ([2607:f8b0:4864:20::134]:38241) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hO3yo-0002ez-R6 for emacs-devel@gnu.org; Tue, 07 May 2019 13:34:16 -0400 Original-Received: by mail-it1-x134.google.com with SMTP id q19so27081968itk.3 for ; Tue, 07 May 2019 10:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ngo-org-uk.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=id4cb8nn2MnvSqDjlIZDTsAG5Q1T9AGfM1ljPjOqsSQ=; b=WjxDxyKUAy2tynPrGnd7SA13CZLlkYHfzACOr7kTAejwMrUoEjI6GlG+hpyKQl2q1L bTuHlai1ogdVBXVIuF1Zmz2YzgGObWx5i4xszzP04VCt6GL2yz42bsjKXBYGSTP5oga7 hixX6TxEQjreRT1nTHaujd3Q5jPMQGoXmBotCnG9XohPHzAZcHq8E0H//vweW2iNPbWH kZoXWyTIogu15uko0e7r0Q9ya2cGppfaG/van+Cz/pewPoil+Kbxi7Mptdk3JFi06W1D RGHD/aBoRykHBGhKEWkH4T+ErOksOFfOayJT9mZtMWhM2gCTeJ8N0KNE9QgjUPgN+1PB PSBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=id4cb8nn2MnvSqDjlIZDTsAG5Q1T9AGfM1ljPjOqsSQ=; b=C94WkJ/7hkSTplHFCrf0gUAYZhV+XCiqC42zwtILZeaWmD2ICYwsW4CWij9S4sLARx OTP88PbJk8dPH7AU1MiE7kB4Jl7sXQv5X/S0ai0E1kTqujiqdlyGn64PBRrLo2v0q71Q kyRWqwZBKKhQxbAEumkrTEWpWrmxQLWYdld5tv1/uajS1dIBQpsri+7UjoxGssRdCwRi 95nArMZQmzketrk81BkesGVlX+SFHFA8nPwov8pM9AqZ62eeM4hxpgK87W6ekpq4dKmL zsbjdc4+wRByghz/Ee2C4bxgVk3YdmMKBuO94x2EncdXeVeUrq0QFqBCBAEQuVV9p78s W+Kw== X-Gm-Message-State: APjAAAXk0Ez6mRJBPKDxma52HSF9bL+09U4251AM6rCOubIAfOcok6Vr wmgC1PCpXbjK0/TEfEk8hcJbPRdUF/N03yO1xxC1a4TabpuN+w== X-Google-Smtp-Source: APXvYqzmQAKJfoeks2A/rNdLeGWHjlLzTSPgD+igb73o1WtSU8dd+c9HiCJG3Em0dfhdJW4/pH/sdwDlannpazxs1Zc= X-Received: by 2002:a24:9c47:: with SMTP id b68mr23688899ite.169.1557250449001; Tue, 07 May 2019 10:34:09 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::134 X-Mailman-Approved-At: Tue, 07 May 2019 13:48:03 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:236246 Archived-At: --000000000000d6e34905884f9fe9 Content-Type: text/plain; charset="UTF-8" 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 --000000000000d6e34905884f9fe9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, I've got a featu= re request for sql-mode.

[not 100% cer= tain if this list was better than bug-gnu-emacs, but https://www.emacswiki.org/emacs/Michael= Mauger mentioned monitoring this list, so I figured it was a better fit= ]

I'd like to be able to easily ei= ther:

1. Configure the mode to only recongnise keywords in uppercase= , or
2. Customise the keywords associated with an SQL product in sql-mod= e.

The specific problem I have, and why this would solve it is as fo= llows.

I produce some teaching material using Emacs and org-mode, ex= porting the results to HTML. This uses the syntax highlighting in Emacs to = generate syntax highlighted SQL in the slides and course notes.

Howe= ver, given a query like the following:

=C2=A0 SELECT name
=C2=A0= =C2=A0=C2=A0 FROM track
=C2=A0=C2=A0 WHERE trackid =3D 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 m= eans that it's rendered differently to "track" snd "trac= kid =3D 1222;" in that example.

This is not easy behaviour to c= ustomise in my Emacs configuration (as far as I can tell), for a few reason= s.

The most important is that the code that creates sql-mode-ansi-fo= nt-lock-keywords runs under eval-when-compile -- it's not a function th= at I can call again after making some modifications, or provide advice arou= nd to customise the behaviour.

Similarly, this means that I can'= t advise sql-font-lock-keywords-builder, and change its arguments so that i= t only receives upper-case keywords -- by the time my code runs its too lat= e.

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, modi= fy it, and create a new value for sql-mode-ansi-font-lock-keywords

S= o I resorted to this:

(setf (car (car sql-mode-ansi-font-lock-keywor= ds))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (s-replace "n\\(?:ame\\|u\\(?:l= lable\\|mber\\)\\))"
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "nu\\(?:llable\\|m= ber\\))"
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (car (car sql-mode-ansi-font-lock-k= eywords))))

Best, N
--000000000000d6e34905884f9fe9--