From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Eric M. Ludlam" Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] let octave-mode understand single-quoted strings Date: Tue, 05 Oct 2010 19:57:41 -0400 Message-ID: <4CABBB75.2010606@siege-engine.com> References: <4C02D67D.5090302@censorshipresearch.org> <19626.57759.799627.189216@segfault.lan> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1286323082 7919 80.91.229.12 (5 Oct 2010 23:58:02 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 5 Oct 2010 23:58:02 +0000 (UTC) Cc: Kurt Hornik , =?ISO-8859-1?Q?Jordi_Guti=E9rrez_Hermoso?= , Emacs development discussions , Stefan Monnier , Daniel Colascione To: "John W. Eaton" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 06 01:57:58 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P3HOO-0000K9-1F for ged-emacs-devel@m.gmane.org; Wed, 06 Oct 2010 01:57:56 +0200 Original-Received: from localhost ([127.0.0.1]:35937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P3HON-0002yS-Ec for ged-emacs-devel@m.gmane.org; Tue, 05 Oct 2010 19:57:55 -0400 Original-Received: from [140.186.70.92] (port=32883 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P3HOG-0002x9-6x for emacs-devel@gnu.org; Tue, 05 Oct 2010 19:57:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P3HOD-00010e-Ja for emacs-devel@gnu.org; Tue, 05 Oct 2010 19:57:47 -0400 Original-Received: from bird.interbax.net ([75.126.100.114]:58228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P3HOD-00010G-E0 for emacs-devel@gnu.org; Tue, 05 Oct 2010 19:57:45 -0400 Original-Received: (qmail 7591 invoked from network); 5 Oct 2010 18:57:42 -0500 Original-Received: from static-71-184-83-10.bstnma.fios.verizon.net (HELO ?192.168.1.201?) (71.184.83.10) by interbax.net with SMTP; 5 Oct 2010 18:57:42 -0500 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.3a1pre) Gecko/20091222 Shredder/3.1a1pre In-Reply-To: <19626.57759.799627.189216@segfault.lan> X-detected-operating-system: by eggs.gnu.org: Windows 98 (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:131380 Archived-At: 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 > >