Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit f5f4b3b

Browse files
committed
Remove unneeded save-excursion.
syntax-propertize-function is allowed to move the point and mark.
1 parent b532cab commit f5f4b3b

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

misc/ninja-mode.el

+21-22
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,27 @@
4747

4848
(defun ninja-syntax-propertize (start end)
4949
(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)))))))))
7271

7372
;;;###autoload
7473
(define-derived-mode ninja-mode prog-mode "ninja"

0 commit comments

Comments
 (0)