Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use syntax table instead of font-lock regexp
  • Loading branch information
zonuexe committed Feb 13, 2017
commit f33abe726268bd2174413bcc7748faf37db9028c
20 changes: 11 additions & 9 deletions nginx-mode.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

;;; nginx-mode.el --- major mode for editing nginx config files

;; Copyright 2010 Andrew J Cosgriff <[email protected]>
Expand All @@ -7,7 +6,7 @@
;; Maintainer: Andrew J Cosgriff <[email protected]>
;; Created: 15 Oct 2010
;; Version: 1.1.6
;; Keywords: nginx
;; Keywords: languages, nginx

;; available from http://github.com/ajc/nginx-mode

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) "#+ *")
Expand Down