all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Andreas Röhler" <andreas.roehler@online.de>
Cc: Richard Stallman <rms@gnu.org>, emacs-devel@gnu.org
Subject: Re: sh-script beg-end of function
Date: Thu, 22 Nov 2007 16:49:47 -0500	[thread overview]
Message-ID: <jwvejeic6rc.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <200711221956.15254.andreas.roehler@online.de> ("Andreas Röhler"'s message of "Thu, 22 Nov 2007 19:56:14 +0100")

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

  reply	other threads:[~2007-11-22 21:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-19 20:43 sh-script beg-end of function Andreas Röhler
2007-11-21 12:05 ` Richard Stallman
2007-11-21 15:52   ` Andreas Röhler
2007-11-22  8:22     ` Richard Stallman
2007-11-21 20:19   ` Stefan Monnier
2007-11-22  7:26     ` Andreas Röhler
2007-11-22 17:39       ` Stefan Monnier
2007-11-22 18:56         ` Andreas Röhler
2007-11-22 21:49           ` Stefan Monnier [this message]
2007-11-23 15:33             ` Andreas Röhler
2007-11-23 16:34               ` Stefan Monnier
2007-11-24 13:45                 ` Andreas Röhler
2007-11-23 15:56             ` Andreas Röhler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvejeic6rc.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=andreas.roehler@online.de \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.