From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: rudalics@gmx.at, rms@gnu.org, emacs-devel@gnu.org
Subject: Re: Honesty with parse-partial-sexp
Date: Tue, 12 Dec 2006 14:29:44 -0500 [thread overview]
Message-ID: <jwvhcw02a41.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20061212201200.GA1118@muc.de> (Alan Mackenzie's message of "12 Dec 2006 20\:01\:34 +0100\, Tue\, 12 Dec 2006 20\:12\:00 +0000")
> I don't think a special case should be made for point already being at
> top level: It's surely more consistent just to return (point) in this
> case. To return nil would make callers of the function have to take
> evasive action, such as:
> (let ((base-pos (or (syntax-ppss-toplevel-pos ppss)
> (point))))
> instead of the more natural
> (let ((base-pos (syntax-ppss-toplevel-pos ppss)))
But there can be other uses. E.g. testing "toplevel-p" becomes just
(null (syntax-ppss-toplevel-pos (syntax-ppss))) rather than having to check
equality with (point).
More to the point, all places in syntax.el where I'd want to use this new
function currently use
(or (car (nth 9 ppss))
(nth 8 ppss)
(nth 2 ppss))
So with your function I'd end up having to do:
(let ((pos (syntax-ppss-toplevel-pos ppss)))
(if (eq pos (point)) (nth 2 ppss) pos))
Nothin terrible, of course, but it seems that it's marginally easier to add
(or ... (point)) than to detect the special case where the value returned in
(point).
There's a tension between making this function just an accessor to the raw
data, and making it a solution to a particular problem.
I was actually expecting someone to complain that she wants the raw
(car (nth 9 ppss)) data for her particular application.
> (or (car (nth 9 ppss))
> (nth 8 ppss)
> (point)))
Of course, the other problem with this code is that there's no guarantee
that (point) is the position of the end of the scan (we may even have
switched to some other buffer in the mean time).
Stefan
next prev parent reply other threads:[~2006-12-12 19:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-07 17:47 Honesty with parse-partial-sexp Alan Mackenzie
2006-12-09 1:26 ` Richard Stallman
2006-12-09 4:04 ` Stefan Monnier
2006-12-09 18:25 ` Richard Stallman
2006-12-09 20:20 ` Stefan Monnier
2006-12-09 9:47 ` martin rudalics
2006-12-09 12:56 ` Miles Bader
2006-12-09 18:26 ` Richard Stallman
2006-12-09 20:30 ` Stefan Monnier
2006-12-11 1:05 ` Richard Stallman
2006-12-12 2:41 ` Stefan Monnier
2006-12-12 19:01 ` Alan Mackenzie
2006-12-12 19:29 ` Stefan Monnier [this message]
2006-12-12 19:53 ` Alan Mackenzie
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=jwvhcw02a41.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
--cc=rudalics@gmx.at \
/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.