unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: eggert@cs.ucla.edu, 22884@debbugs.gnu.org
Subject: bug#22884: 25.0.92; C/l mode editing takes waaaayy too long
Date: Fri, 4 Mar 2016 09:37:07 +0000	[thread overview]
Message-ID: <20160304093707.GA2117@acm.fritz.box> (raw)
In-Reply-To: <83fuw6zlqf.fsf@gnu.org>

Hello, Eli.

On Fri, Mar 04, 2016 at 10:32:56AM +0200, Eli Zaretskii wrote:
> > Date: Thu, 3 Mar 2016 23:18:23 +0000
> > Cc: eggert@cs.ucla.edu, 22884@debbugs.gnu.org
> > From: Alan Mackenzie <acm@muc.de>

> > Would it be practicable to mark comments with text properties?  Say, a
> > property called `comment-depth' which would be either nil (meaning
> > currently unknown), 0 (definitely not in a comment), 1 (definitely in a
> > comment), 2 (in a nested comment), 3, ...... ?  That way we could always
> > scan comments in the forwards direction (which is easy) - if we need to
> > go backwards over a comment without the property, we can just go back to
> > a known point and scan forward.

> I don't see any immediate problems with this.  But doesn't creating
> these properties require to solve the same problem with the specific
> cases we are discussing now?

No, it doesn't.  The difficulties with scanning comments only happen when
scanning backwards.  For example, on scanning backwards for a putative
line comment, we're only guessing that there's going to be a "//" earlier
in the line.  And that token might easily be inside a string, so we've
got to keep track of string delimiters, too.  Etc.
open-paren-in-column-0-is-defun-start is only tested twice in syntax.c,
the "most important" time being in `back-comment', where we break off the
scanning when it is non-nil and we've found an open paren at column zero.

By contrast, scanning comments going forward is trivial.  We see the
opening comment delimiter, and scan forward for the closing one, ignoring
strings, possibly nested openers (/*.../*..*/), and so on.

So a (forward-comment -1) would just involve going back over the closing
delimiter and searching back for the `comment-depth' property being zero.
If the property was unset at that point, we go back to the last place it
is set and scan comments forward till we get back to our starting place.

Additionally, we'd need to zap the property between point and EOB on each
buffer change.  Not difficult.

> > Or would this just overwhelm the text property mechanism?

> No, I don't think it should.  Text properties scale reasonably well.
> And we already have the same with faces (since comments have a
> specific face), don't we?

Then we have a project!

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2016-03-04  9:37 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02 18:08 bug#22884: 25.0.92; C/l mode editing takes waaaayy too long Paul Eggert
2016-03-03 12:49 ` Alan Mackenzie
2016-03-03 17:54   ` Paul Eggert
2016-03-03 19:23     ` Alan Mackenzie
2016-03-03 20:38       ` Eli Zaretskii
2016-03-03 21:57       ` Paul Eggert
2016-03-03 22:59         ` Alan Mackenzie
2016-03-03 20:51     ` Eli Zaretskii
2016-03-03 23:44       ` Paul Eggert
2016-03-04 14:47         ` Alan Mackenzie
2016-03-04 20:32           ` Paul Eggert
2016-03-04 21:08             ` Alan Mackenzie
2016-03-13 10:03               ` Alan Mackenzie
2016-03-08 14:02             ` Alan Mackenzie
2016-03-09  8:25               ` Paul Eggert
2016-03-09  9:28                 ` John Wiegley
2016-03-09  9:37                   ` Paul Eggert
2016-03-09 21:30                     ` John Wiegley
2016-03-09 10:56                   ` Alan Mackenzie
2016-03-09 14:44                     ` Drew Adams
2016-03-09 17:04                       ` Alan Mackenzie
2016-03-09 17:14                         ` Drew Adams
2016-03-03 20:40   ` Eli Zaretskii
2016-03-03 22:27     ` Alan Mackenzie
2016-03-03 23:18     ` Alan Mackenzie
2016-03-04  8:32       ` Eli Zaretskii
2016-03-04  9:37         ` Alan Mackenzie [this message]
2016-03-15  3:07 ` Stefan Monnier
2016-05-08 23:10   ` Dmitry Gutov
2016-05-13 19:35 ` Paul Eggert
2016-05-13 20:37   ` Glenn Morris
2016-05-13 21:09     ` Paul Eggert
2022-04-28 11:22   ` Lars Ingebrigtsen
2022-04-28 19:35     ` Paul Eggert

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=20160304093707.GA2117@acm.fritz.box \
    --to=acm@muc.de \
    --cc=22884@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=eliz@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 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).