[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sh-script beg-end of function
From: |
Stefan Monnier |
Subject: |
Re: sh-script beg-end of function |
Date: |
Thu, 22 Nov 2007 16:49:47 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) |
> Your code adresses a function in it's literally sence,
> whereas my code adresses "top-level-form", a more
> abstract thing. A "top-level-form" form BTW already
> is adressed by Emacs-Lisp `end-of-defun' or
> `beginning-of-defun' and I already remarked the naming
> as somehow misleading therefore, but that's a matter
> from the past.
I understand, but the way I see it, either you're in an sh buffer which
has functions, in which case the defun-prompt-regexp will work fine, or
you're in an sh buffer which basically only contains "unstructured"
"straight-line" code. You want to cater to this latter case as well.
It might be OK, but in my experience which units are useful in this case
is hard to know in general because it depends a lot on the writing style
used (which is anything but standardized sadly). In many cases
paragraph-based navigation will work best.
I don't claim that my defun-prompt-regexp setting is the
end-all-be-all here. It's just a good starting point. But also any
replacement should be at least as good. Most importantly: jumping to
the end of a real function should jump to the closing "}".
If you want to submit an improvement, please send it as a patch against
the current sh-script.el code. This will make it easier for us to
integrate your code.
BTW, `end-of-defun-function' seems to be used in end-of-defun in
a ... weird way, so maybe you'll want to fix that first. Maybe I'll
post a suggestion about it on this list later.
Stefan
PS: Comments about your original code:
- the "defcustom beginning-of-defun-function" is wrong: you can only
use defcustom for variable you *create* (that are your own), not to set
variables defined in other packages.
- The docstring of sh-beginning-of-function is unusable. It could
instead explain what is considered as a "defun".
- Instead of (parse-partial-sexp (point-min) (point)), you can use
syntax-ppss.
- the docstring of `comment-beginning' says "Find the beginning of the
enclosing comment" so I'm wondering why you decided to use that in
a context where you have no idea whether or not you're inside
a comment. Why don't you just use (forward-comment (- (point-max)))
and skip the newcomment madness altogether?
- sh-script beg-end of function, Andreas Röhler, 2007/11/19
- Re: sh-script beg-end of function, Richard Stallman, 2007/11/21
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/21
- Re: sh-script beg-end of function, Stefan Monnier, 2007/11/21
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/22
- Re: sh-script beg-end of function, Stefan Monnier, 2007/11/22
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/22
- Re: sh-script beg-end of function,
Stefan Monnier <=
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/23
- Re: sh-script beg-end of function, Stefan Monnier, 2007/11/23
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/24
- Re: sh-script beg-end of function, Andreas Röhler, 2007/11/23