all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
Cc: rudalics@gmx.at, rms@gnu.org, emacs-devel@gnu.org
Subject: Re: Honesty with parse-partial-sexp
Date: 12 Dec 2006 20:53:05 +0100	[thread overview]
Message-ID: <20061212210331.GB1118@muc.de> (raw)
In-Reply-To: <jwvhcw02a41.fsf-monnier+emacs@gnu.org>

Hi, Stephan,

That was quick!

On Tue, Dec 12, 2006 at 02:29:44PM -0500, Stefan Monnier wrote:
> > 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).

I would argue for a coherent definition rather than optimising it for
particular uses.  However, ....

[ snippety snip ]

> 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).

This is the bit that I missed - ppss doesn't record the stopping point at
all.  So I now agree with you.  How about this:

(defun syntax-ppss-toplevel-pos (ppss)
  "Get the latest syntactically outermost position found in a syntactic scan.

PPSS is a record of the scan; it is \(or looks like) the return
value of the function `partial-parse-sexp' \(or
`syntactic-ppss').  If no such position is recorded in PPSS
\(because the end of the scan was itself at the outermost level),
return NIL.

An \"outermost position\" means one that it is outside of any
syntactic entity: outside of any parentheses encountered in the
scan, or comments, or strings."
  (or (car (nth 9 ppss))
      (nth 8 ppss)))

?

>         Stefan

-- 
Alan.

      reply	other threads:[~2006-12-12 19:53 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
2006-12-12 19:53                 ` Alan Mackenzie [this message]

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=20061212210331.GB1118@muc.de \
    --to=acm@muc.de \
    --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.