From: martin rudalics <rudalics@gmx.at>
Cc: simon.marshall@misys.com, emacs-devel@gnu.org
Subject: Re: jit lock sit-for provokes redisplay provokes imenu
Date: Sat, 22 Jul 2006 11:21:11 +0200 [thread overview]
Message-ID: <44C1EE07.3080502@gmx.at> (raw)
In-Reply-To: <E1G49GP-0005D8-V3@fencepost.gnu.org>
[-- Attachment #1: Type: text/plain, Size: 956 bytes --]
> Rather than increment CHARS_MODIFF separately,
> it should copy the value from MODIFF.
> That way, values of CHARS_MODIFF will be comparable with values
> that were copied from MODIFF.
Yes, but it will deprive you of eventually introducing a variable
SAVE_CHARS_MODIFF and tell whether an insertion/deletion occurred
since the last save because CHARS_MODIFF > SAVE_CHARS_MODIFF.
> Also, instead of setting CHARS_MODIFF explicitly in each place that
> modifies the buffer, modify_region could set it from MODIFF, and
> changing text properties could save and restore it to prevent it from
> being incremented. That means changes in fewer places, and no need
> for each place that modifies the buffer to know about CHARS_MODIFF.
Perhaps the cleanest solution would be to equip modify_region with an
additional parameter, say preserve_chars_modiff, and do everything in
modify_region.
In the attached patch I tried to follow your suggestions.
[-- Attachment #2: modiff.patch --]
[-- Type: text/plain, Size: 10041 bytes --]
*** buffer.c Tue Jun 6 19:20:40 2006
--- buffer.c Fri Jul 21 16:00:22 2006
***************
*** 371,376 ****
--- 371,377 ----
BUF_ZV_BYTE (b) = BEG_BYTE;
BUF_Z_BYTE (b) = BEG_BYTE;
BUF_MODIFF (b) = 1;
+ BUF_CHARS_MODIFF (b) = 1;
BUF_OVERLAY_MODIFF (b) = 1;
BUF_SAVE_MODIFF (b) = 1;
BUF_INTERVALS (b) = 0;
***************
*** 1145,1150 ****
--- 1146,1172 ----
return make_number (BUF_MODIFF (buf));
}
+
+ DEFUN ("buffer-chars-modified-tick", Fbuffer_chars_modified_tick, Sbuffer_chars_modified_tick,
+ 0, 1, 0,
+ doc: /* Return BUFFER's tick counter, incremented for each insert/delete.
+ Each buffer has a tick counter which is incremented each time text in
+ that buffer is inserted or deleted. It wraps around occasionally.
+ No argument or nil as argument means use current buffer as BUFFER. */)
+ (buffer)
+ register Lisp_Object buffer;
+ {
+ register struct buffer *buf;
+ if (NILP (buffer))
+ buf = current_buffer;
+ else
+ {
+ CHECK_BUFFER (buffer);
+ buf = XBUFFER (buffer);
+ }
+
+ return make_number (BUF_CHARS_MODIFF (buf));
+ }
\f
DEFUN ("rename-buffer", Frename_buffer, Srename_buffer, 1, 2,
"sRename buffer (to new name): \nP",
***************
*** 6014,6019 ****
--- 6036,6042 ----
defsubr (&Sbuffer_modified_p);
defsubr (&Sset_buffer_modified_p);
defsubr (&Sbuffer_modified_tick);
+ defsubr (&Sbuffer_chars_modified_tick);
defsubr (&Srename_buffer);
defsubr (&Sother_buffer);
defsubr (&Sbuffer_enable_undo);
*** buffer.h Tue Apr 11 16:24:24 2006
--- buffer.h Fri Jul 21 15:31:34 2006
***************
*** 82,87 ****
--- 82,90 ----
/* Modification count. */
#define MODIFF (current_buffer->text->modiff)
+ /* Character modification count. */
+ #define CHARS_MODIFF (current_buffer->text->chars_modiff)
+
/* Overlay modification count. */
#define OVERLAY_MODIFF (current_buffer->text->overlay_modiff)
***************
*** 147,152 ****
--- 150,158 ----
/* Modification count. */
#define BUF_MODIFF(buf) ((buf)->text->modiff)
+ /* Character modification count. */
+ #define BUF_CHARS_MODIFF(buf) ((buf)->text->chars_modiff)
+
/* Modification count as of last visit or save. */
#define BUF_SAVE_MODIFF(buf) ((buf)->text->save_modiff)
***************
*** 406,411 ****
--- 412,421 ----
for this buffer. It is incremented for
each such event, and never otherwise
changed. */
+ int chars_modiff; /* This counts insert/delete events
+ for this buffer. It is incremented for
+ each such event, and never otherwise
+ changed. */
int save_modiff; /* Previous value of modiff, as of last
time buffer visited or saved a file. */
*** insdel.c Tue Apr 11 16:24:24 2006
--- insdel.c Sat Jul 22 09:48:24 2006
***************
*** 1007,1012 ****
--- 1007,1013 ----
will add up to the right stuff in the undo list. */
record_insert (PT, nchars);
MODIFF++;
+ CHARS_MODIFF = MODIFF;
bcopy (string, GPT_ADDR, nbytes);
***************
*** 1144,1149 ****
--- 1145,1151 ----
record_insert (PT, nchars);
MODIFF++;
+ CHARS_MODIFF = MODIFF;
GAP_SIZE -= outgoing_nbytes;
GPT += nchars;
***************
*** 1295,1300 ****
--- 1297,1303 ----
record_insert (PT, nchars);
MODIFF++;
+ CHARS_MODIFF = MODIFF;
GAP_SIZE -= outgoing_nbytes;
GPT += nchars;
***************
*** 1403,1408 ****
--- 1406,1412 ----
if (len == 0)
evaporate_overlays (from);
MODIFF++;
+ CHARS_MODIFF = MODIFF;
}
/* Like adjust_after_replace, but doesn't require PREV_TEXT.
***************
*** 1453,1458 ****
--- 1457,1463 ----
if (len == 0)
evaporate_overlays (from);
MODIFF++;
+ CHARS_MODIFF = MODIFF;
}
/* Record undo information, adjust markers and position keepers for an
***************
*** 1645,1650 ****
--- 1650,1656 ----
CHECK_MARKERS ();
MODIFF++;
+ CHARS_MODIFF = MODIFF;
UNGCPRO;
signal_after_change (from, nchars_del, GPT - from);
***************
*** 1769,1774 ****
--- 1775,1781 ----
CHECK_MARKERS ();
MODIFF++;
+ CHARS_MODIFF = MODIFF;
}
\f
/* Delete characters in current buffer
***************
*** 1950,1955 ****
--- 1957,1963 ----
if (! EQ (current_buffer->undo_list, Qt))
record_delete (from, deletion);
MODIFF++;
+ CHARS_MODIFF = MODIFF;
/* Relocate point as if it were a marker. */
if (from < PT)
***************
*** 2009,2014 ****
--- 2017,2023 ----
if (MODIFF <= SAVE_MODIFF)
record_first_change ();
MODIFF++;
+ CHARS_MODIFF = MODIFF;
buffer->point_before_scroll = Qnil;
*** textprop.c Sun Jul 2 09:50:00 2006
--- textprop.c Sat Jul 22 10:44:34 2006
***************
*** 1247,1253 ****
}
if (BUFFERP (object))
! modify_region (XBUFFER (object), XINT (start), XINT (end));
/* We are at the beginning of interval I, with LEN chars to scan. */
for (;;)
--- 1247,1257 ----
}
if (BUFFERP (object))
! {
! int save_chars_modiff = CHARS_MODIFF;
! modify_region (XBUFFER (object), XINT (start), XINT (end));
! CHARS_MODIFF = save_chars_modiff;
! }
/* We are at the beginning of interval I, with LEN chars to scan. */
for (;;)
***************
*** 1387,1393 ****
}
if (BUFFERP (object))
! modify_region (XBUFFER (object), XINT (start), XINT (end));
set_text_properties_1 (start, end, properties, object, i);
--- 1391,1401 ----
}
if (BUFFERP (object))
! {
! int save_chars_modiff = CHARS_MODIFF;
! modify_region (XBUFFER (object), XINT (start), XINT (end));
! CHARS_MODIFF = save_chars_modiff;
! }
set_text_properties_1 (start, end, properties, object, i);
***************
*** 1535,1541 ****
}
if (BUFFERP (object))
! modify_region (XBUFFER (object), XINT (start), XINT (end));
/* We are at the beginning of an interval, with len to scan */
for (;;)
--- 1543,1553 ----
}
if (BUFFERP (object))
! {
! int save_chars_modiff = CHARS_MODIFF;
! modify_region (XBUFFER (object), XINT (start), XINT (end));
! CHARS_MODIFF = save_chars_modiff;
! }
/* We are at the beginning of an interval, with len to scan */
for (;;)
***************
*** 1649,1655 ****
if (LENGTH (i) == len)
{
if (!modified && BUFFERP (object))
! modify_region (XBUFFER (object), XINT (start), XINT (end));
remove_properties (Qnil, properties, i, object);
if (BUFFERP (object))
signal_after_change (XINT (start), XINT (end) - XINT (start),
--- 1661,1671 ----
if (LENGTH (i) == len)
{
if (!modified && BUFFERP (object))
! {
! int save_chars_modiff = CHARS_MODIFF;
! modify_region (XBUFFER (object), XINT (start), XINT (end));
! CHARS_MODIFF = save_chars_modiff;
! }
remove_properties (Qnil, properties, i, object);
if (BUFFERP (object))
signal_after_change (XINT (start), XINT (end) - XINT (start),
***************
*** 1662,1668 ****
i = split_interval_left (i, len);
copy_properties (unchanged, i);
if (!modified && BUFFERP (object))
! modify_region (XBUFFER (object), XINT (start), XINT (end));
remove_properties (Qnil, properties, i, object);
if (BUFFERP (object))
signal_after_change (XINT (start), XINT (end) - XINT (start),
--- 1678,1688 ----
i = split_interval_left (i, len);
copy_properties (unchanged, i);
if (!modified && BUFFERP (object))
! {
! int save_chars_modiff = CHARS_MODIFF;
! modify_region (XBUFFER (object), XINT (start), XINT (end));
! CHARS_MODIFF = save_chars_modiff;
! }
remove_properties (Qnil, properties, i, object);
if (BUFFERP (object))
signal_after_change (XINT (start), XINT (end) - XINT (start),
***************
*** 1673,1679 ****
if (interval_has_some_properties_list (properties, i))
{
if (!modified && BUFFERP (object))
! modify_region (XBUFFER (object), XINT (start), XINT (end));
remove_properties (Qnil, properties, i, object);
modified = 1;
}
--- 1693,1703 ----
if (interval_has_some_properties_list (properties, i))
{
if (!modified && BUFFERP (object))
! {
! int save_chars_modiff = CHARS_MODIFF;
! modify_region (XBUFFER (object), XINT (start), XINT (end));
! CHARS_MODIFF = save_chars_modiff;
! }
remove_properties (Qnil, properties, i, object);
modified = 1;
}
*** imenu.el Mon May 1 10:08:52 2006
--- imenu.el Fri Jul 21 16:30:38 2006
***************
*** 968,982 ****
(defvar imenu-buffer-menubar nil)
(defvar imenu-menubar-modified-tick 0
! "The value of (buffer-modified-tick) as of last call to `imenu-update-menubar'.")
(make-variable-buffer-local 'imenu-menubar-modified-tick)
(defun imenu-update-menubar ()
(when (and (current-local-map)
(keymapp (lookup-key (current-local-map) [menu-bar index]))
! (not (eq (buffer-modified-tick)
imenu-menubar-modified-tick)))
! (setq imenu-menubar-modified-tick (buffer-modified-tick))
(let ((index-alist (imenu--make-index-alist t)))
;; Don't bother updating if the index-alist has not changed
;; since the last time we did it.
--- 968,982 ----
(defvar imenu-buffer-menubar nil)
(defvar imenu-menubar-modified-tick 0
! "The value of (buffer-chars-modified-tick) as of last call to `imenu-update-menubar'.")
(make-variable-buffer-local 'imenu-menubar-modified-tick)
(defun imenu-update-menubar ()
(when (and (current-local-map)
(keymapp (lookup-key (current-local-map) [menu-bar index]))
! (not (eq (buffer-chars-modified-tick)
imenu-menubar-modified-tick)))
! (setq imenu-menubar-modified-tick (buffer-chars-modified-tick))
(let ((index-alist (imenu--make-index-alist t)))
;; Don't bother updating if the index-alist has not changed
;; since the last time we did it.
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2006-07-22 9:21 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <81CCA6588E60BB42BE68BD029ED4826008838221@wimex2.wim.midas-kapiti.com>
2006-07-20 18:16 ` jit lock sit-for provokes redisplay provokes imenu Richard Stallman
2006-07-20 19:47 ` Drew Adams
2006-07-20 22:41 ` Richard Stallman
2006-07-21 9:13 ` martin rudalics
2006-07-21 19:37 ` Richard Stallman
2006-07-22 9:01 ` martin rudalics
2006-07-24 14:42 ` Richard Stallman
2006-07-26 9:32 ` martin rudalics
2006-07-21 14:53 ` martin rudalics
2006-07-22 4:38 ` Richard Stallman
2006-07-22 9:21 ` martin rudalics [this message]
2006-07-23 7:55 ` martin rudalics
2006-07-24 14:42 ` Richard Stallman
2006-07-26 11:24 ` martin rudalics
2006-07-26 15:10 ` Stefan Monnier
2006-07-26 16:16 ` martin rudalics
2006-07-27 14:35 ` Stefan Monnier
2006-07-26 22:34 ` Richard Stallman
2006-07-26 22:48 ` David Kastrup
2006-07-27 16:04 ` Richard Stallman
2006-07-27 16:27 ` David Kastrup
2006-07-27 23:45 ` Richard Stallman
2006-08-03 9:35 ` martin rudalics
2006-08-20 14:28 ` Chong Yidong
2006-08-21 14:20 ` Kim F. Storm
2006-08-21 15:20 ` Chong Yidong
2006-08-23 15:04 ` Kim F. Storm
2006-07-26 14:51 Marshall, Simon
2006-07-26 15:48 ` martin rudalics
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=44C1EE07.3080502@gmx.at \
--to=rudalics@gmx.at \
--cc=emacs-devel@gnu.org \
--cc=simon.marshall@misys.com \
/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).