GNU bug report logs - #46327
28.0.50; octave-mode: transpose-quotes taken as string-quotes

Previous Next

Package: emacs;

Reported by: Juang Dse <juangdse <at> gmail.com>

Date: Fri, 5 Feb 2021 14:04:02 UTC

Severity: normal

Found in version 28.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 46327 in the body.
You can then email your comments to 46327 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#46327; Package emacs. (Fri, 05 Feb 2021 14:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juang Dse <juangdse <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 05 Feb 2021 14:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juang Dse <juangdse <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; octave-mode: transpose-quotes taken as string-quotes
Date: Fri, 5 Feb 2021 15:02:50 +0100
octave-mode takes the transpose sign (') for a string quote, and
indents incorrectly.

This can be seen by the two lines
---------------
x = [2 2]'
disp(x)
---------------
and using indent-for-tab-command (TAB) for the 2nd line.



In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.17.4, Xaw scroll bars)
 of 2021-02-05 built on mymachine
Repository revision: 9730575f3a2599be0a4f9c3d1ef5321bf1294e93
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12010000
System Description: Manjaro Linux

Configured using:
 'configure --prefix=/opt/emacs --without-docs --with-x-toolkit=lucid'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY
PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM
LUCID ZLIB

Important settings:
  value of $LC_MONETARY: de_DE.UTF-8
  value of $LC_NUMERIC: de_DE.UTF-8
  value of $LC_TIME: de_DE.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  show-paren-mode: t
  recentf-mode: t
  savehist-mode: t
  image-diredx-async-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort octave smie comint ansi-color ring mail-extr emacsbug
message rmc puny rfc822 mml mml-sec gnus-util rmail rmail-loaddefs
text-property-search time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils paren cus-start cus-load
recentf tree-widget wid-edit savehist epa-file epa derived epg
epg-config image-dired+ image-dired image-mode exif dired dired-loaddefs
advice cl info package easymenu browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq
byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 93033 5796)
 (symbols 48 11171 4)
 (strings 32 33831 1230)
 (string-bytes 1 1078718)
 (vectors 16 16794)
 (vector-slots 8 214572 11574)
 (floats 8 45 35)
 (intervals 56 384 0)
 (buffers 984 10))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46327; Package emacs. (Sun, 07 Feb 2021 13:08:01 GMT) Full text and rfc822 format available.

Message #8 received at 46327 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juang Dse <juangdse <at> gmail.com>
Cc: 46327 <at> debbugs.gnu.org
Subject: Re: bug#46327: 28.0.50; octave-mode: transpose-quotes taken as
 string-quotes
Date: Sun, 07 Feb 2021 14:06:47 +0100
Juang Dse <juangdse <at> gmail.com> writes:

> octave-mode takes the transpose sign (') for a string quote, and
> indents incorrectly.
>
> This can be seen by the two lines
> ---------------
> x = [2 2]'
> disp(x)
> ---------------
> and using indent-for-tab-command (TAB) for the 2nd line.

This is due to the following patch:

commit 9e68413c7f0a7f71e1cee923ace7282d14c2e686
Author:     Noam Postavsky <npostavs <at> users.sourceforge.net>
AuthorDate: Mon Aug 24 17:33:49 2020 +0200

    Fix inferior octave single-quote font lock
    
    * lisp/progmodes/octave.el (octave-mode-syntax-table): Fix
    fontification of single quotes in inferior octave mode (bug#25517).
    
    It looks like the problem is that octave-mode-syntax-table sets single
    quotes as punctuation even though GNU Octave's manual says single quotes
    are string syntax [1].
    
    [1]:
    https://www.gnu.org/software/octave/doc/interpreter/String-Objects.html

And, indeed, that link says:

"A character string in Octave consists of a sequence of characters
enclosed in either double-quote or single-quote marks."

But the ' character is also a transposition operator?  I don't know
Octave at all -- this seems like a rather ambiguous syntax?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46327; Package emacs. (Sun, 07 Feb 2021 14:06:01 GMT) Full text and rfc822 format available.

Message #11 received at 46327 <at> debbugs.gnu.org (full text, mbox):

From: Juang Dse <juangdse <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 46327 <at> debbugs.gnu.org
Subject: Re: bug#46327: 28.0.50;
 octave-mode: transpose-quotes taken as string-quotes
Date: Sun, 7 Feb 2021 15:04:56 +0100
indeed, the ' character is the transpose operator (like in matlab),
and that patch makes emacs essentially useless for octave. Without it,
everything looks fine as I just verified.

Note that the ' character as a string occurs only in pairs, which is
(hopefully) unambiguous.

On Sun, Feb 7, 2021 at 2:06 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
>
> Juang Dse <juangdse <at> gmail.com> writes:
>
> > octave-mode takes the transpose sign (') for a string quote, and
> > indents incorrectly.
> >
> > This can be seen by the two lines
> > ---------------
> > x = [2 2]'
> > disp(x)
> > ---------------
> > and using indent-for-tab-command (TAB) for the 2nd line.
>
> This is due to the following patch:
>
> commit 9e68413c7f0a7f71e1cee923ace7282d14c2e686
> Author:     Noam Postavsky <npostavs <at> users.sourceforge.net>
> AuthorDate: Mon Aug 24 17:33:49 2020 +0200
>
>     Fix inferior octave single-quote font lock
>
>     * lisp/progmodes/octave.el (octave-mode-syntax-table): Fix
>     fontification of single quotes in inferior octave mode (bug#25517).
>
>     It looks like the problem is that octave-mode-syntax-table sets single
>     quotes as punctuation even though GNU Octave's manual says single quotes
>     are string syntax [1].
>
>     [1]:
>     https://www.gnu.org/software/octave/doc/interpreter/String-Objects.html
>
> And, indeed, that link says:
>
> "A character string in Octave consists of a sequence of characters
> enclosed in either double-quote or single-quote marks."
>
> But the ' character is also a transposition operator?  I don't know
> Octave at all -- this seems like a rather ambiguous syntax?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46327; Package emacs. (Sun, 07 Feb 2021 14:12:01 GMT) Full text and rfc822 format available.

Message #14 received at 46327 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juang Dse <juangdse <at> gmail.com>
Cc: 46327 <at> debbugs.gnu.org
Subject: Re: bug#46327: 28.0.50; octave-mode: transpose-quotes taken as
 string-quotes
Date: Sun, 07 Feb 2021 15:11:44 +0100
Juang Dse <juangdse <at> gmail.com> writes:

> Note that the ' character as a string occurs only in pairs, which is
> (hopefully) unambiguous.

Can an Octave string span several lines?  In that case, it's ambiguous
whether

x = [2 2]'
disp(x)

is a transpose character, or an error (with a forgotten ' somewhere), I
guess.

Anyway, I'm reverting the patch, and reopening the other bug report
(bug#25517), which was about

x = 'foo'

not being fontified as a string.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46327; Package emacs. (Sun, 07 Feb 2021 14:49:02 GMT) Full text and rfc822 format available.

Message #17 received at 46327 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Juang Dse <juangdse <at> gmail.com>, 46327 <at> debbugs.gnu.org
Subject: Re: bug#46327: 28.0.50; octave-mode: transpose-quotes taken as
 string-quotes
Date: Sun, 07 Feb 2021 14:48:47 +0000
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Juang Dse <juangdse <at> gmail.com> writes:
>
>> Note that the ' character as a string occurs only in pairs, which is
>> (hopefully) unambiguous.
>
> Can an Octave string span several lines?  In that case, it's ambiguous
> whether
>
> x = [2 2]'
> disp(x)
>
> is a transpose character, or an error (with a forgotten ' somewhere), I
> guess.

I'm new to Octave, so I could be wrong, but AFAIK single-quoted string
literals do not support line continuations.  The only special construct
they may contain is '' which inserts a single '.

Quoth (info "(octave) Strings"):

     Since the single-quote mark is also used for the transpose operator
  (*note Arithmetic Ops) but double-quote marks have no other purpose in
  Octave, it is best to use double-quote marks to denote strings.

Quoth (info "(octave) Escape Sequences in String Constants"):

  In double-quoted strings, the backslash character is used to introduce
  “escape sequences” that represent other characters.  For example, ‘\n’
  embeds a newline character in a double-quoted string and ‘\"’ embeds a
  double quote character.  In single-quoted strings, backslash is not a
  special character.  Here is an example showing the difference:

  [...]

     In a single-quoted string there is only one escape sequence: you may
  insert a single quote character using two single quote characters in
  succession.  For example,

       'I can''t escape'
           ⇒ I can't escape

Quoth (info "(octave) Continuation Lines"):

  In the Octave language, most statements end with a newline character and
  you must tell Octave to ignore the newline character in order to
  continue a statement from one line to the next.  Lines that end with the
  characters ‘...’ are joined with the following line before they are
  divided into tokens by Octave’s parser.  For example, the lines

       x = long_variable_name ...
           + longer_variable_name ...
           - 42

  form a single statement.

     Any text between the continuation marker and the newline character is
  ignored.  For example, the statement

       x = long_variable_name ...    # comment one
           + longer_variable_name ...comment two
           - 42                      # last comment

  is equivalent to the one shown above.

     Inside double-quoted string constants, the character ‘\’ has to be
  used as continuation marker.  The ‘\’ must appear at the end of the line
  just before the newline character:

       s = "This text starts in the first line \
       and is continued in the second line."

Apparently ellipsis continuation lines were also once supported in
double-quoted string literals:

  octave:1> "foo ...RET
  warning: '...' continuations in double-quoted character strings are
  obsolete and will not be allowed in a future version of Octave;
  please use '\' instead

HTH,

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46327; Package emacs. (Sun, 07 Feb 2021 15:17:01 GMT) Full text and rfc822 format available.

Message #20 received at 46327 <at> debbugs.gnu.org (full text, mbox):

From: Juang Dse <juangdse <at> gmail.com>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 46327 <at> debbugs.gnu.org
Subject: Re: bug#46327: 28.0.50;
 octave-mode: transpose-quotes taken as string-quotes
Date: Sun, 7 Feb 2021 16:16:06 +0100
That basically describes continuation, thx.

I noticed that the behavior of bug 25517 only occurs in the inferior
buffer. The octave buffer itself has everything right.

On Sun, Feb 7, 2021 at 3:48 PM Basil L. Contovounesios <contovob <at> tcd.ie> wrote:
>
> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>
> > Juang Dse <juangdse <at> gmail.com> writes:
> >
> >> Note that the ' character as a string occurs only in pairs, which is
> >> (hopefully) unambiguous.
> >
> > Can an Octave string span several lines?  In that case, it's ambiguous
> > whether
> >
> > x = [2 2]'
> > disp(x)
> >
> > is a transpose character, or an error (with a forgotten ' somewhere), I
> > guess.
>
> I'm new to Octave, so I could be wrong, but AFAIK single-quoted string
> literals do not support line continuations.  The only special construct
> they may contain is '' which inserts a single '.
>
> Quoth (info "(octave) Strings"):
>
>      Since the single-quote mark is also used for the transpose operator
>   (*note Arithmetic Ops) but double-quote marks have no other purpose in
>   Octave, it is best to use double-quote marks to denote strings.
>
> Quoth (info "(octave) Escape Sequences in String Constants"):
>
>   In double-quoted strings, the backslash character is used to introduce
>   “escape sequences” that represent other characters.  For example, ‘\n’
>   embeds a newline character in a double-quoted string and ‘\"’ embeds a
>   double quote character.  In single-quoted strings, backslash is not a
>   special character.  Here is an example showing the difference:
>
>   [...]
>
>      In a single-quoted string there is only one escape sequence: you may
>   insert a single quote character using two single quote characters in
>   succession.  For example,
>
>        'I can''t escape'
>            ⇒ I can't escape
>
> Quoth (info "(octave) Continuation Lines"):
>
>   In the Octave language, most statements end with a newline character and
>   you must tell Octave to ignore the newline character in order to
>   continue a statement from one line to the next.  Lines that end with the
>   characters ‘...’ are joined with the following line before they are
>   divided into tokens by Octave’s parser.  For example, the lines
>
>        x = long_variable_name ...
>            + longer_variable_name ...
>            - 42
>
>   form a single statement.
>
>      Any text between the continuation marker and the newline character is
>   ignored.  For example, the statement
>
>        x = long_variable_name ...    # comment one
>            + longer_variable_name ...comment two
>            - 42                      # last comment
>
>   is equivalent to the one shown above.
>
>      Inside double-quoted string constants, the character ‘\’ has to be
>   used as continuation marker.  The ‘\’ must appear at the end of the line
>   just before the newline character:
>
>        s = "This text starts in the first line \
>        and is continued in the second line."
>
> Apparently ellipsis continuation lines were also once supported in
> double-quoted string literals:
>
>   octave:1> "foo ...RET
>   warning: '...' continuations in double-quoted character strings are
>   obsolete and will not be allowed in a future version of Octave;
>   please use '\' instead
>
> HTH,
>
> --
> Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46327; Package emacs. (Sun, 07 Feb 2021 20:37:01 GMT) Full text and rfc822 format available.

Message #23 received at 46327 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: Juang Dse <juangdse <at> gmail.com>, 46327 <at> debbugs.gnu.org
Subject: Re: bug#46327: 28.0.50; octave-mode: transpose-quotes taken as
 string-quotes
Date: Sun, 07 Feb 2021 21:36:00 +0100
"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:

> I'm new to Octave, so I could be wrong, but AFAIK single-quoted string
> literals do not support line continuations.  The only special construct
> they may contain is '' which inserts a single '.

Thanks; I guess that should make it possible to distinguish between the
transpose operator and single-quoted strings (and the '' quoting sounds
quite similar to how SQL quotes single quotes, so the code to handle
that could be cribbed from sql.el).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46327; Package emacs. (Thu, 16 Jun 2022 13:12:01 GMT) Full text and rfc822 format available.

Message #26 received at 46327 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: Juang Dse <juangdse <at> gmail.com>, 46327 <at> debbugs.gnu.org
Subject: Re: bug#46327: 28.0.50; octave-mode: transpose-quotes taken as
 string-quotes
Date: Thu, 16 Jun 2022 15:11:42 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> "Basil L. Contovounesios" <contovob <at> tcd.ie> writes:
>
>> I'm new to Octave, so I could be wrong, but AFAIK single-quoted string
>> literals do not support line continuations.  The only special construct
>> they may contain is '' which inserts a single '.
>
> Thanks; I guess that should make it possible to distinguish between the
> transpose operator and single-quoted strings (and the '' quoting sounds
> quite similar to how SQL quotes single quotes, so the code to handle
> that could be cribbed from sql.el).

Looking at this again, it seems like things work as they're supposed to.
I.e., this fontifies/indents correctly:

x = [2 2]'
foo = 'bar'
disp(x)

So I'm closing this bug report.  (If I've missed something, please
respond to the debbugs address and we'll reopen.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 46327 <at> debbugs.gnu.org and Juang Dse <juangdse <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 16 Jun 2022 13:13:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 15 Jul 2022 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 283 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.