*** 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)); + } 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. */ *** casefiddle.c Tue Apr 11 16:24:24 2006 --- casefiddle.c Fri Jul 21 15:25:50 2006 *************** *** 189,194 **** --- 189,195 ---- validate_region (&b, &e); start = XFASTINT (b); end = XFASTINT (e); + CHARS_MODIFF++; modify_region (current_buffer, start, end); record_change (start, end - start); start_byte = CHAR_TO_BYTE (start); *** editfns.c Sun Jul 2 09:50:00 2006 --- editfns.c Fri Jul 21 15:25:52 2006 *************** *** 2785,2790 **** --- 2785,2791 ---- if (! changed) { changed = pos; + CHARS_MODIFF++; modify_region (current_buffer, changed, XINT (end)); if (! NILP (noundo)) *************** *** 2897,2902 **** --- 2898,2904 ---- pos = XINT (start); pos_byte = CHAR_TO_BYTE (pos); end_pos = XINT (end); + CHARS_MODIFF++; modify_region (current_buffer, pos, XINT (end)); cnt = 0; *************** *** 4162,4167 **** --- 4164,4170 ---- if (end1 == start2) /* adjacent regions */ { + CHARS_MODIFF++; modify_region (current_buffer, start1, end2); record_change (start1, len1 + len2); *************** *** 4218,4224 **** { USE_SAFE_ALLOCA; ! modify_region (current_buffer, start1, end1); modify_region (current_buffer, start2, end2); record_change (start1, len1); record_change (start2, len2); --- 4221,4228 ---- { USE_SAFE_ALLOCA; ! CHARS_MODIFF++; ! modify_region (current_buffer, start1, end1); modify_region (current_buffer, start2, end2); record_change (start1, len1); record_change (start2, len2); *************** *** 4248,4254 **** { USE_SAFE_ALLOCA; ! modify_region (current_buffer, start1, end2); record_change (start1, (end2 - start1)); tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); --- 4252,4259 ---- { USE_SAFE_ALLOCA; ! CHARS_MODIFF++; ! modify_region (current_buffer, start1, end2); record_change (start1, (end2 - start1)); tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); *************** *** 4279,4285 **** USE_SAFE_ALLOCA; record_change (start1, (end2 - start1)); ! modify_region (current_buffer, start1, end2); tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); --- 4284,4291 ---- USE_SAFE_ALLOCA; record_change (start1, (end2 - start1)); ! CHARS_MODIFF++; ! modify_region (current_buffer, start1, end2); tmp_interval1 = copy_intervals (cur_intv, start1, len1); tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); *** insdel.c Tue Apr 11 16:24:24 2006 --- insdel.c Fri Jul 21 15:25:58 2006 *************** *** 1007,1012 **** --- 1007,1013 ---- will add up to the right stuff in the undo list. */ record_insert (PT, nchars); MODIFF++; + CHARS_MODIFF++; bcopy (string, GPT_ADDR, nbytes); *************** *** 1144,1149 **** --- 1145,1151 ---- record_insert (PT, nchars); MODIFF++; + CHARS_MODIFF++; GAP_SIZE -= outgoing_nbytes; GPT += nchars; *************** *** 1295,1300 **** --- 1297,1303 ---- record_insert (PT, nchars); MODIFF++; + CHARS_MODIFF++; GAP_SIZE -= outgoing_nbytes; GPT += nchars; *************** *** 1403,1408 **** --- 1406,1412 ---- if (len == 0) evaporate_overlays (from); MODIFF++; + CHARS_MODIFF++; } /* Like adjust_after_replace, but doesn't require PREV_TEXT. *************** *** 1453,1458 **** --- 1457,1463 ---- if (len == 0) evaporate_overlays (from); MODIFF++; + CHARS_MODIFF++; } /* Record undo information, adjust markers and position keepers for an *************** *** 1645,1650 **** --- 1650,1656 ---- CHECK_MARKERS (); MODIFF++; + CHARS_MODIFF++; UNGCPRO; signal_after_change (from, nchars_del, GPT - from); *************** *** 1769,1774 **** --- 1775,1781 ---- CHECK_MARKERS (); MODIFF++; + CHARS_MODIFF++; } /* Delete characters in current buffer *************** *** 1950,1955 **** --- 1957,1963 ---- if (! EQ (current_buffer->undo_list, Qt)) record_delete (from, deletion); MODIFF++; + CHARS_MODIFF++; /* Relocate point as if it were a marker. */ if (from < PT) *** 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.