summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Andrew J. Cosgriff2017-02-14 08:25:18 +1100
committerGravatar GitHub2017-02-14 08:25:18 +1100
commitc13fa624f47f216d3f612ed656c46016916ecfdd (patch)
tree05c8c22a916b9645d13e74fba2a640c80f94fe85
parenta04cef3a07d235eb03bd944fe6923664493896ee (diff)
parentf33abe726268bd2174413bcc7748faf37db9028c (diff)
downloadnginx-mode-c13fa624f47f216d3f612ed656c46016916ecfdd.tar.gz
nginx-mode-c13fa624f47f216d3f612ed656c46016916ecfdd.zip
Merge pull request #15 from zonuexe/feature/comment-syntax-table
Use syntax table instead of font-lock regexp
-rw-r--r--nginx-mode.el20
1 files changed, 11 insertions, 9 deletions
diff --git a/nginx-mode.el b/nginx-mode.el
index 78089cd..319287c 100644
--- a/nginx-mode.el
+++ b/nginx-mode.el
@@ -1,4 +1,3 @@
-
;;; nginx-mode.el --- major mode for editing nginx config files
;; Copyright 2010 Andrew J Cosgriff <andrew@cosgriff.name>
@@ -7,7 +6,7 @@
;; Maintainer: Andrew J Cosgriff <andrew@cosgriff.name>
;; Created: 15 Oct 2010
;; Version: 1.1.6
-;; Keywords: nginx
+;; Keywords: languages, nginx
;; available from http://github.com/ajc/nginx-mode
@@ -50,10 +49,15 @@
"*Indentation can insert tabs in nginx mode if this is non-nil."
:type 'boolean :group 'nginx)
+(defvar nginx-mode-syntax-table
+ (let ((table (make-syntax-table)))
+ (modify-syntax-entry ?# "< b" table)
+ (modify-syntax-entry ?\n "> b" table)
+ table)
+ "Syntax table for `nginx-mode'.")
(defvar nginx-font-lock-keywords
- (list '("#.*" . font-lock-comment-face)
- '("^\\([ \t]+\\)?\\([A-Za-z09_]+\\)" 2 font-lock-keyword-face t)
+ (list '("^\\([ \t]+\\)?\\([A-Za-z09_]+\\)" 2 font-lock-keyword-face t)
;; uncomment the next one if you want your eyes to bleed
;; (it'll highlight parentheses and curly braces)
;;'("\\(\{\\|\}\\|\(\\|\)\\)" . font-lock-pseudo-keyword-face)
@@ -158,16 +162,14 @@ of the closing brace of a block."
"Keymap for editing nginx config files.")
;;;###autoload
-(defun nginx-mode ()
+(define-derived-mode nginx-mode prog-mode "Nginx"
"Major mode for highlighting nginx config files.
The variable nginx-indent-level controls the amount of indentation.
\\{nginx-mode-map}"
- (interactive)
- (kill-all-local-variables)
+ :syntax-table nginx-mode-syntax-table
+
(use-local-map nginx-mode-map)
- (setq mode-name "Nginx"
- major-mode 'nginx-mode)
(set (make-local-variable 'comment-start) "# ")
(set (make-local-variable 'comment-start-skip) "#+ *")