unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: 22884@debbugs.gnu.org
Subject: bug#22884: 25.0.92; C/l mode editing takes waaaayy too long
Date: Tue, 8 Mar 2016 14:02:05 +0000	[thread overview]
Message-ID: <20160308140205.GA6269@acm.fritz.box> (raw)
In-Reply-To: <56D9F0C6.4090800@cs.ucla.edu>

Hello, Paul.

On Fri, Mar 04, 2016 at 12:32:06PM -0800, Paul Eggert wrote:
> Alan Mackenzie wrote:
> > I have had an idea for fixing Emacs so that we don't have this problem
> > with parens in column 0.  That is only to scan comments in the forward
> > direction, and to mark them with text properties.  `back_comment' will
> > then be little more than checking these text properties are up to date,
> > and then doing a backward text property search.

> Would this mean we no longer need to put \( into Elisp doc strings too? It has 
> always been annoying that we have to do that.

> If it's practical to fold your idea into the emacs-25 branch it sounds like 
> it'll solve the problem. If it's safer to put such a change into the master 
> branch, I can install the patch I already wrote into the emacs-25 branch, as a 
> stopgap. What do you think?

OK, I've hacked this out and committed it to the new branch
"comment-cache", branched off of master.

To use it, (setq comment-cacheing-flag t), and enjoy!  The old
`back_comment' is still in syntax.c, renamed to `old_back_comment', and
it is used when that flag is left at nil.

There should no longer be any restrictions about open parentheses in
column 0, neither in comments nor in strings.
open-paren-in-column-0-is-defun-start should now be a relic (although it
still appears in some lisp files).

At the moment, the code only uses the cached information (on the
`comment-depth' text property) for moving backwards over comments.  It
could be enhanced also to use this information for moving back over
strings, or moving forward over comments and strings, but this is more
of an optimisation than new functionality, and I'm not convinced the
saving would be all that much.  (At the end of any such move, the
variables `from' and `from_byte' are out of synch, and a CHAR_TO_BYTE
invocation is necessary.  I don't know how slow or fast this is.)

As I've said already, the new scheme comes with one or two minor
restrictions: any Lisp code which chnages the syntax table in a way
which affects how literals are handled needs also to call
`trim-comment-cache' to invalidate the cache.  The same applies to
anybody tweaking the `syntax-table' property of a symbol which is the
value of a `category' text property.  CC Mode does the latter
extensively, and I'll need to prepare a version which doesn't do this.

At the moment, the code hasn't yet been tested with nestable comments,
or `category' text properties.  Can you recommend me a major mode with
nestable comments?  I haven't really tested it for narrowing, either, or
anything like indirect buffers.  

I'm not convinced by the names I've chosen for all the new functions and
variables, and I think I ought to rename "comment-cache" to
"literal-cache", and likewise for all the rest.

Some amendment of the Elisp manual will be needed to document the new
minor restrictions.

I look forward to your comments!

-- 
Alan Mackenzie (Nuremberg, Germany).





  parent reply	other threads:[~2016-03-08 14:02 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 [this message]
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
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=20160308140205.GA6269@acm.fritz.box \
    --to=acm@muc.de \
    --cc=22884@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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).