From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#46420: 28.0.50; Wrong line continuation in double-quoted Octave strings Date: Wed, 10 Feb 2021 11:37:30 +0000 Message-ID: <87blcsxif9.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10028"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: 46420@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 10 12:43:28 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l9nu3-0002Ta-Vb for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Feb 2021 12:43:28 +0100 Original-Received: from localhost ([::1]:54186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9nu2-000351-Uu for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Feb 2021 06:43:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9nop-0006vU-3U for bug-gnu-emacs@gnu.org; Wed, 10 Feb 2021 06:38:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44053) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9non-00060C-Vn for bug-gnu-emacs@gnu.org; Wed, 10 Feb 2021 06:38:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l9non-0003ZC-Tx for bug-gnu-emacs@gnu.org; Wed, 10 Feb 2021 06:38:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Feb 2021 11:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46420 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161295706113680 (code B ref -1); Wed, 10 Feb 2021 11:38:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Feb 2021 11:37:41 +0000 Original-Received: from localhost ([127.0.0.1]:55599 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9noT-0003YZ-1d for submit@debbugs.gnu.org; Wed, 10 Feb 2021 06:37:41 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:45130) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9noP-0003YP-O1 for submit@debbugs.gnu.org; Wed, 10 Feb 2021 06:37:40 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9noP-0006oM-H9 for bug-gnu-emacs@gnu.org; Wed, 10 Feb 2021 06:37:37 -0500 Original-Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:51904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9noN-0005pA-5H for bug-gnu-emacs@gnu.org; Wed, 10 Feb 2021 06:37:37 -0500 Original-Received: by mail-wm1-x331.google.com with SMTP id t142so1550621wmt.1 for ; Wed, 10 Feb 2021 03:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:user-agent:mime-version; bh=sKq9ZJZtHsJP+QKnGLiP/jjLI8dFiSLsvn35c1OWfic=; b=eFgSdo7BxwTxRErG5OK+gbbpoV8T4N+3utvvdcB7h+3+CWqT2y0AgUvoUEMhX5IiAB aVSuHvU/Y8OPJRtiOSXBe2mxbSDLkuUMqwZyPpJPC2RrD94O1Ce5o9rCndPeFXqPaE7r Z01nARJo4QdJXqS6tu9FLIgwHKIIp4IHvQVRmWsIFe63PTfMQE45nlJwO7uwMKUf5w5p dl6HASj+jmC+AOs3niUTPC0peyglhdfu2FrZ1/lgc2/m4tRSwgSI39salA/6QyMmJ60n XA3lfV286z2n6OVCVpqm7bVBuL0cWhldxobW513TpSNmZ2DJTD1jQJdKFdNo8sBIPkz7 qvCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=sKq9ZJZtHsJP+QKnGLiP/jjLI8dFiSLsvn35c1OWfic=; b=Rf9Z5JuOLxXZEGyjQfrrt327IOdWyB74Kv4a78fpr90KtgRM6xp2yabQMDnr8Zbvvz 3UVk/ONbF8urc6wY7OztpdePnCDtep6hSaBKbePrjh54eI0znGlTGCYOs8bWlvyQW7lo 4n1GgSwsWY26Up15ePyAttd4QsnCH6zgu9YbPv5SFZg59asVgzgKCnNQUNZjWRVg7JSM iMYMj2D0MBiqEKVxPGWGASbkboao+JtMiJ60ScPMeU/hlU+Vc57pDEFsHN1zx3jYMmtV rrFN2n7giqLIpwbDfF5bfXUmmNXXd02fLbyVHENpSawAWnkX5fY0C3avOCBJZcE9Z6SA scLg== X-Gm-Message-State: AOAM533xvZOQ37RlYBRS1jl8riGrGMSR5SHhnOu2Ki8+1/aSLa06OKMH +NCjk1kqOgOovnqKQy7nx+ThrHGBkSWvjw== X-Google-Smtp-Source: ABdhPJxIrsOUgNuIwBCQ5yCDQR3gHKaQXh9GBPm3Z1oEXSJk1V1Or0vHzZccDthbWA5BrAfLrs51tA== X-Received: by 2002:a1c:7f83:: with SMTP id a125mr2478886wmd.141.1612957052971; Wed, 10 Feb 2021 03:37:32 -0800 (PST) Original-Received: from localhost ([2a02:8084:20e2:c380:6d2d:c2fa:f3fa:cabd]) by smtp.gmail.com with ESMTPSA id k205sm2218637wmf.23.2021.02.10.03.37.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 03:37:32 -0800 (PST) Received-SPF: none client-ip=2a00:1450:4864:20::331; envelope-from=contovob@tcd.ie; helo=mail-wm1-x331.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:199767 Archived-At: --=-=-= Content-Type: text/plain Tags: patch 0. emacs -Q 1. C-x b foo RET 2. M-x octave-mode RET 3. s = "foo C-M-j This inserts the line continuation marker '...' instead of '\'. Since Octave 3.8, released over 7 years ago, breaking double-quoted strings with an ellipsis, or breaking anything else with a backslash, is deprecated; see https://www.gnu.org/s/octave/NEWS-3.8.html and (info "(octave) Continuation Lines"). In the Octave 6.1 REPL: octave:1> s = "foo... warning: '...' continuations in double-quoted character strings are obsolete and will not be allowed in a future version of Octave; please use '\' instead > " s = foo octave:2> x = [1 \ warning: using continuation marker \ outside of double quoted strings is deprecated and will be removed from a future version of Octave, use ... instead > ] x = 1 I attach a patch which reintroduces the backslash as octave-string-continuation-marker, alongside the existing ellipsis octave-continuation-string. [ I think octave-string-continuation is the perfect name for the backslash, but I can imagine it not being very popular ;). Naming suggestions welcome. ] WDYT? -- Basil In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2021-02-09 built on tia Repository revision: bff9bd0d3acff0fa0a50e21bdeca024e71fa518b Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12010000 System Description: Debian GNU/Linux bullseye/sid Configured using: 'configure 'CC=ccache gcc' 'CFLAGS=-O2 -march=native' --config-cache --prefix=/home/blc/.local --enable-checking=structs --with-x-toolkit=lucid --with-file-notification=yes --with-x' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XAW3D XDBE XIM XPM LUCID ZLIB --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-Octave-double-quoted-string-line-continuations.patch >From 50d5a88ae7bb93efbba1d74af382a3a526134816 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Wed, 10 Feb 2021 01:30:08 +0000 Subject: [PATCH] Fix Octave double-quoted string line continuations * lisp/progmodes/octave.el (octave-string-continuation-marker): New defconst after octave-continuation-string. (octave-continuation-string): Mention it in docstring. (octave-maybe-insert-continuation-string): Mark unused function as obsolete. (octave-help-function): Simplify action. (octave--indent-new-comment-line): Insert octave-string-continuation-marker instead of octave-continuation-string within double-quoted strings. (octave-indent-new-comment-line): * etc/NEWS: Describe new behavior. --- doc/misc/octave-mode.texi | 5 +++- etc/NEWS | 9 +++++++ lisp/progmodes/octave.el | 49 +++++++++++++++++++++------------------ 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/doc/misc/octave-mode.texi b/doc/misc/octave-mode.texi index 1adc268969..e330606015 100644 --- a/doc/misc/octave-mode.texi +++ b/doc/misc/octave-mode.texi @@ -83,9 +83,12 @@ Using Octave Mode @kindex C-M-j @findex octave-indent-new-comment-line @vindex octave-continuation-string +@vindex octave-string-continuation-marker Break Octave line at point, continuing comment if within one. Insert @code{octave-continuation-string} before breaking the line unless -inside a list. Signal an error if within a single-quoted string. +inside a list. If within a double-quoted string, insert +@code{octave-string-continuation-marker} instead. Signal an error if +within a single-quoted string. @item C-c ; @kindex C-c ; diff --git a/etc/NEWS b/etc/NEWS index bd209de18e..1e447a58d9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2017,6 +2017,15 @@ could have saved enough typing by using an abbrev, a hint will be displayed in the echo area, mentioning the abbrev that could have been used instead. +** Octave Mode + ++++ +*** Line continuations in double-quoted strings now use a backslash. +Typing 'C-M-j' (bound to 'octave-indent-new-comment-line') now follows +the behavior introduced in Octave 3.8 of using a backslash as a line +continuation marker within double-quoted strings, and an ellipsis +everywhere else. + * New Modes and Packages in Emacs 28.1 diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index ddcc6f5450..a8a86478d8 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -215,9 +215,15 @@ octave-continuation-regexp (concat "[^#%\n]*\\(" octave-continuation-marker-regexp "\\)\\s-*\\(\\s<.*\\)?$")) -;; Char \ is considered a bad decision for continuing a line. (defconst octave-continuation-string "..." - "Character string used for Octave continuation lines.") + "Character string used for Octave continuation lines. +Joins current line with following line, except within +double-quoted strings, where `octave-string-continuation-marker' +is used instead.") + +(defconst octave-string-continuation-marker "\\" + "Line continuation marker for double-quoted Octave strings. +Non-string statements use `octave-continuation-string'.") (defvar octave-mode-imenu-generic-expression (list @@ -1032,11 +1038,11 @@ octave-looking-at-kw (looking-at regexp))) (defun octave-maybe-insert-continuation-string () - (if (or (octave-in-comment-p) - (save-excursion - (beginning-of-line) - (looking-at octave-continuation-regexp))) - nil + (declare (obsolete nil "28.1")) + (unless (or (octave-in-comment-p) + (save-excursion + (beginning-of-line) + (looking-at octave-continuation-regexp))) (delete-horizontal-space) (insert (concat " " octave-continuation-string)))) @@ -1218,23 +1224,22 @@ octave-font-lock-texinfo-comment (defun octave-indent-new-comment-line (&optional soft) "Break Octave line at point, continuing comment if within one. Insert `octave-continuation-string' before breaking the line -unless inside a list. Signal an error if within a single-quoted -string." +unless inside a list. If within a double-quoted string, insert +`octave-string-continuation-marker' instead. Signal an error if +within a single-quoted string." (interactive) (funcall comment-line-break-function soft)) (defun octave--indent-new-comment-line (orig &rest args) - (cond - ((octave-in-comment-p) nil) - ((eq (octave-in-string-p) ?') - (error "Cannot split a single-quoted string")) - ((eq (octave-in-string-p) ?\") - (insert octave-continuation-string)) - (t - (delete-horizontal-space) - (unless (and (cadr (syntax-ppss)) - (eq (char-after (cadr (syntax-ppss))) ?\()) - (insert " " octave-continuation-string)))) + (pcase (syntax-ppss) + ((app ppss-string-terminator ?\') + (user-error "Cannot split a single-quoted string")) + ((app ppss-string-terminator ?\") + (insert octave-string-continuation-marker)) + ((pred (not ppss-comment-depth)) + (delete-horizontal-space) + (unless (octave-smie--in-parens-p) + (insert " " octave-continuation-string)))) (apply orig args) (indent-according-to-mode)) @@ -1663,9 +1668,7 @@ 'octave-help-file (define-button-type 'octave-help-function 'follow-link t - 'action (lambda (b) - (octave-help - (buffer-substring (button-start b) (button-end b))))) + 'action (lambda (b) (octave-help (button-label b)))) (defvar octave-help-mode-map (let ((map (make-sparse-keymap))) -- 2.30.0 --=-=-=--