diff options
| author | Stefan Monnier | 2014-10-15 11:28:35 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2014-10-15 11:28:35 -0400 |
| commit | 8d56586d0a2ec4af423fe6fb0b2d344a04371ff8 (patch) | |
| tree | 47a7aacc39c30447283846b05cea8ac465c0a4ee | |
| parent | d7b601108d48e2508ce1bcbd5bacb2d8e0bd0f78 (diff) | |
| download | emacs-8d56586d0a2ec4af423fe6fb0b2d344a04371ff8.tar.gz emacs-8d56586d0a2ec4af423fe6fb0b2d344a04371ff8.zip | |
* lisp/progmodes/m4-mode.el (m4-syntax-propertize): New var.
(m4-mode): Use it.
(m4--quoted-p): New function.
(m4-font-lock-keywords): Don't handle #..\n comments any more.
(m4-mode-syntax-table): Use punctuation syntax (according to m4 manual)
for most special characters.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/progmodes/m4-mode.el | 33 |
2 files changed, 27 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9b6d532decb..610cf6f8670 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | 2014-10-15 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2014-10-15 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * progmodes/m4-mode.el (m4-syntax-propertize): New var. | ||
| 4 | (m4-mode): Use it. | ||
| 5 | (m4--quoted-p): New function. | ||
| 6 | (m4-font-lock-keywords): Don't handle #..\n comments any more. | ||
| 7 | (m4-mode-syntax-table): Use punctuation syntax (according to m4 manual) | ||
| 8 | for most special characters. | ||
| 9 | |||
| 3 | * progmodes/compile.el (compilation--previous-directory): Simplify. | 10 | * progmodes/compile.el (compilation--previous-directory): Simplify. |
| 4 | (compilation-next-error): Ensure the parse before we look at | 11 | (compilation-next-error): Ensure the parse before we look at |
| 5 | compilation-message property. | 12 | compilation-message property. |
diff --git a/lisp/progmodes/m4-mode.el b/lisp/progmodes/m4-mode.el index b795b35a8ea..573acf4445d 100644 --- a/lisp/progmodes/m4-mode.el +++ b/lisp/progmodes/m4-mode.el | |||
| @@ -65,14 +65,13 @@ If m4 is not in your PATH, set this to an absolute file name." | |||
| 65 | 65 | ||
| 66 | (defvar m4-font-lock-keywords | 66 | (defvar m4-font-lock-keywords |
| 67 | `( | 67 | `( |
| 68 | ("\\(\\b\\(m4_\\)?dnl\\b\\|^\\#\\).*$" . font-lock-comment-face) | 68 | ("\\(\\_<\\(m4_\\)?dnl\\_>\\).*$" . font-lock-comment-face) |
| 69 | ; ("\\(\\bdnl\\b\\|\\bm4_dnl\\b\\|^\\#\\).*$" . font-lock-comment-face) | ||
| 70 | ("\\$[*#@0-9]" . font-lock-variable-name-face) | 69 | ("\\$[*#@0-9]" . font-lock-variable-name-face) |
| 71 | ("\\\$\\\@" . font-lock-variable-name-face) | 70 | ("\\\$\\\@" . font-lock-variable-name-face) |
| 72 | ("\\\$\\\*" . font-lock-variable-name-face) | 71 | ("\\\$\\\*" . font-lock-variable-name-face) |
| 73 | ("\\b\\(builtin\\|change\\(com\\|quote\\|word\\)\\|d\\(e\\(bug\\(file\\|mode\\)\\|cr\\|f\\(ine\\|n\\)\\)\\|iv\\(ert\\|num\\)\\|nl\\|umpdef\\)\\|e\\(rrprint\\|syscmd\\|val\\)\\|f\\(ile\\|ormat\\)\\|gnu\\|i\\(f\\(def\\|else\\)\\|n\\(c\\(lude\\|r\\)\\|d\\(ex\\|ir\\)\\)\\)\\|l\\(en\\|ine\\)\\|m\\(4\\(exit\\|wrap\\)\\|aketemp\\)\\|p\\(atsubst\\|opdef\\|ushdef\\)\\|regexp\\|s\\(hift\\|include\\|ubstr\\|ys\\(cmd\\|val\\)\\)\\|tra\\(ceo\\(ff\\|n\\)\\|nslit\\)\\|un\\(d\\(efine\\|ivert\\)\\|ix\\)\\)\\b" . font-lock-keyword-face) | 72 | ("\\b\\(builtin\\|change\\(com\\|quote\\|word\\)\\|d\\(e\\(bug\\(file\\|mode\\)\\|cr\\|f\\(ine\\|n\\)\\)\\|iv\\(ert\\|num\\)\\|nl\\|umpdef\\)\\|e\\(rrprint\\|syscmd\\|val\\)\\|f\\(ile\\|ormat\\)\\|gnu\\|i\\(f\\(def\\|else\\)\\|n\\(c\\(lude\\|r\\)\\|d\\(ex\\|ir\\)\\)\\)\\|l\\(en\\|ine\\)\\|m\\(4\\(exit\\|wrap\\)\\|aketemp\\)\\|p\\(atsubst\\|opdef\\|ushdef\\)\\|regexp\\|s\\(hift\\|include\\|ubstr\\|ys\\(cmd\\|val\\)\\)\\|tra\\(ceo\\(ff\\|n\\)\\|nslit\\)\\|un\\(d\\(efine\\|ivert\\)\\|ix\\)\\)\\b" . font-lock-keyword-face) |
| 74 | ("\\b\\(m4_\\(builtin\\|change\\(com\\|quote\\|word\\)\\|d\\(e\\(bug\\(file\\|mode\\)\\|cr\\|f\\(ine\\|n\\)\\)\\|iv\\(ert\\|num\\)\\|nl\\|umpdef\\)\\|e\\(rrprint\\|syscmd\\|val\\)\\|f\\(ile\\|ormat\\)\\|i\\(f\\(def\\|else\\)\\|n\\(c\\(lude\\|r\\)\\|d\\(ex\\|ir\\)\\)\\)\\|l\\(en\\|ine\\)\\|m\\(4\\(_undefine\\|exit\\|wrap\\)\\|aketemp\\)\\|p\\(atsubst\\|opdef\\|ushdef\\)\\|regexp\\|s\\(hift\\|include\\|ubstr\\|ys\\(cmd\\|val\\)\\)\\|tra\\(ceo\\(ff\\|n\\)\\|nslit\\)\\|undivert\\)\\)\\b" . font-lock-keyword-face)) | 73 | ("\\b\\(m4_\\(builtin\\|change\\(com\\|quote\\|word\\)\\|d\\(e\\(bug\\(file\\|mode\\)\\|cr\\|f\\(ine\\|n\\)\\)\\|iv\\(ert\\|num\\)\\|nl\\|umpdef\\)\\|e\\(rrprint\\|syscmd\\|val\\)\\|f\\(ile\\|ormat\\)\\|i\\(f\\(def\\|else\\)\\|n\\(c\\(lude\\|r\\)\\|d\\(ex\\|ir\\)\\)\\)\\|l\\(en\\|ine\\)\\|m\\(4\\(_undefine\\|exit\\|wrap\\)\\|aketemp\\)\\|p\\(atsubst\\|opdef\\|ushdef\\)\\|regexp\\|s\\(hift\\|include\\|ubstr\\|ys\\(cmd\\|val\\)\\)\\|tra\\(ceo\\(ff\\|n\\)\\|nslit\\)\\|undivert\\)\\)\\b" . font-lock-keyword-face)) |
| 75 | "Default font-lock-keywords for `m4 mode'.") | 74 | "Default `font-lock-keywords' for M4 mode.") |
| 76 | 75 | ||
| 77 | (defcustom m4-mode-hook nil | 76 | (defcustom m4-mode-hook nil |
| 78 | "Hook called by `m4-mode'." | 77 | "Hook called by `m4-mode'." |
| @@ -86,19 +85,26 @@ If m4 is not in your PATH, set this to an absolute file name." | |||
| 86 | (modify-syntax-entry ?' ")`" table) | 85 | (modify-syntax-entry ?' ")`" table) |
| 87 | (modify-syntax-entry ?# "<\n" table) | 86 | (modify-syntax-entry ?# "<\n" table) |
| 88 | (modify-syntax-entry ?\n ">#" table) | 87 | (modify-syntax-entry ?\n ">#" table) |
| 89 | (modify-syntax-entry ?{ "_" table) | 88 | (modify-syntax-entry ?{ "." table) |
| 90 | (modify-syntax-entry ?} "_" table) | 89 | (modify-syntax-entry ?} "." table) |
| 91 | ;; FIXME: This symbol syntax for underscore looks OK on its own, but it's | ||
| 92 | ;; odd that it should have the same syntax as { and } are these really | ||
| 93 | ;; valid in m4 symbols? | ||
| 94 | (modify-syntax-entry ?_ "_" table) | 90 | (modify-syntax-entry ?_ "_" table) |
| 95 | ;; FIXME: These three chars with word syntax look wrong. | 91 | (modify-syntax-entry ?* "." table) |
| 96 | (modify-syntax-entry ?* "w" table) | 92 | (modify-syntax-entry ?\" "." table) |
| 97 | (modify-syntax-entry ?\" "w" table) | ||
| 98 | (modify-syntax-entry ?\" "w" table) | ||
| 99 | table) | 93 | table) |
| 100 | "Syntax table used while in `m4-mode'.") | 94 | "Syntax table used while in `m4-mode'.") |
| 101 | 95 | ||
| 96 | (defun m4--quoted-p (pos) | ||
| 97 | "Return non-nil if POS is inside a quoted string." | ||
| 98 | (let ((quoted nil)) | ||
| 99 | (dolist (o (nth 9 (save-excursion (syntax-ppss pos)))) | ||
| 100 | (if (eq (char-after o) ?\`) (setq quoted t))) | ||
| 101 | quoted)) | ||
| 102 | |||
| 103 | (defconst m4-syntax-propertize | ||
| 104 | (syntax-propertize-rules | ||
| 105 | ("#" (0 (when (m4--quoted-p (match-beginning 0)) | ||
| 106 | (string-to-syntax ".")))))) | ||
| 107 | |||
| 102 | (defvar m4-mode-map | 108 | (defvar m4-mode-map |
| 103 | (let ((map (make-sparse-keymap)) | 109 | (let ((map (make-sparse-keymap)) |
| 104 | (menu-map (make-sparse-keymap))) | 110 | (menu-map (make-sparse-keymap))) |
| @@ -148,7 +154,8 @@ If m4 is not in your PATH, set this to an absolute file name." | |||
| 148 | (setq-local comment-start "#") | 154 | (setq-local comment-start "#") |
| 149 | (setq-local parse-sexp-ignore-comments t) | 155 | (setq-local parse-sexp-ignore-comments t) |
| 150 | (setq-local add-log-current-defun-function #'m4-current-defun-name) | 156 | (setq-local add-log-current-defun-function #'m4-current-defun-name) |
| 151 | (setq font-lock-defaults '(m4-font-lock-keywords nil))) | 157 | (setq-local syntax-propertize-function m4-syntax-propertize) |
| 158 | (setq-local font-lock-defaults '(m4-font-lock-keywords nil))) | ||
| 152 | 159 | ||
| 153 | (provide 'm4-mode) | 160 | (provide 'm4-mode) |
| 154 | ;;stuff to play with for debugging | 161 | ;;stuff to play with for debugging |