* bug#19754: sh-script.el: mostly wrong defun-prompt-regexp
@ 2015-02-03 2:05 Carlos Pita
2016-02-23 11:15 ` Lars Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: Carlos Pita @ 2015-02-03 2:05 UTC (permalink / raw)
To: 19754
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]*"))
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#19754: sh-script.el: mostly wrong defun-prompt-regexp
2015-02-03 2:05 bug#19754: sh-script.el: mostly wrong defun-prompt-regexp Carlos Pita
@ 2016-02-23 11:15 ` Lars Ingebrigtsen
0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-23 11:15 UTC (permalink / raw)
To: Carlos Pita; +Cc: 19754
Carlos Pita <carlosjosepita@gmail.com> writes:
> 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]*"))
I've tried a few function definition forms in bash scripts, and your
regexp seems to give much better `C-M-a' action, so I've applied it to
the Emacs trunk.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-23 11:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-03 2:05 bug#19754: sh-script.el: mostly wrong defun-prompt-regexp Carlos Pita
2016-02-23 11:15 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.