|
1 | | - |
2 | 1 | ;;; nginx-mode.el --- major mode for editing nginx config files |
3 | 2 |
|
4 | 3 | ;; Copyright 2010 Andrew J Cosgriff <[email protected]> |
|
7 | 6 | ;; Maintainer: Andrew J Cosgriff <[email protected]> |
8 | 7 | ;; Created: 15 Oct 2010 |
9 | 8 | ;; Version: 1.1.6 |
10 | | -;; Keywords: nginx |
| 9 | +;; Keywords: languages, nginx |
11 | 10 |
|
12 | 11 | ;; available from http://github.com/ajc/nginx-mode |
13 | 12 |
|
|
50 | 49 | "*Indentation can insert tabs in nginx mode if this is non-nil." |
51 | 50 | :type 'boolean :group 'nginx) |
52 | 51 |
|
| 52 | +(defvar nginx-mode-syntax-table |
| 53 | + (let ((table (make-syntax-table))) |
| 54 | + (modify-syntax-entry ?# "< b" table) |
| 55 | + (modify-syntax-entry ?\n "> b" table) |
| 56 | + table) |
| 57 | + "Syntax table for `nginx-mode'.") |
53 | 58 |
|
54 | 59 | (defvar nginx-font-lock-keywords |
55 | | - (list '("#.*" . font-lock-comment-face) |
56 | | - '("^\\([ \t]+\\)?\\([A-Za-z09_]+\\)" 2 font-lock-keyword-face t) |
| 60 | + (list '("^\\([ \t]+\\)?\\([A-Za-z09_]+\\)" 2 font-lock-keyword-face t) |
57 | 61 | ;; uncomment the next one if you want your eyes to bleed |
58 | 62 | ;; (it'll highlight parentheses and curly braces) |
59 | 63 | ;;'("\\(\{\\|\}\\|\(\\|\)\\)" . font-lock-pseudo-keyword-face) |
@@ -158,16 +162,14 @@ of the closing brace of a block." |
158 | 162 | "Keymap for editing nginx config files.") |
159 | 163 |
|
160 | 164 | ;;;###autoload |
161 | | -(defun nginx-mode () |
| 165 | +(define-derived-mode nginx-mode prog-mode "Nginx" |
162 | 166 | "Major mode for highlighting nginx config files. |
163 | 167 |
|
164 | 168 | The variable nginx-indent-level controls the amount of indentation. |
165 | 169 | \\{nginx-mode-map}" |
166 | | - (interactive) |
167 | | - (kill-all-local-variables) |
| 170 | + :syntax-table nginx-mode-syntax-table |
| 171 | + |
168 | 172 | (use-local-map nginx-mode-map) |
169 | | - (setq mode-name "Nginx" |
170 | | - major-mode 'nginx-mode) |
171 | 173 |
|
172 | 174 | (set (make-local-variable 'comment-start) "# ") |
173 | 175 | (set (make-local-variable 'comment-start-skip) "#+ *") |
|
0 commit comments