aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2011-04-19 12:33:34 -0300
committerStefan Monnier2011-04-19 12:33:34 -0300
commit602ea69dc7a93969742958ee6af3feae23cd1e02 (patch)
tree044639275d20a34534c7442dd72b5807dfedbcda
parent06b605171f1c9d8b42bd3326a243b8b03d2e4e58 (diff)
downloademacs-602ea69dc7a93969742958ee6af3feae23cd1e02.tar.gz
emacs-602ea69dc7a93969742958ee6af3feae23cd1e02.zip
* lisp/progmodes/octave-mod.el (octave-in-comment-p, octave-in-string-p)
(octave-not-in-string-or-comment-p): Use syntax-ppss so it works with multi-line comments as well.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/progmodes/octave-mod.el26
2 files changed, 16 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 22c9813b5ce..66f854da5e3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12011-04-19 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/octave-mod.el (octave-in-comment-p, octave-in-string-p)
4 (octave-not-in-string-or-comment-p): Use syntax-ppss so it works with
5 multi-line comments as well.
6
12011-04-19 Juanma Barranquero <lekktu@gmail.com> 72011-04-19 Juanma Barranquero <lekktu@gmail.com>
2 8
3 Lexical-binding cleanup. 9 Lexical-binding cleanup.
diff --git a/lisp/progmodes/octave-mod.el b/lisp/progmodes/octave-mod.el
index 7ec4cf3d947..8bf9ff299d0 100644
--- a/lisp/progmodes/octave-mod.el
+++ b/lisp/progmodes/octave-mod.el
@@ -182,7 +182,7 @@ parenthetical grouping.")
182 (goto-char start) 182 (goto-char start)
183 (octave-syntax-propertize-sqs end) 183 (octave-syntax-propertize-sqs end)
184 (funcall (syntax-propertize-rules 184 (funcall (syntax-propertize-rules
185 ;; Try to distinguish the string-quotes from the transpose-quotes. 185 ;; Try to distinguish the string-quotes from the transpose-quotes.
186 ("[[({,; ]\\('\\)" 186 ("[[({,; ]\\('\\)"
187 (1 (prog1 "\"'" (octave-syntax-propertize-sqs end))))) 187 (1 (prog1 "\"'" (octave-syntax-propertize-sqs end)))))
188 (point) end)) 188 (point) end))
@@ -190,15 +190,15 @@ parenthetical grouping.")
190(defun octave-syntax-propertize-sqs (end) 190(defun octave-syntax-propertize-sqs (end)
191 "Propertize the content/end of single-quote strings." 191 "Propertize the content/end of single-quote strings."
192 (when (eq (nth 3 (syntax-ppss)) ?\') 192 (when (eq (nth 3 (syntax-ppss)) ?\')
193 ;; A '..' string. 193 ;; A '..' string.
194 (when (re-search-forward 194 (when (re-search-forward
195 "\\(?:\\=\\|[^']\\)\\(?:''\\)*\\('\\)\\($\\|[^']\\)" end 'move) 195 "\\(?:\\=\\|[^']\\)\\(?:''\\)*\\('\\)\\($\\|[^']\\)" end 'move)
196 (goto-char (match-beginning 2)) 196 (goto-char (match-beginning 2))
197 (when (eq (char-before (match-beginning 1)) ?\\) 197 (when (eq (char-before (match-beginning 1)) ?\\)
198 ;; Backslash cannot escape a single quote. 198 ;; Backslash cannot escape a single quote.
199 (put-text-property (1- (match-beginning 1)) (match-beginning 1) 199 (put-text-property (1- (match-beginning 1)) (match-beginning 1)
200 'syntax-table (string-to-syntax "."))) 200 'syntax-table (string-to-syntax ".")))
201 (put-text-property (match-beginning 1) (match-end 1) 201 (put-text-property (match-beginning 1) (match-end 1)
202 'syntax-table (string-to-syntax "\"'"))))) 202 'syntax-table (string-to-syntax "\"'")))))
203 203
204(defcustom inferior-octave-buffer "*Inferior Octave*" 204(defcustom inferior-octave-buffer "*Inferior Octave*"
@@ -668,20 +668,15 @@ Look up symbol in the function, operator and variable indices of the info files.
668 668
669(defsubst octave-in-comment-p () 669(defsubst octave-in-comment-p ()
670 "Return t if point is inside an Octave comment." 670 "Return t if point is inside an Octave comment."
671 (save-excursion 671 (nth 4 (syntax-ppss)))
672 ;; FIXME: use syntax-ppss?
673 (nth 4 (parse-partial-sexp (line-beginning-position) (point)))))
674 672
675(defsubst octave-in-string-p () 673(defsubst octave-in-string-p ()
676 "Return t if point is inside an Octave string." 674 "Return t if point is inside an Octave string."
677 (save-excursion 675 (nth 3 (syntax-ppss)))
678 ;; FIXME: use syntax-ppss?
679 (nth 3 (parse-partial-sexp (line-beginning-position) (point)))))
680 676
681(defsubst octave-not-in-string-or-comment-p () 677(defsubst octave-not-in-string-or-comment-p ()
682 "Return t if point is not inside an Octave string or comment." 678 "Return t if point is not inside an Octave string or comment."
683 ;; FIXME: Use syntax-ppss? 679 (let ((pps (syntax-ppss)))
684 (let ((pps (parse-partial-sexp (line-beginning-position) (point))))
685 (not (or (nth 3 pps) (nth 4 pps))))) 680 (not (or (nth 3 pps) (nth 4 pps)))))
686 681
687 682
@@ -698,7 +693,6 @@ Look up symbol in the function, operator and variable indices of the info files.
698 nil 693 nil
699 (delete-horizontal-space) 694 (delete-horizontal-space)
700 (insert (concat " " octave-continuation-string)))) 695 (insert (concat " " octave-continuation-string))))
701
702 696
703;;; Indentation 697;;; Indentation
704 698