all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Eric M. Ludlam" <eric@siege-engine.com>
To: "John W. Eaton" <jwe@octave.org>
Cc: "Kurt Hornik" <Kurt.Hornik@wu-wien.ac.at>,
	"Jordi Gutiérrez Hermoso" <jordigh@gmail.com>,
	"Emacs development discussions" <emacs-devel@gnu.org>,
	"Stefan Monnier" <monnier@IRO.UMontreal.CA>,
	"Daniel Colascione" <daniel@censorshipresearch.org>
Subject: Re: [PATCH] let octave-mode understand single-quoted strings
Date: Tue, 05 Oct 2010 19:57:41 -0400	[thread overview]
Message-ID: <4CABBB75.2010606@siege-engine.com> (raw)
In-Reply-To: <19626.57759.799627.189216@segfault.lan>

The matlab mode that I support can be found here:

http://matlab-emacs.cvs.sourceforge.net/viewvc/matlab-emacs/matlab-emacs/

It has had many contributors so it couldn't be a part of emacs, but the 
string & comment font locking I wrote wholly myself as far as I 
remember.  If you would like to use it for octave I'm sure that could be 
arranged.

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

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.

Eric

On 10/05/2010 04:28 AM, John W. Eaton wrote:
> On  3-Sep-2010, Stefan Monnier wrote:
>
> |>>  I just implemented the single-quote string support based
> |>>  on code I previously wrote for perl-mode, where it's used for
> |>>  string-like thingies that often span multiple lines.  I.e. it came "for
> |>>  free".
>
> In Octave and Matlab, character strings can't span multiple lines.
>
> | BTW, where can I find a definition of the syntax of single-quoted
> | strings (i.e. how does Octave distinguish a transpose from a single-quote
> | starting a string)?
> | The Octave docs I have don't say anything about it, AFAICT.
>
> It's messy.
>
> A single-quote character is recognized as a transpose operator if it
>
> * Follows a ), ], or } character
>
>      ( .. )'     =>  tranpose expression
>      [ .. ]'     =>  tranpose matrix expression
>      { .. }'     =>  tranpose cell array expression
>
> * Follows a literal double-quoted string, or a literal single-quoted
>    string if there is a space between the transpose operator and the
>    final single-quote character that delimits the string.  For example
>
>      "string"'   =>  transpose the character array 'string'
>      'string' '  =>  transpose the character array 'string'
>      'string''   =>  unterminated string constant
>      'a''b'      =>  1x3 character array containing the characters a'b
>
> * Follows an identifier (variable or function name) unless the
>    identifier could be a "command".  For example
>
>      pwd '       =>  unterminated string constant
>      (pwd)'      =>  transpose the output from the pwd function
>      dir 'foo'   =>  list contents of the directory foo
>
> * Follows an expression that references a structure element:
>
>      a.b'        =>  return the transpose of a.b
>
>    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).
>
> Does that help?
>
> jwe
>
>



  reply	other threads:[~2010-10-05 23:57 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 [this message]
2010-10-07  8:41                   ` Stefan Monnier
2011-10-04 15:13                     ` Jordi Gutiérrez Hermoso
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=4CABBB75.2010606@siege-engine.com \
    --to=eric@siege-engine.com \
    --cc=Kurt.Hornik@wu-wien.ac.at \
    --cc=daniel@censorshipresearch.org \
    --cc=emacs-devel@gnu.org \
    --cc=jordigh@gmail.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.