all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Daniel Colascione <dancol@dancol.org>
To: 16585@debbugs.gnu.org
Cc: Alan Mackenzie <acm@muc.de>
Subject: bug#16585: c-invalidate-state-cache fails if called when narrowed
Date: Tue, 28 Jan 2014 18:09:04 -0800	[thread overview]
Message-ID: <52E862C0.3010608@dancol.org> (raw)

c-invalidate-state-cache can fail if called in a narrowed region: we end 
up calling c-clear-char-property for bob even if that's before 
point-min, causing remote-text-properties to raise (args-out-of-range 1 2).

We get into this situation when expanding yasnippet snippets; we're 
calling c-invalidate-state-cache from c-before-change.

To repro manually, first write this to some buffer.

#include <stdio.h>

void foo() {

}


Then (this is important) run M-x c-mode. After starting the mode, move 
point to inside foo's body and eval (save-restriction (narrow-to-region 
(point-at-bol) (point-at-eol)) (c-invalidate-state-cache (point))). You 
should break into the debugger.

The patch below seems correct and fixes the problem for me, but it'd be 
nice if Alan could take a look at it before I push it to trunk. The 
version of c-invalidate-state-cache in cc-mode trunk is very different.

=== modified file 'lisp/progmodes/cc-engine.el'
--- lisp/progmodes/cc-engine.el	2014-01-19 12:32:47 +0000
+++ lisp/progmodes/cc-engine.el	2014-01-29 02:07:44 +0000
@@ -3318,15 +3318,17 @@
    ;; of all parens in preprocessor constructs, except for any such 
construct
    ;; containing point.  We can then call `c-invalidate-state-cache-1' 
without
    ;; worrying further about macros and template delimiters.
-  (c-with-<->-as-parens-suppressed
-   (if (and c-state-old-cpp-beg
-	    (< c-state-old-cpp-beg here))
-       (c-with-all-but-one-cpps-commented-out
-	c-state-old-cpp-beg
-	(min c-state-old-cpp-end here)
-	(c-invalidate-state-cache-1 here))
-     (c-with-cpps-commented-out
-      (c-invalidate-state-cache-1 here)))))
+  (save-restriction
+    (widen)
+    (c-with-<->-as-parens-suppressed
+     (if (and c-state-old-cpp-beg
+              (< c-state-old-cpp-beg here))
+         (c-with-all-but-one-cpps-commented-out
+          c-state-old-cpp-beg
+          (min c-state-old-cpp-end here)
+          (c-invalidate-state-cache-1 here))
+       (c-with-cpps-commented-out
+        (c-invalidate-state-cache-1 here))))))

  (defmacro c-state-maybe-marker (place marker)
    ;; If PLACE is non-nil, return a marker marking it, otherwise nil.






             reply	other threads:[~2014-01-29  2:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-29  2:09 Daniel Colascione [this message]
2014-01-29  2:49 ` bug#16585: c-invalidate-state-cache fails if called when narrowed Glenn Morris
2014-02-02  2:12   ` Daniel Colascione
2014-02-16  9:14     ` Alan Mackenzie
2014-02-05 23:16 ` Alan Mackenzie
2014-02-08 22:37 ` Alan Mackenzie
     [not found] ` <20140208223717.GA4063@acm.acm>
2014-02-08 22:57   ` Alan Mackenzie

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=52E862C0.3010608@dancol.org \
    --to=dancol@dancol.org \
    --cc=16585@debbugs.gnu.org \
    --cc=acm@muc.de \
    /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.