unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Paul Pogonyshev <pogonyshev@gmx.net>
Cc: emacs-devel@gnu.org
Subject: Re: generic buffer parsing cache data
Date: Sun, 01 Jul 2007 17:20:29 +0200	[thread overview]
Message-ID: <4687C63D.6020401@gmx.at> (raw)
In-Reply-To: <200707011641.58414.pogonyshev@gmx.net>

 > It is unclear whether changes in any text properties should lead to cache
 > invalidation.  Probably no, at least by default.

Maybe for changes in syntax-table text properties.

 > It also makes sense to define some `anchors'.  Those would be ways of
 > partitioning buffers into parts, where changes in one part don't cause
 > invalidation of cache data in other parts.  For instance, in Python mode
 > anchors would be set wherever a toplevel block is defined, since it stops
 > parsing on reaching a toplevel anyway.  However, this can be added later.
 > For instance, it is not clear when and how to remove anchors.  (I.e. in
 > Python mode if toplevel is indented to another level, it should stop
 > being an anchor.)

An open-paren-in-column-0 would be such an anchor in many modes.

 > It is required that major mode stores cache data at some logical position,
 > so it can later find them again.  Maybe it also makes sense to add
 >
 >     Function: find-cache-data key &optional pos
 >
 > 	Find and return cache data at POS (or point position) or _before
 > 	it_.  Return nil if there is no (valid) cached data at pos or
 > 	anywhere before with that KEY.

The classic method based on the entire information to get out of a
nested block.

 > However, I don't see any obvious ways of using it.  As I can see, modes
 > should access cache data like this (in pseudocode):
 >
 > 	mode-get-cache-data:
 > 	    data = (get-cache-data mode-key)
 > 	    if data is nil:
 > 		data = (mode-compute-cache-data)
 > 		(put-cache-data mode-key data)
 > 	    return data
 >
 > 	mode-compute-cache-data:
 > 	    save-excursion:
 > 		travel-to-higher-level-cache-point
 > 		higher-level-data = (mode-get-cache-data)
 > 	    data = (mode-compute-data-from-higher-level higher-level-data)
 > 	    return data
 >
 > Here `higher-level' is not the same as `previous'.  For instance, in
 > Python mode it makes sense to compute indentation from the block this one
 > is nested in, not just previous block:
 >
 >     class X:
 > 	class Y: # <-- higher-level block for the current block
 > 	    class Z:
 > 		def bla (): # <-- previos block (with cached data)
 > 		   pass
 > 	    def __init__(self): # <-- current block
 > 		pass

I don't see why it should be difficult to keep the entire necessary
information at "bla".  After all you'd avoid to compute your data from
"class Y".  Moreover in other contexts it's not clear whether a thing
like "class Y" does constitute a "higher-level" block than the current
one.

Anyway, I understand that you want some routines for cache management
where the major (or minor) mode would fill in the necessary information
itself.  I don't see any problems adding such functionality to
`syntax-ppss' as Stefan suggested.

  reply	other threads:[~2007-07-01 15:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-30 21:38 generic buffer parsing cache data Paul Pogonyshev
2007-07-01 11:48 ` martin rudalics
2007-07-01 12:16   ` Paul Pogonyshev
2007-07-01 12:38     ` martin rudalics
2007-07-01 13:41       ` Paul Pogonyshev
2007-07-01 15:20         ` martin rudalics [this message]
2007-07-01 20:40         ` Richard Stallman
2007-07-01 12:45     ` Thien-Thi Nguyen
2007-07-01 13:10       ` Paul Pogonyshev
2007-07-01 13:16         ` Lennart Borgman (gmail)
2007-07-01 13:43           ` Paul Pogonyshev
2007-07-01 13:28       ` joakim
2007-07-01 12:52     ` Stefan Monnier
2007-07-01 13:49       ` Paul Pogonyshev
2007-07-01 20:08         ` Stefan Monnier
2007-07-01 20:44           ` Paul Pogonyshev
2007-07-01 21:23             ` Stefan Monnier
2007-07-01 16:32     ` Richard Stallman
2007-07-01 16:32     ` Richard Stallman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=4687C63D.6020401@gmx.at \
    --to=rudalics@gmx.at \
    --cc=emacs-devel@gnu.org \
    --cc=pogonyshev@gmx.net \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).