Re: ISO something like "#if 0 ... #endif" for SQL code

Поиск
Список
Период
Сортировка
От Kynn Jones
Тема Re: ISO something like "#if 0 ... #endif" for SQL code
Дата
Msg-id c2350ba40803111112v6c233878s59f70187495178ed@mail.gmail.com
обсуждение исходный текст
Ответ на Re: ISO something like "#if 0 ... #endif" for SQL code  ("Gurjeet Singh" <singh.gurjeet@gmail.com>)
Список pgsql-general
On Tue, Mar 11, 2008 at 10:10 AM, Gurjeet Singh <singh.gurjeet@gmail.com> wrote:
The SQL standard, and Postgres, allow you to nest comments; some commercial RDBMS' do not provide this, and hence people think it's not possible in SQL.

Ah!  Finally I see what Martin was getting at in his reply.

Well, among those who seem unaware of the standard is the author of the Emacs SQL mode, because its syntax highlighting gets all messed up with nested C-style comments...

Thanks for the tip!

Kynn


P.S.  For any interested Emacs user:  as it happens, it was pretty easy to fix sql.el to allow C-style comments to nest.  It just required adding a couple of n's, to change the lines

    (modify-syntax-entry ?/ ". 14" table)
    (modify-syntax-entry ?* ". 23" table)

to

    (modify-syntax-entry ?/ ". 14n" table)
    (modify-syntax-entry ?* ". 23n" table)

(actually either one of the two changes would have sufficed) in the syntax table definition

(defvar sql-mode-syntax-table
  (let ((table (make-syntax-table)))
    ;; C-style comments /**/ (see elisp manual "Syntax Flags"))
    (modify-syntax-entry ?/ ". 14" table)
    (modify-syntax-entry ?* ". 23" table)
    ;; double-dash starts comments
    (modify-syntax-entry ?- ". 12b" table)
    ;; newline and formfeed end comments
    (modify-syntax-entry ?\n "> b" table)
    (modify-syntax-entry ?\f "> b" table)
    ;; single quotes (') delimit strings
    (modify-syntax-entry ?' "\"" table)
    ;; double quotes (") don't delimit strings
    (modify-syntax-entry ?\" "." table)
    ;; backslash is no escape character
    (modify-syntax-entry ?\\ "." table)
    table)
  "Syntax table used in `sql-mode' and `sql-interactive-mode'.")

(I also had to restart Emacs to get this change to have an effect.  Just executing the revised definition was not enough.  Maybe there's a way to do achieve the same without restarting, but I couldn't think of it.)

В списке pgsql-general по дате отправления:

Предыдущее
От: "Mike"
Дата:
Сообщение: Re: message contents do not agree with length in message type "T"
Следующее
От: "Kynn Jones"
Дата:
Сообщение: Re: ISO something like "#if 0 ... #endif" for SQL code