AndreLTR
2016-02-07 18:30:43 UTC
Hello,
I'm receiving the error below for a font-lock mode I'm developing:
Symbol's value as variable is void: font-lock
It occurs when I press M-x odba-mode. The related .emacs are below:
(global-font-lock-mode t)
(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)))
:;
;; 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/myodba-mode.el")
(autoload 'odba-mode "myodba-mode" "Major mode for ODBA files" t)
;; 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))
(push (cons "\\.odba" 'odba-mode) auto-mode-alist)
The myodba-mode is below:
;; This is my suggestion for an odba mode
;; Based on the lsl-mode.el
;; André Luiz Tietbohl Ramos <***@gmail.com>
;; Example of font coloring:
;; RED -> comment
;; GREEN -> type
;; PURPLE -> "keyword"
;; PINK -> event
;; BLUE -> function
(require font-lock)
;; Use colors to highlight commands, etc.
(global-font-lock-mode t)
;;; Permite usar font-lock sempre
(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)))
;; odba-mode, my first major mode
(setq odba-highlights
'(("[PrefixDeclaration]\\|[SourceDeclaration]\\|[MappingDeclaration]"
. font-lock-function-name-face)
("sourceUri\\|connectionUrl\\|username\\|password\\|driverClass"
. font-lock-builtin-face)
("SELECT\\|FROM\\|WHERE" . font-lock-keyword-face)
("[[\\|]]" . font-lock-constant-face)
("@collection" . font-lock-type-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)
;;; mylsl-mode.el --- sample major mode for editing LSL.
;; Copyright (c) 2015, by you
;; Author: your name ( your email )
;; Version: 2.0.13
;; Created: 26 Jun 2015
;; Keywords: languages
;; Homepage: http://ergoemacs.org/emacs/elisp_syntax_coloring.html
;; This file is not part of GNU Emacs.
;;; License:
;; You can redistribute this program and/or modify it under the terms of the
;; GNU General Public License version 2.
;;; Commentary:
;; short description here
;; full doc on how to use here
;;
;;; Code:
;; define several category of keywords
(setq odba-functions '("[PrefixDeclaration]" "[SourceDeclaration]" "[MappingDeclaration]"))
(setq odba-keywords '("sourceUri" "connectionUrl" "username" "password" "driverClass"))
(setq odba-types '("SELECT" "FROM" "WHERE"))
(setq odba-constants '("[[" "]]"))
(setq odba-events '("@collection"))
;; generate regex string for each category of keywords
(setq odba-keywords-regexp (regexp-opt odba-keywords 'words))
(setq odba-type-regexp (regexp-opt odba-types 'words))
(setq odba-constant-regexp (regexp-opt odba-constants 'words))
(setq odba-event-regexp (regexp-opt odba-events 'words))
(setq odba-functions-regexp (regexp-opt odba-functions 'words))
;; create the list for font-lock.
;; each category of keyword is given a particular face
(setq odba-font-lock-keywords
`(
(,odba-type-regexp . font-lock-type-face) ;;
(,odba-constant-regexp . font-lock-constant-face) ;;
(,odba-event-regexp . font-lock-builtin-face) ;;
(,odba-functions-regexp . font-lock-function-name-face) ;;
(,odba-keywords-regexp . font-lock-keyword-face)
;; note: order above matters, because once colored, that part won't change.
;; in general, longer words first
))
;;;###autoload
(define-derived-mode odba-mode fundamental-mode
"odba mode"
"Major mode for editing odba (Open Database Access Language)"
;; code for syntax highlighting
(setq font-lock-defaults '((odba-font-lock-keywords))))
;; clear memory. no longer needed
(setq odba-keywords nil)
(setq odba-types nil)
(setq odba-constants nil)
(setq odba-events nil)
(setq odba-functions nil)
;; clear memory. no longer needed
(setq odba-keywords-regexp nil)
(setq odba-types-regexp nil)
(setq odba-constants-regexp nil)
(setq odba-events-regexp nil)
(setq odba-functions-regexp nil)
;; add the mode to the `features' list
(provide 'odba-mode)
;; Local Variables:
;; coding: utf-8
;; End:
;;; odba-mode.el ends here
Any suggestions as to why it is happening, please? Regarding emacs-lisp, I'm quite a newbie.
TIA,
Andre Luiz
I'm receiving the error below for a font-lock mode I'm developing:
Symbol's value as variable is void: font-lock
It occurs when I press M-x odba-mode. The related .emacs are below:
(global-font-lock-mode t)
(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)))
:;
;; 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/myodba-mode.el")
(autoload 'odba-mode "myodba-mode" "Major mode for ODBA files" t)
;; 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))
(push (cons "\\.odba" 'odba-mode) auto-mode-alist)
The myodba-mode is below:
;; This is my suggestion for an odba mode
;; Based on the lsl-mode.el
;; André Luiz Tietbohl Ramos <***@gmail.com>
;; Example of font coloring:
;; RED -> comment
;; GREEN -> type
;; PURPLE -> "keyword"
;; PINK -> event
;; BLUE -> function
(require font-lock)
;; Use colors to highlight commands, etc.
(global-font-lock-mode t)
;;; Permite usar font-lock sempre
(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)))
;; odba-mode, my first major mode
(setq odba-highlights
'(("[PrefixDeclaration]\\|[SourceDeclaration]\\|[MappingDeclaration]"
. font-lock-function-name-face)
("sourceUri\\|connectionUrl\\|username\\|password\\|driverClass"
. font-lock-builtin-face)
("SELECT\\|FROM\\|WHERE" . font-lock-keyword-face)
("[[\\|]]" . font-lock-constant-face)
("@collection" . font-lock-type-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)
;;; mylsl-mode.el --- sample major mode for editing LSL.
;; Copyright (c) 2015, by you
;; Author: your name ( your email )
;; Version: 2.0.13
;; Created: 26 Jun 2015
;; Keywords: languages
;; Homepage: http://ergoemacs.org/emacs/elisp_syntax_coloring.html
;; This file is not part of GNU Emacs.
;;; License:
;; You can redistribute this program and/or modify it under the terms of the
;; GNU General Public License version 2.
;;; Commentary:
;; short description here
;; full doc on how to use here
;;
;;; Code:
;; define several category of keywords
(setq odba-functions '("[PrefixDeclaration]" "[SourceDeclaration]" "[MappingDeclaration]"))
(setq odba-keywords '("sourceUri" "connectionUrl" "username" "password" "driverClass"))
(setq odba-types '("SELECT" "FROM" "WHERE"))
(setq odba-constants '("[[" "]]"))
(setq odba-events '("@collection"))
;; generate regex string for each category of keywords
(setq odba-keywords-regexp (regexp-opt odba-keywords 'words))
(setq odba-type-regexp (regexp-opt odba-types 'words))
(setq odba-constant-regexp (regexp-opt odba-constants 'words))
(setq odba-event-regexp (regexp-opt odba-events 'words))
(setq odba-functions-regexp (regexp-opt odba-functions 'words))
;; create the list for font-lock.
;; each category of keyword is given a particular face
(setq odba-font-lock-keywords
`(
(,odba-type-regexp . font-lock-type-face) ;;
(,odba-constant-regexp . font-lock-constant-face) ;;
(,odba-event-regexp . font-lock-builtin-face) ;;
(,odba-functions-regexp . font-lock-function-name-face) ;;
(,odba-keywords-regexp . font-lock-keyword-face)
;; note: order above matters, because once colored, that part won't change.
;; in general, longer words first
))
;;;###autoload
(define-derived-mode odba-mode fundamental-mode
"odba mode"
"Major mode for editing odba (Open Database Access Language)"
;; code for syntax highlighting
(setq font-lock-defaults '((odba-font-lock-keywords))))
;; clear memory. no longer needed
(setq odba-keywords nil)
(setq odba-types nil)
(setq odba-constants nil)
(setq odba-events nil)
(setq odba-functions nil)
;; clear memory. no longer needed
(setq odba-keywords-regexp nil)
(setq odba-types-regexp nil)
(setq odba-constants-regexp nil)
(setq odba-events-regexp nil)
(setq odba-functions-regexp nil)
;; add the mode to the `features' list
(provide 'odba-mode)
;; Local Variables:
;; coding: utf-8
;; End:
;;; odba-mode.el ends here
Any suggestions as to why it is happening, please? Regarding emacs-lisp, I'm quite a newbie.
TIA,
Andre Luiz