|
47 | 47 |
|
48 | 48 | (defun ninja-syntax-propertize (start end)
|
49 | 49 | (save-match-data
|
50 |
| - (save-excursion |
51 |
| - (goto-char start) |
52 |
| - (while (search-forward "#" end t) |
53 |
| - (let ((match-pos (match-beginning 0))) |
54 |
| - (when (and |
55 |
| - ;; Is it the first non-white character on the line? |
56 |
| - (eq match-pos (save-excursion (back-to-indentation) (point))) |
57 |
| - (save-excursion |
58 |
| - (goto-char (line-end-position 0)) |
59 |
| - (or |
60 |
| - ;; If we're continuting the previous line, it's not a |
61 |
| - ;; comment. |
62 |
| - (not (eq ?$ (char-before))) |
63 |
| - ;; Except if the previous line is a comment as well, as the |
64 |
| - ;; continuation dollar is ignored then. |
65 |
| - (nth 4 (syntax-ppss))))) |
66 |
| - (put-text-property match-pos (1+ match-pos) 'syntax-table '(11)) |
67 |
| - (let ((line-end (line-end-position))) |
68 |
| - ;; Avoid putting properties past the end of the buffer. |
69 |
| - ;; Otherwise we get an `args-out-of-range' error. |
70 |
| - (unless (= line-end (1+ (buffer-size))) |
71 |
| - (put-text-property line-end (1+ line-end) 'syntax-table '(12)))))))))) |
| 50 | + (goto-char start) |
| 51 | + (while (search-forward "#" end t) |
| 52 | + (let ((match-pos (match-beginning 0))) |
| 53 | + (when (and |
| 54 | + ;; Is it the first non-white character on the line? |
| 55 | + (eq match-pos (save-excursion (back-to-indentation) (point))) |
| 56 | + (save-excursion |
| 57 | + (goto-char (line-end-position 0)) |
| 58 | + (or |
| 59 | + ;; If we're continuting the previous line, it's not a |
| 60 | + ;; comment. |
| 61 | + (not (eq ?$ (char-before))) |
| 62 | + ;; Except if the previous line is a comment as well, as the |
| 63 | + ;; continuation dollar is ignored then. |
| 64 | + (nth 4 (syntax-ppss))))) |
| 65 | + (put-text-property match-pos (1+ match-pos) 'syntax-table '(11)) |
| 66 | + (let ((line-end (line-end-position))) |
| 67 | + ;; Avoid putting properties past the end of the buffer. |
| 68 | + ;; Otherwise we get an `args-out-of-range' error. |
| 69 | + (unless (= line-end (1+ (buffer-size))) |
| 70 | + (put-text-property line-end (1+ line-end) 'syntax-table '(12))))))))) |
72 | 71 |
|
73 | 72 | ;;;###autoload
|
74 | 73 | (define-derived-mode ninja-mode prog-mode "ninja"
|
|
0 commit comments