emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] let octave-mode understand single-quoted strings


From: Jordi Gutiérrez Hermoso
Subject: Re: [PATCH] let octave-mode understand single-quoted strings
Date: Tue, 4 Oct 2011 10:13:23 -0500

On 7 October 2010 03:41, Stefan Monnier <address@hidden> wrote:
>>>>>> John W. Eaton <address@hidden> writes:
>> A single-quote character is recognized as a transpose operator if it
> [...]
>> Does that help?
>
> Yes, it does, thank you.
>
>> The Octave manual has a more complete description of how
>> "command-style" parsing works (yes, this is ugly; it was implemented
>> because it is required for compatibility with Matlab).
>
> Could you give me a pointer to it?  I haven't found it.
>
>>>>>> "Eric" == Eric M Ludlam <address@hidden> writes:
>> If not, the basic idea behind it is to use font-lock's functional matching
>> stuff.  Look to these functions:
>
>> matlab-font-lock-string-match-normal
>> matlab-font-lock-string-match-unterminated
>> matlab-font-lock-comment-match
>
> Thanks.  octave-mod.el uses syntax-table text-properties instead (since
> it has the advantage of making buffer navigation functions work
> correctly as well), so it's necessarily a bit different.
>
>> The strings and comments have to be done together, so you end up having to
>> use these functions in a particular order, checking to see what faces are
>> left behind while looking at comment chars to make sure it isn't in
>> a string.
>
> FWIW, I've appended the code I use now in octave-mod.el, since I think
> it's a good bit simpler.  It uses the new syntax-propertize feature, but
> you could use font-lock-syntactic-keywords instead.
>
>
>        Stefan
>
>
> (defun octave-syntax-propertize-function (start end)
>  (goto-char start)
>  (octave-syntax-propertize-sqs end)
>  (funcall (syntax-propertize-rules
>            ;; Try to distinguish the string-quotes from the transpose-quotes.
>            ("[[({,; ]\\('\\)"
>             (1 (prog1 "\"'" (octave-syntax-propertize-sqs end)))))
>           (point) end))
>
> (defun octave-syntax-propertize-sqs (end)
>  "Propertize the content/end of single-quote strings."
>  (when (eq (nth 3 (syntax-ppss)) ?\')
>    ;; A '..' string.
>    (when (re-search-forward
>           "\\(?:\\=\\|[^']\\)\\(?:''\\)*\\('\\)\\($\\|[^']\\)" end 'move)
>      (goto-char (match-beginning 2))
>            (when (eq (char-before (match-beginning 1)) ?\\)
>              ;; Backslash cannot escape a single quote.
>              (put-text-property (1- (match-beginning 1)) (match-beginning 1)
>                                 'syntax-table (string-to-syntax ".")))
>            (put-text-property (match-beginning 1) (match-end 1)
>                         'syntax-table (string-to-syntax "\"'")))))
>

Ping!

It's been almost a year. And still no single-quote strings in Octave
mode. I have forgotten what the issues were. Can this code be pushed
now to the bzr repo?

- Jordi G. H.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]