Subject: Re: bug#14332: 24.3; Octave indentation bug

From: Leo Liu <[email-masked]>
Date: Mon, 06 May 2013 11:29:42 +0800

On 2013-05-06 09:04 +0800, Stefan Monnier wrote:
> Then your best bet is probably to put in the mode's syntax-table the
> syntax corresponding to the most common use of \ (either as an escape
> char in strings or as an operator), and then use syntax-propertize to
> put the other syntax on the other case (where you can check (nth
> 3 (syntax-ppss (math-beginning 0))) to see if you're within a string).

What I would like is to have \ mean "." unless it is in double-quoted
strings where it should be "\\". I have the following non-working patch.
Ideas?

diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 2e848600..d5a1af2b 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -137,6 +137,8 @@ (defun octave-syntax-propertize-function (start end)
   (goto-char start)
   (octave-syntax-propertize-sqs end)
   (funcall (syntax-propertize-rules
+            ("\\\\" (0 (when (eq (nth 3 (syntax-ppss (match-beginning 0))) ?\")
+                         "\\")))
             ;; Try to distinguish the string-quotes from the transpose-quotes.
             ("\\(?:^\\|[[({,; ]\\)\\('\\)"
              (1 (prog1 "\"'" (octave-syntax-propertize-sqs end)))))
@@ -242,7 +244,7 @@ (defvar octave-mode-syntax-table
     (modify-syntax-entry ?& "."   table)
     (modify-syntax-entry ?| "."   table)
     (modify-syntax-entry ?! "."   table)
-    (modify-syntax-entry ?\\ "\\" table)
+    (modify-syntax-entry ?\\ "."  table)
     (modify-syntax-entry ?\' "."  table)
     ;; Was "w" for abbrevs, but now that it's not necessary any more,
     (modify-syntax-entry ?\` "."  table)