[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Defining functions on the fly
From: |
Tassilo Horn |
Subject: |
Re: Defining functions on the fly |
Date: |
Tue, 16 Jun 2015 13:12:52 +0200 |
User-agent: |
Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) |
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>> There is: `forward-sexp' and `backward-sexp'. Although the name sexp
>> is a bit lisp-specific, sexp-based motion has been implemented for
>> more C-like languages, too. For example, it works well for shell
>> scripts
>
> Unfortunatly couldn't experience this. There are several common cases
> within shell-script, where calls to navigate sexp would raise an
> error.
>
> That's why language-modes have to implement a couple of most basic things. See
>
> http://lists.gnu.org/archive/html/emacs-devel/2015-06/msg00013.html
I agree with Stefan and Arthur on this particular issue.
> ###
>
> vorhanden() {
> for i in "blah" "blub";
> do
> # some comment (note: for compatibility)
> if [ ! -x $i ]; then
>
> ###
>
> with cursor last line "if", C-M-b jumps to "for", but should end at
> "do"
No. `do ... done' is no valid expression, i.e., it cannot stand on its
own but is only valid together with for, while, until, or repeat.
> From "for" ->
>
> Debugger entered--Lisp error: (scan-error "Containing expression ends
> prematurely" 13 13)
> signal(scan-error ("Containing expression ends prematurely" 13 13))
> smie-forward-sexp-command(-1)
> forward-sexp(-1)
> backward-sexp(1)
> call-interactively(backward-sexp nil nil)
> command-execute(backward-sexp)
Indeed, here I'd expect it to move to the beginning of the function
definition.
> Or take this:
>
> ###
>
> if [ $# == 0 ]; then
> # some comment (note: for compatibility)
> set "" `find . -maxdepth 1 -type f -name "*.txt" | sed 's/..\(.*\)/\1/'`
>
> for i in $*; do
> # some comment (note: for compatibility)
> pass
> done
>
> fi
>
> ###
>
> With cursor at third line, "set", expression is not recognised at all,
> C-M-f stops at the end of symbol "set"
Well, "command arg arg arg" in shell scripts is equivalent to (command
arg arg arg) in lisp with the distinction that with the lisp syntax's
parentheses you have a choice to move over the complete expression (when
point is on the opening paren) or inside it (when point is on the
"command"). Because the shell syntax doesn't have delimiters for the
funcall or at least the argument list, there's not much you can do.
> That's a fakir's mode :)
Well, you can extend it quite easily and declaratively by modifying
`sh-smie-sh-grammar', and then your improvements are transparently
available to anything which uses sexp-based motion. I don't see how you
can get the same benefits with tons and tons of special-case functions.
Bye,
Tassilo
- Re: Defining functions on the fly, (continued)
Re: Defining functions on the fly, Tassilo Horn, 2015/06/15
Message not available
- Re: Defining functions on the fly, Stefan Monnier, 2015/06/15
- Re: Defining functions on the fly, Andreas Röhler, 2015/06/16
- Re: Defining functions on the fly, Tassilo Horn, 2015/06/16
- Re: Defining functions on the fly, Andreas Röhler, 2015/06/16
- Re: Defining functions on the fly,
Tassilo Horn <=
- Re: Defining functions on the fly, Andreas Röhler, 2015/06/16
- Re: Defining functions on the fly, Tassilo Horn, 2015/06/16
- Re: Defining functions on the fly, Andreas Röhler, 2015/06/16
- Message not available
- Re: Defining functions on the fly, Stefan Monnier, 2015/06/16
Message not availableRe: Defining functions on the fly, Pascal J. Bourguignon, 2015/06/16
Re: Defining functions on the fly, Andreas Röhler, 2015/06/16
Re: Defining functions on the fly, Andreas Röhler, 2015/06/16
Message not availableRe: Defining functions on the fly, Pascal J. Bourguignon, 2015/06/16
Re: Defining functions on the fly, Andreas Röhler, 2015/06/16
Message not availableRe: Defining functions on the fly, Pascal J. Bourguignon, 2015/06/16