From: Chong Yidong <cyd@stupidchicken.com>
Cc: Alan Mackenzie <acm@muc.de>,
emacs-devel@gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>,
Richard Stallman <rms@gnu.org>
Subject: Re: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw.
Date: Sat, 16 Dec 2006 16:26:21 -0500 [thread overview]
Message-ID: <8764cbzg5e.fsf@stupidchicken.com> (raw)
In-Reply-To: <87d56jzjn3.fsf@stupidchicken.com> (Chong Yidong's message of "Sat\, 16 Dec 2006 15\:10\:56 -0500")
Chong Yidong <cyd@stupidchicken.com> writes:
>> Anyway, I'm afraid there's nothing we can do here at the moment. I'm
>> convinced that this bug is responsible for C mode being slow over the
>> past year. Eventually, Stefan will have to move syntax-ppss in here.
>> So far let's avoid setting `open-paren-in-column-0-is-defun-start' to
>> nil for _any_ mode. Unless you have an idea ...
>
> It might be possible to construct a "last known defun start position"
> cache variable living in scan_list, so that back_comment can use that
> instead of BOB. But I don't know how desirable or general such a fix
> is.
This idea seems to work fairly well. The patch to syntax.c is
attached; it adds an optional DEFUN_START argument to scan_lists which
is a position known to be outside any code structure. The code in
beginning-of-defun-raw can be altered to use this as follows:
(let* ((ppss (let (syntax-begin-function
font-lock-beginning-of-syntax-function)
(syntax-ppss)))
(defun-start (nth 2 ppss))
...)
...
(goto-char (scan-lists (point) (- arg) 0 defun-start))
With this additional change, (progn (goto-char (point-max)) (redisplay))
on xdisp.c takes 0.139s, down from 2.15s.
However M-> is still slow, because, for some reason, (recenter -3) at
the end of the buffer now takes about 2 seconds. I don't know why.
However, I think all this should be post-22 work; for Emacs 22, let's
just set open-paren-in-column-0-is-defun-start to t, and leave the
existing beginning-of-defun-raw code there should anyone want to set
it to nil.
*** emacs/src/syntax.c.~1.203.~ 2006-12-11 11:37:43.000000000 -0500
--- emacs/src/syntax.c 2006-12-16 15:56:24.000000000 -0500
***************
*** 98,107 ****
static int find_defun_start P_ ((int, int));
static int back_comment P_ ((EMACS_INT, EMACS_INT, EMACS_INT, int, int,
! EMACS_INT *, EMACS_INT *));
static int char_quoted P_ ((int, int));
static Lisp_Object skip_chars P_ ((int, int, Lisp_Object, Lisp_Object, int));
! static Lisp_Object scan_lists P_ ((EMACS_INT, EMACS_INT, EMACS_INT, int));
static void scan_sexps_forward P_ ((struct lisp_parse_state *,
int, int, int, int,
int, Lisp_Object, int));
--- 98,107 ----
static int find_defun_start P_ ((int, int));
static int back_comment P_ ((EMACS_INT, EMACS_INT, EMACS_INT, int, int,
! EMACS_INT *, EMACS_INT *, int));
static int char_quoted P_ ((int, int));
static Lisp_Object skip_chars P_ ((int, int, Lisp_Object, Lisp_Object, int));
! static Lisp_Object scan_lists P_ ((EMACS_INT, EMACS_INT, EMACS_INT, int, int));
static void scan_sexps_forward P_ ((struct lisp_parse_state *,
int, int, int, int,
int, Lisp_Object, int));
***************
*** 471,480 ****
the returned value (or at FROM, if the search was not successful). */
static int
! back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_ptr)
EMACS_INT from, from_byte, stop;
int comnested, comstyle;
EMACS_INT *charpos_ptr, *bytepos_ptr;
{
/* Look back, counting the parity of string-quotes,
and recording the comment-starters seen.
--- 471,482 ----
the returned value (or at FROM, if the search was not successful). */
static int
! back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_ptr,
! defun_start)
EMACS_INT from, from_byte, stop;
int comnested, comstyle;
EMACS_INT *charpos_ptr, *bytepos_ptr;
+ int defun_start;
{
/* Look back, counting the parity of string-quotes,
and recording the comment-starters seen.
***************
*** 497,506 ****
int comment_end_byte = from_byte;
int comstart_pos = 0;
int comstart_byte;
! /* Place where the containing defun starts,
! or 0 if we didn't come across it yet. */
! int defun_start = 0;
! int defun_start_byte = 0;
register enum syntaxcode code;
int nesting = 1; /* current comment nesting */
int c;
--- 499,505 ----
int comment_end_byte = from_byte;
int comstart_pos = 0;
int comstart_byte;
! int defun_start_byte = defun_start ? CHAR_TO_BYTE (defun_start) : 0;
register enum syntaxcode code;
int nesting = 1; /* current comment nesting */
int c;
***************
*** 2153,2159 ****
else if (code == Sendcomment)
{
found = back_comment (from, from_byte, stop, comnested, comstyle,
! &out_charpos, &out_bytepos);
if (found == -1)
{
if (c == '\n')
--- 2152,2158 ----
else if (code == Sendcomment)
{
found = back_comment (from, from_byte, stop, comnested, comstyle,
! &out_charpos, &out_bytepos, 0);
if (found == -1)
{
if (c == '\n')
***************
*** 2204,2213 ****
? SYNTAX (c) : Ssymbol)
static Lisp_Object
! scan_lists (from, count, depth, sexpflag)
register EMACS_INT from;
EMACS_INT count, depth;
! int sexpflag;
{
Lisp_Object val;
register EMACS_INT stop = count > 0 ? ZV : BEGV;
--- 2203,2212 ----
? SYNTAX (c) : Ssymbol)
static Lisp_Object
! scan_lists (from, count, depth, sexpflag, defun_start)
register EMACS_INT from;
EMACS_INT count, depth;
! int sexpflag, defun_start;
{
Lisp_Object val;
register EMACS_INT stop = count > 0 ? ZV : BEGV;
***************
*** 2512,2518 ****
if (!parse_sexp_ignore_comments)
break;
found = back_comment (from, from_byte, stop, comnested, comstyle,
! &out_charpos, &out_bytepos);
/* FIXME: if found == -1, then it really wasn't a comment-end.
For single-char Sendcomment, we can't do much about it apart
from skipping the char.
--- 2511,2517 ----
if (!parse_sexp_ignore_comments)
break;
found = back_comment (from, from_byte, stop, comnested, comstyle,
! &out_charpos, &out_bytepos, defun_start);
/* FIXME: if found == -1, then it really wasn't a comment-end.
For single-char Sendcomment, we can't do much about it apart
from skipping the char.
***************
*** 2579,2585 ****
make_number (last_good), make_number (from));
}
! DEFUN ("scan-lists", Fscan_lists, Sscan_lists, 3, 3, 0,
doc: /* Scan from character number FROM by COUNT lists.
Returns the character number of the position thus found.
--- 2578,2584 ----
make_number (last_good), make_number (from));
}
! DEFUN ("scan-lists", Fscan_lists, Sscan_lists, 3, 4, 0,
doc: /* Scan from character number FROM by COUNT lists.
Returns the character number of the position thus found.
***************
*** 2593,2606 ****
If the beginning or end of (the accessible part of) the buffer is reached
and the depth is wrong, an error is signaled.
If the depth is right but the count is not used up, nil is returned. */)
! (from, count, depth)
! Lisp_Object from, count, depth;
{
CHECK_NUMBER (from);
CHECK_NUMBER (count);
CHECK_NUMBER (depth);
! return scan_lists (XINT (from), XINT (count), XINT (depth), 0);
}
DEFUN ("scan-sexps", Fscan_sexps, Sscan_sexps, 2, 2, 0,
--- 2592,2611 ----
If the beginning or end of (the accessible part of) the buffer is reached
and the depth is wrong, an error is signaled.
If the depth is right but the count is not used up, nil is returned. */)
! (from, count, depth, defun_start)
! Lisp_Object from, count, depth, defun_start;
{
CHECK_NUMBER (from);
CHECK_NUMBER (count);
CHECK_NUMBER (depth);
! if (NILP (defun_start))
! defun_start = make_number (0);
! else
! CHECK_NUMBER (defun_start);
!
! return scan_lists (XINT (from), XINT (count), XINT (depth), 0,
! XINT (defun_start));
}
DEFUN ("scan-sexps", Fscan_sexps, Sscan_sexps, 2, 2, 0,
***************
*** 2620,2626 ****
CHECK_NUMBER (from);
CHECK_NUMBER (count);
! return scan_lists (XINT (from), XINT (count), 0, 1);
}
DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars,
--- 2625,2631 ----
CHECK_NUMBER (from);
CHECK_NUMBER (count);
! return scan_lists (XINT (from), XINT (count), 0, 1, 0);
}
DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars,
next prev parent reply other threads:[~2006-12-16 21:26 UTC|newest]
Thread overview: 120+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87y7po2e9b.fsf@leeloo.anubex.internal>
[not found] ` <45741FBE.3000107@swipnet.se>
[not found] ` <45742464.1090504@gmx.at>
2006-12-04 21:17 ` Mysterious fontification/C++ context issue Alan Mackenzie
2006-12-06 0:47 ` Richard Stallman
2006-12-06 9:04 ` martin rudalics
2006-12-06 12:22 ` Kim F. Storm
2006-12-06 16:31 ` Chong Yidong
2006-12-07 4:59 ` Richard Stallman
2006-12-09 17:46 ` Chong Yidong
2006-12-09 20:09 ` Stefan Monnier
2006-12-11 1:05 ` Richard Stallman
2006-12-11 2:27 ` Stefan Monnier
2006-12-11 4:38 ` Stefan Monnier
2006-12-12 16:24 ` Chong Yidong
2006-12-12 17:10 ` Stefan Monnier
2006-12-10 4:24 ` Richard Stallman
2006-12-10 0:35 ` Alan Mackenzie
2006-12-10 1:11 ` Chong Yidong
2006-12-10 9:12 ` Alan Mackenzie
2006-12-10 12:46 ` David Kastrup
2006-12-10 14:50 ` Alan Mackenzie
2006-12-10 15:13 ` David Kastrup
2006-12-10 20:30 ` Chong Yidong
2006-12-13 21:29 ` Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw Alan Mackenzie
2006-12-14 1:02 ` Chong Yidong
2006-12-14 7:36 ` Alan Mackenzie
2006-12-14 10:47 ` martin rudalics
2006-12-14 18:26 ` Alan Mackenzie
2006-12-14 18:53 ` David Kastrup
2006-12-14 20:21 ` Chong Yidong
2006-12-14 20:35 ` Chong Yidong
2006-12-14 22:18 ` Alan Mackenzie
2006-12-14 22:51 ` Chong Yidong
2006-12-15 0:53 ` David Kastrup
2006-12-15 10:35 ` Johan Bockgård
2006-12-14 21:53 ` What `opic0ids' really is [was: Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw.] Stuart D. Herring
2006-12-15 7:32 ` Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw martin rudalics
2006-12-15 19:22 ` Alan Mackenzie
2006-12-15 22:20 ` David Kastrup
2006-12-16 10:17 ` martin rudalics
2006-12-17 11:44 ` Alan Mackenzie
2006-12-17 12:02 ` David Kastrup
2006-12-17 12:08 ` Alan Mackenzie
2006-12-17 12:14 ` David Kastrup
2006-12-17 12:26 ` Alan Mackenzie
2006-12-17 12:51 ` David Kastrup
2006-12-17 17:28 ` martin rudalics
2006-12-17 18:36 ` Mysterious fontification/C++ context issue - Patch for c-basic-common-init Alan Mackenzie
2006-12-17 18:45 ` Chong Yidong
2006-12-17 22:18 ` Alan Mackenzie
2006-12-17 22:59 ` Chong Yidong
2006-12-18 0:06 ` Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw Stefan Monnier
2006-12-15 23:24 ` Stefan Monnier
2006-12-16 10:17 ` martin rudalics
2006-12-16 18:14 ` Chong Yidong
2006-12-16 18:27 ` martin rudalics
2006-12-16 19:00 ` martin rudalics
2006-12-16 19:33 ` Chong Yidong
2006-12-16 19:59 ` martin rudalics
2006-12-16 20:10 ` Chong Yidong
2006-12-16 21:26 ` Chong Yidong [this message]
2006-12-16 22:43 ` martin rudalics
2006-12-16 23:30 ` Stefan Monnier
2006-12-16 23:40 ` martin rudalics
2006-12-17 0:04 ` Stefan Monnier
2006-12-17 4:02 ` Chong Yidong
2006-12-17 10:32 ` martin rudalics
2006-12-17 10:26 ` martin rudalics
2006-12-17 10:59 ` David Kastrup
2006-12-17 23:23 ` Stefan Monnier
2006-12-17 11:10 ` Alan Mackenzie
2006-12-17 12:01 ` David Kastrup
2006-12-18 0:04 ` Stefan Monnier
2006-12-16 22:11 ` martin rudalics
2006-12-16 23:29 ` Stefan Monnier
2006-12-16 23:37 ` martin rudalics
2006-12-16 20:22 ` David Kastrup
2006-12-16 22:21 ` martin rudalics
2006-12-14 17:29 ` Chong Yidong
2006-12-14 18:56 ` David Kastrup
2006-12-14 22:57 ` Alan Mackenzie
2006-12-15 22:56 ` Stefan Monnier
2006-12-15 23:03 ` David Kastrup
2006-12-14 10:45 ` martin rudalics
2006-12-14 18:29 ` Alan Mackenzie
2006-12-15 22:49 ` Stefan Monnier
2006-12-10 21:39 ` Mysterious fontification/C++ context issue Stefan Monnier
2006-12-10 23:14 ` Kim F. Storm
2006-12-14 7:43 ` Alan Mackenzie
2006-12-14 7:51 ` Miles Bader
2006-12-15 23:36 ` Stefan Monnier
2006-12-10 9:18 ` martin rudalics
2006-12-11 1:23 ` Stefan Monnier
2006-12-11 7:23 ` martin rudalics
2006-12-11 7:36 ` Stefan Monnier
2006-12-11 8:32 ` martin rudalics
2006-12-11 16:30 ` Stefan Monnier
2006-12-11 1:05 ` Stefan Monnier
2006-12-11 1:06 ` Richard Stallman
2006-12-06 18:44 ` Richard Stallman
2006-12-06 22:38 ` martin rudalics
2006-12-08 5:05 ` Richard Stallman
2006-12-09 9:42 ` martin rudalics
2006-12-10 4:24 ` Richard Stallman
2006-12-10 8:38 ` martin rudalics
2006-12-10 10:56 ` Alan Mackenzie
2006-12-10 11:58 ` martin rudalics
2006-12-10 14:30 ` Slawomir Nowaczyk
2006-12-11 1:29 ` Stefan Monnier
2006-12-06 20:52 ` Alan Mackenzie
2006-12-06 22:38 ` martin rudalics
2006-12-07 5:07 ` Stefan Monnier
2006-12-15 5:03 Mysterious fontification/C++ context issue - Patch for beginning-of-defun-raw Richard Stallman
2006-12-15 6:31 ` Sean O'Rourke
2006-12-15 16:08 ` Chong Yidong
2006-12-15 16:16 ` Sean O'Rourke
2006-12-15 16:44 ` Chong Yidong
2006-12-15 20:46 ` Stuart D. Herring
2006-12-15 21:24 ` Richard Stallman
2006-12-15 22:31 ` Sean O'Rourke
2006-12-15 16:57 ` Chong Yidong
2006-12-15 23:33 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8764cbzg5e.fsf@stupidchicken.com \
--to=cyd@stupidchicken.com \
--cc=acm@muc.de \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=rms@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.