From: Claudius@sailer-online.de (Claudius Sailer)
Subject: need help with highlighting file
Date: Fri, 10 Feb 2006 22:46:33 +0100 [thread overview]
Message-ID: <1hakf3i.cs9pc3c9t1quN%Claudius@sailer-online.de> (raw)
Hi,
I have a language SQR which I want to highlight. I copied sql.el and
renamed it. I made correct including in .emacs. I deleted everything I
don't need and it works. BUT I have 2 problems. SQR is like SQL not case
sensitiv, but my highlighting only works with small letters. So it is
case sensitive And SQR uses ! for comments. I don't know how
I can activate this correctly. I have only SQL-Comment but I wasn't
unable to make changes that it works.
could I get some help?
thanks
Claudius
some parts of coding without all comments
;;; sqr-mode.el --- specialized comint.el for SQR
;;;; comments are removed for less traffic
;;; Code:
(require 'comint)
;; Need the following to allow GNU Emacs 19 to compile the file.
(require 'regexp-opt)
(require 'custom)
;; Syntax Table
(defvar sqr-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 comment
(if (string-match "XEmacs\\|Lucid" emacs-version)
(modify-syntax-entry ?- ". 56" table)
(modify-syntax-entry ?- ". 12b" table))
;; newline and formfeed end coments
(modify-syntax-entry ?\n "> b" table)
(modify-syntax-entry ?\f "> b" table)
;; single quotes (') quotes delimit strings
(modify-syntax-entry ?' "\"" table)
table)
"Syntax table used in `sqr-mode.")
;; Font lock support
(defvar sqr-mode-font-lock-keywords nil
"SQR keywords used by font-lock.
This variable is used by `sqr-mode'. The
regular expressions are created during compilation by calling the
function `regexp-opt'. Therefore, take a look at the source before
you define your own sqr-mode-font-lock-keywords. You may want to
add functions and SQR keywords.")
(if sqr-mode-font-lock-keywords
()
(let ((sqr-keywords (eval-when-compile
(concat "\\b"
(regexp-opt '(
"authorization" "avg" "begin" "close" "cobol" "commit"
"continue" "count" "declare" "double" "end" "escape"
"exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator"
"key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli"
"precision" "primary" "procedure" "references" "rollback"
"schema" "section" "some" "sqlcode" "sqlerror" "sum" "work") t) "\\b")))
(sqr-reserved-words (eval-when-compile
(concat "\\b"
(regexp-opt '(
"all" "and" "any" "as" "asc" "between" "by" "check" "create"
"current" "default" "delete" "desc" "distinct" "exists" "float" "for"
"from" "grant" "group" "having" "in" "insert" "into" "is"
"like" "not" "null" "of" "on" "option" "or" "order" "privileges"
"public" "select" "set" "table" "to" "union" "unique"
"update" "user" "values" "view" "where" "with") t) "\\b")))
(sqr-types (eval-when-compile
(concat "\\b"
(regexp-opt '(
;; SQR Keywords that look like types --hellblau
"character" "cursor" "dec" "int" "real"
;; SQR Reserved Word that look like types --hellblau
"char" "integer" "smallint" ) t) "\\b"))))
(setq sqr-mode-font-lock-keywords
(list (cons sqr-keywords 'font-lock-function-name-face)
(cons sqr-reserved-words 'font-lock-keyword-face)
(cons sqr-types 'font-lock-type-face)))))
(defvar sqr-mode-font-lock-keywords sqr-mode-font-lock-keywords
"SQR keywords used by font-lock.
This variable defaults to `sqr-mode-font-lock-keywords'. This is
used for the default `font-lock-defaults' value in `sqr-mode'. This
can be changed by some entry functions to provide more hilighting.")
;;; Functions to switch highlighting
(defun sqr-highlight-keywords ()
"Highlight SQR keywords.
Basically, this just sets `font-lock-keywords' appropriately."
(interactive)
(setq font-lock-keywords sqr-mode-font-lock-keywords)
(font-lock-fontify-buffer))
;;;###autoload
(defun sqr-mode ()
"Major mode to edit SQR."
(interactive)
(kill-all-local-variables)
(setq major-mode 'sqr-mode)
(setq mode-name "SQR-MODE")
;(use-local-map sqr-mode-map)
;(if sqr-mode-menu
; (easy-menu-add sqr-mode-menu)); XEmacs
(set-syntax-table sqr-mode-syntax-table)
(make-local-variable 'font-lock-defaults)
;; Note that making KEYWORDS-ONLY nil will cause havoc if you try
;; SELECT 'x' FROM DUAL with SQL*Plus, because the title of the column
;; will have just one quote. Therefore syntactic hilighting is
;; disabled for interactive buffers. `_' and `.' are considered part
;; of words.
; (setq font-lock-defaults '(sqr-mode-font-lock-keywords
; nil t ((?_ . "w") (?. . "w"))))
; (make-local-variable 'comment-start)
; (setq comment-start "!")
;; Make each buffer in sqr-mode remember the "current" SQLi buffer.
;(make-local-variable 'sqr-buffer)
;; Add imenu support for sql-mode. Note that imenu-generic-expression
;; is buffer-local, so we don't need a local-variable for it. SQR is
;; case-insensitive, that's why we have to set imenu-case-fold-search.
;; imenu-syntax-alist makes sure that `_' is considered part of object
;; names.
; (setq imenu-generic-expression sqr-imenu-generic-expression
; imenu-case-fold-search t
; imenu-syntax-alist '(("_" . "w")))
;; Make `sqr-send-paragraph' work on paragraphs that contain indented
;; lines.
; (make-local-variable 'paragraph-separate)
; (make-local-variable 'paragraph-start)
; (setq paragraph-separate "[\f]*$"
; paragraph-start "[\n\f]")
;; Abbrevs
; (setq local-abbrev-table sqr-mode-abbrev-table)
; (setq abbrev-all-caps 1)
)
(provide 'sqr-mode)
;;; sqr-mode.el ends here
reply other threads:[~2006-02-10 21:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1hakf3i.cs9pc3c9t1quN%Claudius@sailer-online.de \
--to=claudius@sailer-online.de \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.