From: "Jordi Gutiérrez Hermoso" <jordigh@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "John W. Eaton" <jwe@octave.org>,
Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>,
Emacs development discussions <emacs-devel@gnu.org>,
Daniel Colascione <daniel@censorshipresearch.org>,
"Eric M. Ludlam" <eric@siege-engine.com>
Subject: Re: [PATCH] let octave-mode understand single-quoted strings
Date: Tue, 4 Oct 2011 10:13:23 -0500 [thread overview]
Message-ID: <CAPHS2gyyvvN2kubARnpWxxc=h8FUqw4wbTNDUVpzmuztZ3Ej=A@mail.gmail.com> (raw)
In-Reply-To: <jwvsk0io1h6.fsf-monnier+emacs@gnu.org>
On 7 October 2010 03:41, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>>>>> John W. Eaton <jwe@octave.org> 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 <eric@siege-engine.com> 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.
next prev parent reply other threads:[~2011-10-04 15:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-30 21:19 [PATCH] let octave-mode understand single-quoted strings Daniel Colascione
2010-08-31 12:32 ` Stefan Monnier
2010-08-31 21:15 ` Jordi Gutiérrez Hermoso
2010-09-01 6:46 ` Stefan Monnier
2010-09-02 14:07 ` Jordi Gutiérrez Hermoso
2010-09-02 16:24 ` Stefan Monnier
2010-09-02 23:46 ` Jordi Gutiérrez Hermoso
2010-09-03 10:48 ` Stefan Monnier
2010-10-05 8:28 ` John W. Eaton
2010-10-05 23:57 ` Eric M. Ludlam
2010-10-07 8:41 ` Stefan Monnier
2011-10-04 15:13 ` Jordi Gutiérrez Hermoso [this message]
2011-10-04 17:40 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPHS2gyyvvN2kubARnpWxxc=h8FUqw4wbTNDUVpzmuztZ3Ej=A@mail.gmail.com' \
--to=jordigh@gmail.com \
--cc=Kurt.Hornik@wu-wien.ac.at \
--cc=daniel@censorshipresearch.org \
--cc=emacs-devel@gnu.org \
--cc=eric@siege-engine.com \
--cc=jwe@octave.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.