Hello Michael,
After your suggestion, all done! THX! The answer is below.
(require 'font-lock)
;; Use colors to highlight commands, etc.
(global-font-lock-mode t)
;;; allows font-lock usage always
(cond ((fboundp 'global-font-lock-mode)
;; turn on font-lock in all modes that support it
(global-font-lock-mode t)
;; maximum colors
(setq font-lock-maximum-decoration t)))
(setq odba-highlights
'(("\\(?:\\[PrefixDeclaration]\\)\\|\\(?:\\[SourceDeclaration]\\)\\|\\(?:\\[MappingDeclaration]\\)" . font-lock-function-name-face)
("sourceUri\\|connectionUrl\\|username\\|password\\|driverClass\\|mappingId\\|target\\|source\\|\\(?: a \\)\\|\\(?: \\.\\)"
. font-lock-variable-name-face)
("@collection\\|^[[:blank:]]*]]\\|\\(?:\\[\\[\\)" . font-lock-keyword-face)
("[A-Za-z]+:\\|:\\|#" . font-lock-type-face)
("SELECT\\|FROM\\|WHERE\\|LIMIT\\|;\\|OR\\|AND" . font-lock-constant-face)))
(define-derived-mode odba-mode fundamental-mode
(setq font-lock-defaults '(odba-highlights))
(setq mode-name "odba lang"))
;; add the mode to the 'features' list
(provide 'odba-mode)
I'm facing another issue now that it works: how could a .odba colorized automatically, please? I'm receiving the following warning when opening emacs alone:
Warning (initialization): An error occurred while loading `/home/andreltr/.emacs':
error: Required feature `odba-mode.el' was not provided
How come?
When opening emacs along with files the warning does not show. Plus, .odba files are colorized correctly when M-x odba-mode is done! The relevant section of my .emacs file is below. How to solve this, please?
:;
;; odba mode
;;
(setq load-path (append '("/home/andreltr/.emacs.d/odba-mode/") load-path))
(add-to-list 'load-path "/home/andreltr/.emacs.d/odba-mode/odba-mode.el")
(autoload 'odba-mode "odba-mode" "Major mode for ODBA files" t)
(add-to-list 'auto-mode-alist '("\\.odba\\'" . odba-mode))
;; Turn on font lock when in odba mode
(add-hook 'odba-mode-hook
'turn-on-font-lock)
(setq auto-mode-alist
(append
(list
'("\\.odba\\" . odba-mode))
auto-mode-alist))
(require 'odba-mode.el)
TIA,
Andre Luiz
Post by AndreLTRHello,
I need to colour the following character sequences but could not after many tries,
1 - [[ and ]] with space character before of after them.
2 - [ with a variable character string length afterword.
3 - ] with a variable character string length beforehand.
2 and 3 could form a single regexp since the keyword in question is variable.
4 - a single period at the end of a sentence with a space before it.
5 - the : character is preceded by a variable length string (including zero characters).
[ and ] shall have the same colour. Likewise for : and period. Could anyone help me, please?
TIA,