Subject: bug#26037: 25.1; perl-mode add syntax support for subroutine signatures

From: Evgeni Kolev <[email-masked]>
Date: Thu, 9 Mar 2017 18:57:16 +0200

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))