GNU bug report logs - #26037
25.1; perl-mode add syntax support for subroutine signatures

Previous Next

Package: emacs;

Reported by: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>

Date: Thu, 9 Mar 2017 17:25:02 UTC

Severity: wishlist

Tags: fixed, patch

Found in version 25.1

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

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 26037 in the body.
You can then email your comments to 26037 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#26037; Package emacs. (Thu, 09 Mar 2017 17:25:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Evgeni Kolev <evgeni.d.kolev <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 09 Mar 2017 17:25:02 GMT) Full text and rfc822 format available.

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

From: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1; perl-mode add syntax support for subroutine signatures
Date: Thu, 9 Mar 2017 18:57:16 +0200
[Message part 1 (text/plain, inline)]
perl 5.20 (released May 2014) added experimental support for subroutine
signatures. So this is valid perl code:

sub test ($param) {
  ...
}

However, perl-mode's syntax rules treat everything between ( and ) as
punctuation (syntax class "."). As a result (thing-at-point 'word)
doesn't return $param when the point is on $param because $param is
considered punctuation. The patch below tries to address this by
using syntax class "@" inside the parens.


diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index a516f07..2b9d9ad 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -258,7 +258,7 @@
       ;; Funny things in `sub' arg-specs like `sub myfun ($)' or `sub ($)'.
       ;; Be careful not to match "sub { (...) ... }".
       ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([^)]+\\))"
-       (1 "."))
+       (1 "@"))
       ;; Turn __DATA__ trailer into a comment.
       ("^\\(_\\)_\\(?:DATA\\|END\\)__[
\t]*\\(?:\\(\n\\)#.-\\*-.*perl.*-\\*-\\|\n.*\\)"
        (1 "< c") (2 "> c")






In GNU Emacs 25.1.1 (x86_64-apple-darwin15.6.0)
 of 2017-01-21 built on evgeni-mba.local
Configured using:
 'configure --disable-dependency-tracking --disable-silent-rules
 --enable-locallisppath=/usr/local/share/emacs/site-lisp
 --infodir=/usr/local/Cellar/emacs/25.1/share/info/emacs
 --prefix=/usr/local/Cellar/emacs/25.1 --without-x --with-xml2
 --without-dbus --without-gnutls --without-ns'

Configured features:
JPEG NOTIFY ACL LIBXML2 ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  aggressive-indent-mode: t
  beacon-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  global-smart-tab-mode: t
  smart-tab-mode: t
  show-smartparens-global-mode: t
  show-smartparens-mode: t
  smartparens-mode: t
  winner-mode: t
  ivy-mode: t
  which-key-mode: t
  shackle-mode: t
  ido-vertical-mode: t
  save-place-mode: t
  recentf-mode: t
  global-evil-visualstar-mode: t
  evil-visualstar-mode: t
  evil-commentary-mode: t
  global-evil-surround-mode: t
  evil-surround-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  evil-mode: t
  evil-local-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent messages:
Loading package haskell-snippets...done
Loading package uniquify...
Configuring package uniquify...done
Loading package uniquify...done
Loading package beacon...
Configuring package beacon...done
Loading package beacon...done
Loading /Users/edkolev/.emacs.d/init.el...done (1.320s) [after-init]
Configuring package aggressive-indent...done
Configuring package dired...done

Load-path shadows:
~/dev/evil/evil hides /Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil
~/dev/evil/evil-vars hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-vars
~/dev/evil/evil-types hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-types
~/dev/evil/evil-states hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-states
~/dev/evil/evil-search hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-search
~/dev/evil/evil-repeat hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-repeat
~/dev/evil/evil-pkg hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-pkg
~/dev/evil/evil-maps hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-maps
~/dev/evil/evil-macros hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-macros
~/dev/evil/evil-jumps hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-jumps
~/dev/evil/evil-integration hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-integration
~/dev/evil/evil-ex hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-ex
~/dev/evil/evil-digraphs hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-digraphs
~/dev/evil/evil-core hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-core
~/dev/evil/evil-common hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-common
~/dev/evil/evil-commands hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-commands
~/dev/evil/evil-command-window hides
/Users/edkolev/.emacs.d/elpa/evil-20170209.1259/evil-command-window
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-xact hides
/usr/local/share/emacs/site-lisp/ledger/ledger-xact
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-texi hides
/usr/local/share/emacs/site-lisp/ledger/ledger-texi
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-test hides
/usr/local/share/emacs/site-lisp/ledger/ledger-test
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-state hides
/usr/local/share/emacs/site-lisp/ledger/ledger-state
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-sort hides
/usr/local/share/emacs/site-lisp/ledger/ledger-sort
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-schedule hides
/usr/local/share/emacs/site-lisp/ledger/ledger-schedule
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-report hides
/usr/local/share/emacs/site-lisp/ledger/ledger-report
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-regex hides
/usr/local/share/emacs/site-lisp/ledger/ledger-regex
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-reconcile
hides /usr/local/share/emacs/site-lisp/ledger/ledger-reconcile
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-post hides
/usr/local/share/emacs/site-lisp/ledger/ledger-post
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-occur hides
/usr/local/share/emacs/site-lisp/ledger/ledger-occur
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-navigate hides
/usr/local/share/emacs/site-lisp/ledger/ledger-navigate
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-mode hides
/usr/local/share/emacs/site-lisp/ledger/ledger-mode
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-init hides
/usr/local/share/emacs/site-lisp/ledger/ledger-init
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-fonts hides
/usr/local/share/emacs/site-lisp/ledger/ledger-fonts
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-fontify hides
/usr/local/share/emacs/site-lisp/ledger/ledger-fontify
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-exec hides
/usr/local/share/emacs/site-lisp/ledger/ledger-exec
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-context hides
/usr/local/share/emacs/site-lisp/ledger/ledger-context
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-complete hides
/usr/local/share/emacs/site-lisp/ledger/ledger-complete
/Users/edkolev/.emacs.d/elpa/ledger-mode-20170208.425/ledger-commodities
hides /usr/local/share/emacs/site-lisp/ledger/ledger-commodities
/Users/edkolev/.emacs.d/elpa/seq-2.19/seq hides
/usr/local/Cellar/emacs/25.1/share/emacs/25.1/lisp/emacs-lisp/seq

Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec epg mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils
colir color term/xterm xterm aggressive-indent beacon haskell-snippets
yasnippet smart-tab smartparens-config smartparens dash s ucs-normalize
winner whitespace ivy delsel ivy-overlay which-key shackle compile
ido-vertical-mode ido saveplace evil-indent-plus recentf tree-widget
wid-edit evil-visualstar evil-replace-with-register evil-exchange
evil-commentary evil-commentary-integration evil-surround evil
evil-integration undo-tree diff evil-maps evil-commands ffap url-parse
auth-source eieio eieio-core gnus-util time-date mm-util help-fns
mail-prsvr password-cache url-vars evil-jumps cl-seq evil-command-window
evil-types evil-search evil-ex evil-macros evil-repeat evil-states
evil-core evil-common derived cl-macs windmove cl thingatpt rect
evil-digraphs evil-vars hippie-exp comint regexp-opt ansi-color ring
edmacro kmacro general spacemacs-light-theme spacemacs-common
use-package diminish bind-key easy-mmode finder-inf advice info tool-bar
package epg-config seq byte-opt gv bytecomp byte-compile cl-extra
help-mode easymenu cconv cl-loaddefs pcase cl-lib mule-util tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select mouse jit-lock font-lock syntax
facemenu font-core frame 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 charscript case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp
files text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote kqueue multi-tty
make-network-process emacs)

Memory information:
((conses 16 452052 73574)
 (symbols 48 35184 3)
 (miscs 40 56 271)
 (strings 32 62447 49959)
 (string-bytes 1 1927618)
 (vectors 16 47695)
 (vector-slots 8 855243 19673)
 (floats 8 777 568)
 (intervals 56 270 16)
 (buffers 976 17))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Sat, 11 Mar 2017 14:26:02 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>
Cc: 26037 <at> debbugs.gnu.org
Subject: Re: bug#26037: 25.1;
 perl-mode add syntax support for subroutine signatures
Date: Sat, 11 Mar 2017 09:26:21 -0500
severity 26037 wishlist
quit

Evgeni Kolev <evgeni.d.kolev <at> gmail.com> writes:

> perl 5.20 (released May 2014) added experimental support for subroutine
> signatures. So this is valid perl code:
>
> sub test ($param) {
> ...
> }
>
> However, perl-mode's syntax rules treat everything between ( and ) as
> punctuation (syntax class "."). As a result (thing-at-point 'word)
> doesn't return $param when the point is on $param because $param is
> considered punctuation. The patch below tries to address this by
> using syntax class "@" inside the parens.
>
> diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
> index a516f07..2b9d9ad 100644
> --- a/lisp/progmodes/perl-mode.el
> +++ b/lisp/progmodes/perl-mode.el
> @@ -258,7 +258,7 @@
> ;; Funny things in `sub' arg-specs like `sub myfun ($)' or `sub ($)'.
> ;; Be careful not to match "sub { (...) ... }".
> ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([^)]+\\))"
> - (1 "."))
> + (1 "@"))

Don't we still want 'sub ($)' and such to be marked with punctuation
syntax?




Severity set to 'wishlist' from 'normal' Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sat, 11 Mar 2017 14:26:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Wed, 15 Mar 2017 02:08:02 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>, 26037 <at> debbugs.gnu.org
Subject: Re: bug#26037: 25.1;
 perl-mode add syntax support for subroutine signatures
Date: Tue, 14 Mar 2017 22:08:41 -0400
[Message part 1 (text/plain, inline)]
[Please keep 26037 <at> debbugs.gnu.org on CC]
[Message part 2 (message/rfc822, inline)]
From: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>
To: npostavs <at> users.sourceforge.net
Subject: Re: bug#26037: 25.1; perl-mode add syntax support for subroutine signatures
Date: Tue, 14 Mar 2017 14:14:58 +0200
[Message part 3 (text/plain, inline)]
Hi, thanks for your reply!

The '$' inside 'sub ($)' should be treated as punctuation (or symbol,
sorry, I'm not 100% sure, see below) due to the "@" syntax class - if
I'm not mistaken, "@" will let the syntax "fall-through" to the
standard syntax table; the standard syntax table, in turn, should
define '$' and other perl sigils as punctuation.

However, I'm not sure how to verify that the '$' in 'sub ($)' is
punctuation or symbol.

I'm using this document for reference to syntax classes:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Class-Table.html
[Message part 4 (text/plain, inline)]

I believe the standard syntax table is fundamental mode's syntax table,
not perl's.  Otherwise you might as well just delete the entry entirely.

You can check any character's current syntax by moving point to it, and
doing C-u C-x =.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Thu, 16 Mar 2017 00:49:01 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: 26037 <at> debbugs.gnu.org
Cc: evgenysw <at> gmail.com
Subject: Re: bug#26037: 25.1;
 perl-mode add syntax support for subroutine signatures
Date: Wed, 15 Mar 2017 20:49:21 -0400
[Message part 1 (text/plain, inline)]
[Please use Reply All to keep 26037 <at> debbugs.gnu.org on CC]

[Message part 2 (message/rfc822, inline)]
From: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>
To: npostavs <at> users.sourceforge.net
Subject: Re: bug#26037: 25.1; perl-mode add syntax support for subroutine signatures
Date: Wed, 15 Mar 2017 12:00:32 +0200
[Message part 3 (text/plain, inline)]
OK, I see.

After a bit of testing with C-u C-x =, I see that with my proposed
change the sigils in 'sub test ($)' will *not* have punctuation class
as they did before the chagne.

I see these options:

1. I can try to improve the proposed change to preserve backward
compatibility - I can try to add another rule which will strictly
match only the allowed prototype-sigils $%&*;@[\]

2. discard my proposed change as it might have undesired side effects -
at this point, I don't see anything in perl-mode which depends on
these prototype-sigils having punctioation class, however, I could be
missing something.

3. accept my proposed change as-is, but we must be sure nothing will
be broken as a result.  I'm sure syntax highlighting will not be
broken (I've tested with different themes, different perl sub
definitions).

Please let me know what you think.
[Message part 4 (text/plain, inline)]

I ran git blame against the relevant lines, and turned up Bug#18502.
Please check if your change breaks the indentation test case at
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=18502#5.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Sat, 18 Mar 2017 15:51:02 GMT) Full text and rfc822 format available.

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

From: Евгени Колев <evgenysw <at> gmail.com>
To: npostavs <at> users.sourceforge.net
Cc: 26037 <at> debbugs.gnu.org
Subject: Re: bug#26037: 25.1;
 perl-mode add syntax support for subroutine signatures
Date: Sat, 18 Mar 2017 16:24:18 +0200
[Message part 1 (text/plain, inline)]
Yes, my change does break the indentation test case.
So changing the class doesn't seem like a good option.

After giving some thought to this, I think we can instead
make the regex more strict so that it matches only the
allowed characters in perl's prototypes. The allowed chars
are: $%&*;@[\]

This is what I have in mind - diff is pasted below.
However, please note the change below doesn't handle
these 3 chars [ / ]  I'll add them if you think this is the correct
approach:

diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index a516f07..840aa4e 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -257,7 +257,7 @@
        (1 (prog1 "\"" (perl-syntax-propertize-special-constructs end))))
       ;; Funny things in `sub' arg-specs like `sub myfun ($)' or `sub ($)'.
       ;; Be careful not to match "sub { (...) ... }".
-      ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([^)]+\\))"
+
 ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([$%&*;@]+\\))"
        (1 "."))
       ;; Turn __DATA__ trailer into a comment.
       ("^\\(_\\)_\\(?:DATA\\|END\\)__[
\t]*\\(?:\\(\n\\)#.-\\*-.*perl.*-\\*-\\|\n.*\\)"

On Thu, Mar 16, 2017 at 2:49 AM, <npostavs <at> users.sourceforge.net> wrote:

> [Please use Reply All to keep 26037 <at> debbugs.gnu.org on CC]
>
>
>
> ---------- Forwarded message ----------
> From: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>
> To: npostavs <at> users.sourceforge.net
> Cc:
> Bcc:
> Date: Wed, 15 Mar 2017 12:00:32 +0200
> Subject: Re: bug#26037: 25.1; perl-mode add syntax support for subroutine
> signatures
> OK, I see.
>
> After a bit of testing with C-u C-x =, I see that with my proposed
> change the sigils in 'sub test ($)' will *not* have punctuation class
> as they did before the chagne.
>
> I see these options:
>
> 1. I can try to improve the proposed change to preserve backward
> compatibility - I can try to add another rule which will strictly
> match only the allowed prototype-sigils $%&*;@[\]
>
> 2. discard my proposed change as it might have undesired side effects -
> at this point, I don't see anything in perl-mode which depends on
> these prototype-sigils having punctioation class, however, I could be
> missing something.
>
> 3. accept my proposed change as-is, but we must be sure nothing will
> be broken as a result.  I'm sure syntax highlighting will not be
> broken (I've tested with different themes, different perl sub
> definitions).
>
> Please let me know what you think.
>
>
>
> I ran git blame against the relevant lines, and turned up Bug#18502.
> Please check if your change breaks the indentation test case at
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=18502#5.
>
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Sat, 18 Mar 2017 15:58:02 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: Евгени Колев <evgenysw <at> gmail.com>
Cc: 26037 <at> debbugs.gnu.org
Subject: Re: bug#26037: 25.1;
 perl-mode add syntax support for subroutine signatures
Date: Sat, 18 Mar 2017 11:58:46 -0400
Евгени Колев <evgenysw <at> gmail.com> writes:

>
> After giving some thought to this, I think we can instead
> make the regex more strict so that it matches only the
> allowed characters in perl's prototypes. The allowed chars
> are: $%&*;@[\]
>
> This is what I have in mind - diff is pasted below.
> However, please note the change below doesn't handle
> these 3 chars [ / ]  I'll add them if you think this is the correct
> approach:

Yeah, that looks right to me (although I don't know perl very well).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Sun, 26 Mar 2017 17:39:02 GMT) Full text and rfc822 format available.

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

From: Евгени Колев <evgenysw <at> gmail.com>
To: npostavs <at> users.sourceforge.net
Cc: 26037 <at> debbugs.gnu.org
Subject: Re: bug#26037: 25.1;
 perl-mode add syntax support for subroutine signatures
Date: Sun, 26 Mar 2017 20:29:55 +0300
[Message part 1 (text/plain, inline)]
The regex is now updated to include all the chars $%&*;@[\]

I got the list of chars from here
http://perldoc.perl.org/perlsub.html#Prototypes

This is the diff, please let me if it can be improved:

diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index a516f07..43eb462 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -257,7 +257,7 @@
        (1 (prog1 "\"" (perl-syntax-propertize-special-constructs end))))
       ;; Funny things in `sub' arg-specs like `sub myfun ($)' or `sub ($)'.
       ;; Be careful not to match "sub { (...) ... }".
-      ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([^)]+\\))"
+
 ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([][$%&*;@\\]+\\))"
        (1 "."))
       ;; Turn __DATA__ trailer into a comment.
       ("^\\(_\\)_\\(?:DATA\\|END\\)__[
\t]*\\(?:\\(\n\\)#.-\\*-.*perl.*-\\*-\\|\n.*\\)"

On Sat, Mar 18, 2017 at 5:58 PM, <npostavs <at> users.sourceforge.net> wrote:

> Евгени Колев <evgenysw <at> gmail.com> writes:
>
> >
> > After giving some thought to this, I think we can instead
> > make the regex more strict so that it matches only the
> > allowed characters in perl's prototypes. The allowed chars
> > are: $%&*;@[\]
> >
> > This is what I have in mind - diff is pasted below.
> > However, please note the change below doesn't handle
> > these 3 chars [ / ]  I'll add them if you think this is the correct
> > approach:
>
> Yeah, that looks right to me (although I don't know perl very well).
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Sun, 26 Mar 2017 18:04:02 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: Евгени Колев <evgenysw <at> gmail.com>
Cc: 26037 <at> debbugs.gnu.org
Subject: Re: bug#26037: 25.1;
 perl-mode add syntax support for subroutine signatures
Date: Sun, 26 Mar 2017 14:04:45 -0400
Евгени Колев <evgenysw <at> gmail.com> writes:

> The regex is now updated to include all the chars $%&*;@[\]
>
> I got the list of chars from here
> http://perldoc.perl.org/perlsub.html#Prototypes

It looks like "+" is another possible character:

    The + prototype is a special alternative to $ that will act like
    \[@%] when given a literal array or hash variable, but will
    otherwise force scalar context on the argument. This is useful for
    functions which should accept either a literal array or an array
    reference as the argument:

            sub mypush (+@) {

>
> This is the diff, please let me if it can be improved:
>

> ;; Funny things in `sub' arg-specs like `sub myfun ($)' or `sub ($)'.
> ;; Be careful not to match "sub { (...) ... }".
> - ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([^)]+\\))"
> + ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([][$%&*;@\\]+\\))"

Please update the comment too.

And if it's not too much trouble could you add a commit message as
described in CONTRIBUTE?  (And then post the output from 'git
format-patch' instead of 'git diff')




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Tue, 28 Mar 2017 03:34:02 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: 26037 <at> debbugs.gnu.org
Cc: Евгени Колев <evgenysw <at> gmail.com>
Subject: [Евгени Колев] Re: bug#26037:
 25.1; perl-mode add syntax support for subroutine signatures
Date: Mon, 27 Mar 2017 23:34:42 -0400
[Message part 1 (text/plain, inline)]
[Please use Reply All to keep 26037 <at> debbugs.gnu.org on Cc]

[Message part 2 (message/rfc822, inline)]
From: Евгени Колев <evgenysw <at> gmail.com>
To: npostavs <at> users.sourceforge.net
Subject: Re: bug#26037: 25.1; perl-mode add syntax support for subroutine signatures
Date: Mon, 27 Mar 2017 09:55:55 +0300
[Message part 3 (text/plain, inline)]
Sure! Here's output of format-patch, with `+' added to the regex and
updated comment, and again, please let me know if it can be improved:

From 250e022caf3889a1778820bac1ad072240fa93d4 Mon Sep 17 00:00:00 2001
From: Evgeni Kolev <evgenysw <at> gmail.com>
Date: Mon, 27 Mar 2017 09:30:10 +0300
Subject: [PATCH] Propertize only perl prototype chars `][$%&*;+@\' as
 punctuation

As a result, variables in signatures such as `sub add ($a, $b) are not
treated as punctuation.
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function):
Strictly match only prototype characters as punctuation. (Bug#26037)

Copyright-paperwork-exempt: yes
---
 lisp/progmodes/perl-mode.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index a516f07..1bcc743 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -255,9 +255,10 @@
       ;; format statements
       ("^[ \t]*format.*=[ \t]*\\(\n\\)"
        (1 (prog1 "\"" (perl-syntax-propertize-special-constructs end))))
-      ;; Funny things in `sub' arg-specs like `sub myfun ($)' or `sub ($)'.
-      ;; Be careful not to match "sub { (...) ... }".
-      ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([^)]+\\))"
+      ;; Propertize perl prototype chars `][$%&*;+@\' as punctioation
+      ;; in `sub' arg-specs like `sub myfun ($)' or `sub ($)'. Be
+      ;; careful not to match "sub { (...) ... }".
+
 ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([][$%&*;+@\\]+\\))"
        (1 "."))
       ;; Turn __DATA__ trailer into a comment.
       ("^\\(_\\)_\\(?:DATA\\|END\\)__[
\t]*\\(?:\\(\n\\)#.-\\*-.*perl.*-\\*-\\|\n.*\\)"
-- 
2.10.0


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Tue, 28 Mar 2017 03:41:01 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: 26037 <at> debbugs.gnu.org
Cc: Евгени Колев <evgenysw <at> gmail.com>
Subject: Re: bug#26037: [Евгени Колев] Re:
 bug#26037: 25.1; perl-mode add syntax support for subroutine signatures
Date: Mon, 27 Mar 2017 23:41:59 -0400
npostavs <at> users.sourceforge.net writes:

> +      ;; Propertize perl prototype chars `][$%&*;+@\' as punctioation
                                                                ^^^^
                                                                Typo.
                                                            
> +      ;; in `sub' arg-specs like `sub myfun ($)' or `sub ($)'. Be
> +      ;; careful not to match "sub { (...) ... }".

Perhaps you could mention that we're trying not match subroutine signatures?






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Wed, 29 Mar 2017 06:30:02 GMT) Full text and rfc822 format available.

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

From: Евгени Колев <evgenysw <at> gmail.com>
To: npostavs <at> users.sourceforge.net
Cc: 26037 <at> debbugs.gnu.org
Subject: Re: bug#26037: [Евгени Колев] Re: bug#26037: 25.1; perl-mode add syntax support for subroutine signatures
Date: Wed, 29 Mar 2017 09:28:40 +0300
[Message part 1 (text/plain, inline)]
Sure, here's the updated patch:


From de1c6f786b8366423cca7edce1ecfabe763567d0 Mon Sep 17 00:00:00 2001
From: Evgeni Kolev <evgenysw <at> gmail.com>
Date: Mon, 27 Mar 2017 09:30:10 +0300
Subject: [PATCH] Propertize only perl prototype chars `][$%&*;+@\' as
 punctuation

As a result, variables in signatures such as `sub add ($a, $b) are not
treated as punctuation.
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function):
Strictly match only prototype characters as punctuation. (Bug#26037)

Copyright-paperwork-exempt: yes
---
 lisp/progmodes/perl-mode.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index a516f07..45628e3 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -255,9 +255,11 @@
       ;; format statements
       ("^[ \t]*format.*=[ \t]*\\(\n\\)"
        (1 (prog1 "\"" (perl-syntax-propertize-special-constructs end))))
-      ;; Funny things in `sub' arg-specs like `sub myfun ($)' or `sub ($)'.
-      ;; Be careful not to match "sub { (...) ... }".
-      ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([^)]+\\))"
+      ;; Propertize perl prototype chars `$%&*;+@\[]' as punctuation
+      ;; in `sub' arg-specs like `sub myfun ($)' and `sub ($)'. But
+      ;; don't match subroutine signatures like `sub add ($a, $b)', or
+      ;; anonymous subs like "sub { (...) ... }".
+
 ("\\<sub\\(?:[\s\t\n]+\\(?:\\sw\\|\\s_\\)+\\)?[\s\t\n]*(\\([][$%&*;+@\\]+\\))"
        (1 "."))
       ;; Turn __DATA__ trailer into a comment.
       ("^\\(_\\)_\\(?:DATA\\|END\\)__[
\t]*\\(?:\\(\n\\)#.-\\*-.*perl.*-\\*-\\|\n.*\\)"
-- 
2.10.0
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Wed, 29 Mar 2017 23:46:02 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: Евгени Колев <evgenysw <at> gmail.com>
Cc: 26037 <at> debbugs.gnu.org
Subject: Re: bug#26037: 25.1;
 perl-mode add syntax support for subroutine signatures
Date: Wed, 29 Mar 2017 19:46:18 -0400
tags 26037 patch
quit

Евгени Колев <evgenysw <at> gmail.com> writes:

> Sure, here's the updated patch:

Thanks, looks good to me, I will push to master in a few days.




Added tag(s) patch. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Wed, 29 Mar 2017 23:46:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Sat, 01 Apr 2017 21:40:02 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: Евгени Колев <evgenysw <at> gmail.com>
Cc: 26037 <at> debbugs.gnu.org
Subject: Re: bug#26037: 25.1;
 perl-mode add syntax support for subroutine signatures
Date: Sat, 01 Apr 2017 17:40:40 -0400
tags 26037 fixed
close 26037 26.1
quit

npostavs <at> users.sourceforge.net writes:

>
> Евгени Колев <evgenysw <at> gmail.com> writes:
>
>> Sure, here's the updated patch:
>
> Thanks, looks good to me, I will push to master in a few days.

Pushed to master [1: a184a7edc5] (I fixed a missing double space between
sentences and a missing ' in the commit message).  Thanks for working on
this.

PS gmail line-wrapped your patch, it's better to send as attachment when
using gmail.

1: 2017-04-01 17:32:18 -0400 a184a7edc58e1e053aa317a0f162df7e225597e1
  Propertize only perl prototype chars `][$%&*;+@\' as punctuation





Added tag(s) fixed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sat, 01 Apr 2017 21:40:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 26037 <at> debbugs.gnu.org and Evgeni Kolev <evgeni.d.kolev <at> gmail.com> Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sat, 01 Apr 2017 21:40:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26037; Package emacs. (Mon, 03 Apr 2017 07:51:01 GMT) Full text and rfc822 format available.

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

From: Евгени Колев <evgenysw <at> gmail.com>
To: npostavs <at> users.sourceforge.net
Cc: 26037 <at> debbugs.gnu.org
Subject: Re: bug#26037: 25.1;
 perl-mode add syntax support for subroutine signatures
Date: Mon, 3 Apr 2017 10:49:28 +0300
[Message part 1 (text/plain, inline)]
Thanks, and thanks for working on improving emacs!

On Sun, Apr 2, 2017 at 12:40 AM, <npostavs <at> users.sourceforge.net> wrote:

> tags 26037 fixed
> close 26037 26.1
> quit
>
> npostavs <at> users.sourceforge.net writes:
>
> >
> > Евгени Колев <evgenysw <at> gmail.com> writes:
> >
> >> Sure, here's the updated patch:
> >
> > Thanks, looks good to me, I will push to master in a few days.
>
> Pushed to master [1: a184a7edc5] (I fixed a missing double space between
> sentences and a missing ' in the commit message).  Thanks for working on
> this.
>
> PS gmail line-wrapped your patch, it's better to send as attachment when
> using gmail.
>
> 1: 2017-04-01 17:32:18 -0400 a184a7edc58e1e053aa317a0f162df7e225597e1
>   Propertize only perl prototype chars `][$%&*;+@\' as punctuation
>
>
[Message part 2 (text/html, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 01 May 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 51 days ago.

Previous Next


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