emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] comment-cache 223d16f 2/3: Apply `comment-depth' text


From: Alan Mackenzie
Subject: Re: [Emacs-diffs] comment-cache 223d16f 2/3: Apply `comment-depth' text properties when calling `back_comment'.
Date: Sat, 12 Mar 2016 21:58:39 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

Hello, Dmitry.

On Sat, Mar 12, 2016 at 10:56:18PM +0200, Dmitry Gutov wrote:
> On 03/12/2016 07:08 PM, Alan Mackenzie wrote:

> > Now, if only we had a nice fast method of determining whether we were in
> > a literal, and then getting out of it .....  :-)

> Why not

> (save-restriction
>    (prog-widen)
>    (let* ((state (syntax-ppss))
>           (lit-start (nth 8 state)))
>      (when lit-start
>        (goto-char lit-start))))

> ?

In a large buffer, this involves scanning on average 10,000 characters
with parse-partial-sexp.  This is not what I meant by "fast".

What I had in mind looks more like (note the recent renaming of
`comment-depth' to `literal-cache'):

  (setq lc (get-text-property (point) 'literal-cache))
  (when (not (equal lc '(0 . 0)))
    (setq start (previous-single-property-change (point) 'literal-cache))
    (goto-char start)
    ;; Move back over opening delimiter(s).
    )

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]