GNU bug report logs - #19754
sh-script.el: mostly wrong defun-prompt-regexp

Previous Next

Package: emacs;

Reported by: Carlos Pita <carlosjosepita <at> gmail.com>

Date: Tue, 3 Feb 2015 02:07:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 26.1

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 19754 <at> debbugs.gnu.org
Subject: bug#19754: sh-script.el: mostly wrong defun-prompt-regexp
Date: Mon, 2 Feb 2015 23:05:31 -0300
Tags: patch

The defun regexp is defined for sh-sript mode as:

  (setq-local defun-prompt-regexp
     (concat "^\\(function[ \t]\\|[[:alnum:]]+[ \t]+()[ \t]+\\)"))


At least in bash you have several valid forms not allowed by that regexp:

1) spaces between (, ), and { are optional

2) function name {...} (indeed, function {} is not even valid!)

3) function name () {...}

4) function          name() {...}

Also the concat seems pointless to me.

Here is a patched version:

(setq-local defun-prompt-regexp
        (concat
         "^\\("
         "\\(function[ \t]\\)?[ \t]*[[:alnum:]]+[ \t]*([ \t]*)"
         "\\|"
         "function[ \t]+[[:alnum:]]+[ \t]*\\(([ \t]*)\\)?"
         "\\)[ \t]*"))




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

Previous Next


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