all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: "Jordi Gutiérrez Hermoso" <jordigh@gmail.com>
Cc: "John W. Eaton" <jwe@octave.org>,
	Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>,
	Emacs, Daniel Colascione <daniel@censorshipresearch.org>,
	development discussions <emacs-devel@gnu.org>
Subject: Re: [PATCH] let octave-mode understand single-quoted strings
Date: Fri, 03 Sep 2010 12:48:35 +0200	[thread overview]
Message-ID: <jwv62yn3zh9.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <AANLkTinaL4PYzGr8qEG21hPu-+PCYNFx7FWbjmm+QQ1N@mail.gmail.com> ("Jordi Gutiérrez Hermoso"'s message of "Thu, 2 Sep 2010 18:46:54 -0500")

>> 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".
> The thing is that Matlab has a quirk where a' means the transpose of a
> and 'a' means the string containing a, and Octave inherits this
> syntax. That's the trickiest thing about single-quote strings in
> Octave (and why Octave sources encourage using double-quote strings
> all the time).

Right.

> I still don't get why this is related to multiline issues, though.

It's not directly related.

> Where is your patch?

In Emacs's trunk.  See below.
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.


        Stefan


=== modified file 'lisp/progmodes/octave-mod.el'
--- lisp/progmodes/octave-mod.el	2010-08-12 14:44:16 +0000
+++ lisp/progmodes/octave-mod.el	2010-08-17 15:49:30 +0000
@@ -181,6 +179,30 @@
 	 '(3 font-lock-function-name-face nil t)))
   "Additional Octave expressions to highlight.")
 
+(defvar octave-font-lock-syntactic-keywords
+  ;; Try to distinguish the string-quotes from the transpose-quotes.
+  '(("[[({,; ]\\('\\)" (1 "\"'"))
+    (octave-font-lock-close-quotes)))
+
+(defun octave-font-lock-close-quotes (limit)
+  "Fix the syntax-table of the closing quotes of single-quote strings."
+  ;; Freely inspired from perl-font-lock-special-syntactic-constructs.
+  (let ((state (syntax-ppss)))
+    (while (< (point) limit)
+      (cond
+       ((eq (nth 3 state) ?\')
+        ;; A '..' string.
+        (save-excursion
+          (when (and (or (looking-at "\\('\\)")
+                         (re-search-forward "[^\\]\\(?:\\\\\\\\\\)*\\('\\)"
+                                            nil t))
+                     (not (eobp)))
+            (put-text-property (match-beginning 1) (match-end 1)
+                               'syntax-table (string-to-syntax "\"'"))))))
+
+      (setq state (parse-partial-sexp (point) limit nil nil state
+				      'syntax-table)))))
+
 (defcustom inferior-octave-buffer "*Inferior Octave*"
   "Name of buffer for running an inferior Octave process."
   :type 'string



  reply	other threads:[~2010-09-03 10:48 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 [this message]
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
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=jwv62yn3zh9.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=Kurt.Hornik@wu-wien.ac.at \
    --cc=daniel@censorshipresearch.org \
    --cc=emacs-devel@gnu.org \
    --cc=jordigh@gmail.com \
    --cc=jwe@octave.org \
    /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.