unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: stephen.berman@gmx.net
Cc: 15841@debbugs.gnu.org
Subject: bug#15841: Display bugs with cache-long-lines non-nil
Date: Fri, 15 Nov 2013 18:34:05 +0200	[thread overview]
Message-ID: <838uwpipz6.fsf@gnu.org> (raw)
In-Reply-To: <83txfh1t0b.fsf@gnu.org>

> Date: Tue, 12 Nov 2013 18:31:32 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: 15841@debbugs.gnu.org
> 
> In any case, I already traced through the code that is involved, and
> the immediate reason for the assertion violation is that the cache
> isn't being updated wrt changes in buffer size (which are caused by
> decoding the stuff brought in by 'ls').  However, a naive attempt to
> force such updates didn't solve the whole problem: the aborts are
> gone, but the infloop is still there, and also other minor display
> issues.  So I guess there's another factor at work there...

I think I might have found a solution for this.  Could you please run
with the patch below for a while, and see if it gives good results?

=== modified file 'src/coding.c'
--- src/coding.c	2013-10-08 06:40:09 +0000
+++ src/coding.c	2013-11-15 16:27:56 +0000
@@ -9358,6 +9358,14 @@ code_convert_region (Lisp_Object start, 
   setup_coding_system (coding_system, &coding);
   coding.mode |= CODING_MODE_LAST_BLOCK;
 
+  if (BUFFERP (dst_object) && !EQ (dst_object, src_object))
+    {
+      struct buffer *buf = XBUFFER (dst_object);
+      ptrdiff_t buf_pt = BUF_PT (buf);
+
+      invalidate_buffer_caches (buf, buf_pt, buf_pt);
+    }
+
   if (encodep)
     encode_coding_object (&coding, src_object, from, from_byte, to, to_byte,
 			  dst_object);
@@ -9447,6 +9455,15 @@ code_convert_string (Lisp_Object string,
   coding.mode |= CODING_MODE_LAST_BLOCK;
   chars = SCHARS (string);
   bytes = SBYTES (string);
+
+  if (BUFFERP (dst_object))
+    {
+      struct buffer *buf = XBUFFER (dst_object);
+      ptrdiff_t buf_pt = BUF_PT (buf);
+
+      invalidate_buffer_caches (buf, buf_pt, buf_pt);
+    }
+
   if (encodep)
     encode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object);
   else

=== modified file 'src/insdel.c'
--- src/insdel.c	2013-11-11 05:18:53 +0000
+++ src/insdel.c	2013-11-15 16:27:56 +0000
@@ -993,6 +993,11 @@ insert_from_gap (ptrdiff_t nchars, ptrdi
   if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
     nchars = nbytes;
 
+  /* No need to call prepare_to_modify_buffer, since this is called
+     from places that replace some region with a different text, so
+     prepare_to_modify_buffer was already called by the deletion part
+     of this dance.  */
+  invalidate_buffer_caches (current_buffer, GPT, GPT);
   record_insert (GPT, nchars);
   MODIFF++;
 
@@ -1869,19 +1874,26 @@ prepare_to_modify_buffer (ptrdiff_t star
 			  ptrdiff_t *preserve_ptr)
 {
   prepare_to_modify_buffer_1 (start, end, preserve_ptr);
+  invalidate_buffer_caches (current_buffer, start, end);
+}
 
-  if (current_buffer->newline_cache)
-    invalidate_region_cache (current_buffer,
-                             current_buffer->newline_cache,
-                             start - BEG, Z - end);
-  if (current_buffer->width_run_cache)
-    invalidate_region_cache (current_buffer,
-                             current_buffer->width_run_cache,
-                             start - BEG, Z - end);
-  if (current_buffer->bidi_paragraph_cache)
-    invalidate_region_cache (current_buffer,
-                             current_buffer->bidi_paragraph_cache,
-                             start - BEG, Z - end);
+/* Invalidate the caches maintained by the buffer BUF, if any, for the
+   region between buffer positions START and END.  */
+void
+invalidate_buffer_caches (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
+{
+  if (buf->newline_cache)
+    invalidate_region_cache (buf,
+                             buf->newline_cache,
+                             start - BUF_BEG (buf), BUF_Z (buf) - end);
+  if (buf->width_run_cache)
+    invalidate_region_cache (buf,
+                             buf->width_run_cache,
+                             start - BUF_BEG (buf), BUF_Z (buf) - end);
+  if (buf->bidi_paragraph_cache)
+    invalidate_region_cache (buf,
+                             buf->bidi_paragraph_cache,
+                             start - BUF_BEG (buf), BUF_Z (buf) - end);
 }
 
 /* These macros work with an argument named `preserve_ptr'

=== modified file 'src/lisp.h'
--- src/lisp.h	2013-11-15 08:18:37 +0000
+++ src/lisp.h	2013-11-15 16:27:56 +0000
@@ -3486,6 +3486,7 @@ extern Lisp_Object del_range_2 (ptrdiff_
 extern void modify_text (ptrdiff_t, ptrdiff_t);
 extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
 extern void prepare_to_modify_buffer_1 (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
+extern void invalidate_buffer_caches (struct buffer *, ptrdiff_t, ptrdiff_t);
 extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t);
 extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t,
 				 ptrdiff_t, ptrdiff_t);






  parent reply	other threads:[~2013-11-15 16:34 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-03 21:35 bug#15797: 24.3.50; Info: Mention cache-long-scans Jambunathan K
2013-11-04  0:36 ` Glenn Morris
2013-11-04  4:41   ` Jambunathan K
2013-11-04 13:10     ` Michael Heerdegen
2013-11-04 14:21       ` Jambunathan K
2013-11-05 16:32       ` Eli Zaretskii
2013-11-05 19:24         ` Stefan Monnier
2013-11-06  4:44           ` Jambunathan K
2013-11-08 10:29             ` Eli Zaretskii
2013-11-08 13:13               ` Jambunathan K
2013-11-08 14:02                 ` Stefan Monnier
2013-11-08 14:08                   ` Jambunathan K
2013-11-08 14:15                 ` Eli Zaretskii
2013-11-08 14:33                   ` Jambunathan K
2013-11-08 15:16                     ` Eli Zaretskii
2013-11-08 10:28           ` Eli Zaretskii
2013-11-08 19:07           ` Nathan Trapuzzano
2013-11-08 20:57             ` Stefan Monnier
2013-11-08 21:36               ` Nathan Trapuzzano
2013-11-08 23:11                 ` Nathan Trapuzzano
2013-11-09  8:33                 ` Eli Zaretskii
2013-11-08 21:18             ` Eli Zaretskii
2013-11-08 21:22               ` Glenn Morris
2013-11-09  2:37             ` Michael Heerdegen
2013-11-09  8:18             ` bug#15841: Display bugs with cache-long-lines non-nil Eli Zaretskii
2013-11-09  8:31               ` Eli Zaretskii
2013-11-09  8:52                 ` Eli Zaretskii
2013-11-09 11:18                 ` Eli Zaretskii
2013-11-09 14:02                   ` Eli Zaretskii
2013-11-09 21:27                     ` Eli Zaretskii
2013-11-10 18:20                 ` Michael Heerdegen
2013-11-10 18:31                   ` Eli Zaretskii
2013-11-11  3:39                     ` Michael Heerdegen
2013-11-11 16:23                       ` Eli Zaretskii
2013-11-13 23:45                         ` Michael Heerdegen
2013-11-14  3:51                           ` Eli Zaretskii
2013-11-09  8:51               ` Eli Zaretskii
2013-11-11 14:12               ` Stephen Berman
2013-11-11 20:13                 ` Eli Zaretskii
2013-11-11 20:38                   ` Stephen Berman
2013-11-12  0:38                 ` Stephen Berman
2013-11-12 10:03                   ` Stephen Berman
2013-11-12 16:31                     ` Eli Zaretskii
2013-11-12 21:34                       ` Stephen Berman
2013-11-15 16:34                       ` Eli Zaretskii [this message]
2013-11-15 18:05                         ` Stephen Berman
2013-11-16 18:53                         ` Andy Moreton
2013-11-16 19:02                           ` Eli Zaretskii
2013-11-18 16:32                           ` Eli Zaretskii
2013-11-06 18:02         ` bug#15797: 24.3.50; Info: Mention cache-long-scans Michael Heerdegen
2013-11-06 18:17           ` Eli Zaretskii
2013-11-06 18:50             ` Michael Heerdegen
2013-11-06 20:46               ` Eli Zaretskii
     [not found]         ` <<87wqkltnmk.fsf@web.de>
     [not found]           ` <<8338n975tf.fsf@gnu.org>
2013-11-06 18:58             ` Drew Adams
2013-11-06 20:56               ` Eli Zaretskii
     [not found] ` <handler.15797.D15797.138352538323812.notifdone@debbugs.gnu.org>
2013-11-04  6:27   ` bug#15797: closed (Re: bug#15797: 24.3.50; Info: Mention cache-long-scans) Jambunathan K
     [not found] <"<9jiow9uhoa.fsf"@fencepost.gnu.org>
     [not found] <<871u2xf9st.fsf@gmail.com>

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=838uwpipz6.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=15841@debbugs.gnu.org \
    --cc=stephen.berman@gmx.net \
    /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).