unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: Bug #25608 and the comment-cache branch
Date: Wed, 22 Feb 2017 04:25:53 +0200	[thread overview]
Message-ID: <195629e9-11d6-2fb6-4c9d-39c8a244e2ec@yandex.ru> (raw)
In-Reply-To: <jwv4lzwn46i.fsf-monnier+emacs@gnu.org>

On 14.02.2017 18:38, Stefan Monnier wrote:

> Like all the sexp movement functions, `forward-comment` is allowed to
> assume that the starting position is outside of comments/strings, so it
> doesn't need to consult the cache to see if it's within a string.

I see, thanks. And I think that means that, ideally, it would work 
without the caller having to adjust the syntax visibility bounds, or the 
like, as long as the syntax table is correct and the beginning (or the 
end) of the currently navigated comment is within view.

> In the case we do scan forward (e.g. the case where we end up using
> parse-partial-sexp (or syntax-ppss in my patch)), we actually manually
> re-introduce that behavior: if the forward parse says that the
> end-comment-marker in inside a string (or inside another comment), we
> re-parse from the beginning of that string (or comment) to try and see
> if that end-comment-marker could be considered to close a comment nested
> within the string (or the other comment).

That indeed sounds complex.

> Calling syntax-ppss every time back_comment is invoked would probably
> result in bad performance currently: when parsing backward
> (e.g. backward-sexp), the syntax-ppss-last optimization is ineffective,
> so we'd fallback on syntax-ppss-cache which ends up scanning on the
> average syntax-ppss-max-span/2 (i.e. 10K) chars.  When \n is a comment
> ender (i.e. in most programming language modes), it would imply
> a forward scan of 10K for every line.

You're probably right, but I wonder what the benchmarks would say.

(parse-partial-sexp 1 10000) takes 0.0005 seconds here, so it'd still 
require some intensive usage to show up on user's radar.

Previously, we started from the beginning of the current defun, as 
delineated by an open paren in the first column, right?

I've seen function definitions longer than 10000 chars.

> IOW, for such an approach to work, we'd have to rework syntax-ppss to be
> faster when scanning backward (e.g. reduce syntax-ppss-max-span, which
> would have other repercussions).

Perhaps we could use the "generic comment bounds" syntax-table property 
to delineate such difficult comments. If that idea sounds similar to 
comment-cache, that is no accident.

But we should try to limit the incompatibility with mixed modes by only 
caching the beginnings of comments which contain strings, nested 
comments, etc. Better suggestion welcome (use a tree data structure 
instead of in-buffer text-properties?).

I've only recently come to the realization that our usage of the 
syntax-table text property has the same general incompatibility with 
mixed mode buffers as comment-cache does. The only reasons why it 
doesn't show as much is because we use them relatively rarely. But we 
couldn't, for instance, apply a "generic string" syntax to some literal 
in a subregion that is inside a "generic string" belonging to the 
primary major mode. Not sure what to do about that.



  reply	other threads:[~2017-02-22  2:25 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 20:24 Bug #25608 and the comment-cache branch Alan Mackenzie
2017-02-02 20:47 ` Eli Zaretskii
2017-02-02 21:51   ` Alan Mackenzie
2017-02-02 22:15     ` Dmitry Gutov
2017-02-03  7:41     ` Eli Zaretskii
2017-02-03 17:29       ` Alan Mackenzie
2017-02-03 22:08         ` Dmitry Gutov
2017-02-04 10:24           ` Alan Mackenzie
2017-02-06  2:09             ` Dmitry Gutov
2017-02-06 19:24               ` Alan Mackenzie
2017-02-07  1:42                 ` Dmitry Gutov
2017-02-07 19:21                   ` Alan Mackenzie
2017-02-14 15:28                     ` Dmitry Gutov
2017-02-14 16:38                       ` Stefan Monnier
2017-02-22  2:25                         ` Dmitry Gutov [this message]
2017-02-22  3:53                           ` Stefan Monnier
2017-02-23 14:23                             ` Dmitry Gutov
2017-02-23 14:48                               ` Stefan Monnier
2017-02-24  7:46                                 ` Tom Tromey
2017-02-14 21:14                       ` Alan Mackenzie
2017-02-16 14:10                         ` Stefan Monnier
2017-02-18 10:44                           ` Alan Mackenzie
2017-02-18 13:49                             ` Stefan Monnier
2017-02-12  2:53               ` John Wiegley
2017-02-12  8:20                 ` Elias Mårtenson
2017-02-12 10:47                 ` Alan Mackenzie
2017-02-12 11:14                 ` martin rudalics
2017-02-12 15:05                   ` Andreas Röhler
2017-02-12 15:39                   ` Eli Zaretskii
2017-02-05 22:00       ` Alan Mackenzie
2017-02-06  1:12         ` Stefan Monnier
2017-02-06 18:37           ` Alan Mackenzie
2017-02-08 17:20         ` Eli Zaretskii
2017-02-11 23:25           ` Alan Mackenzie
2017-02-12  0:55             ` Stefan Monnier
2017-02-12 12:05               ` Alan Mackenzie
2017-02-12 13:13                 ` Juanma Barranquero
2017-02-12 15:57                 ` Dmitry Gutov
2017-02-12 17:29                   ` Alan Mackenzie
2017-02-12 20:35                     ` Dmitry Gutov
2017-02-13  1:47                     ` zhanghj
2017-02-13  5:50                       ` Stefan Monnier
2017-02-13  6:45                         ` zhanghj
2017-02-13  7:24                           ` Stefan Monnier
2017-02-13  7:59                             ` zhanghj
2017-02-13  9:25                               ` Stefan Monnier
2017-02-13 16:14                           ` Drew Adams
2017-02-13  7:05                         ` zhanghj
2017-02-13  7:16                         ` zhanghj
2017-02-13 14:57                           ` Dmitry Gutov
2017-02-12 17:49                 ` Stefan Monnier
2017-02-13 18:09                   ` Alan Mackenzie
2017-02-13 19:34                     ` Eli Zaretskii
2017-02-13 21:21                     ` Stefan Monnier
2017-02-02 22:14 ` Dmitry Gutov
2017-02-03 16:44   ` Alan Mackenzie
2017-02-03 21:53     ` Dmitry Gutov
2017-02-04 11:02       ` Alan Mackenzie
2017-02-06  1:28         ` Dmitry Gutov
2017-02-06 19:37           ` Alan Mackenzie
2017-02-06  2:08         ` Stefan Monnier
2017-02-06 20:01           ` Alan Mackenzie
2017-02-06 22:33             ` Stefan Monnier
2017-02-07 21:24               ` Alan Mackenzie
2017-02-08 12:54                 ` Stefan Monnier
2017-02-07 15:29             ` Eli Zaretskii
2017-02-07 21:09               ` Alan Mackenzie
2017-02-08 17:28                 ` Eli Zaretskii
2017-02-02 23:57 ` Stefan Monnier
2017-02-03 16:19   ` Alan Mackenzie
2017-02-04  9:06     ` Andreas Röhler
2017-02-04 18:18     ` Stefan Monnier
2017-02-04 18:28       ` Alan Mackenzie
2017-02-03  7:49 ` Yuri Khan
2017-02-03 18:30   ` Andreas Röhler

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=195629e9-11d6-2fb6-4c9d-39c8a244e2ec@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).