From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#20240: 25.0.50; CC Mode broken fontification and commenting Date: 3 Apr 2015 20:52:19 -0000 Organization: muc.de e.V. Message-ID: <20150403205219.41891.qmail@mail.muc.de> References: <87zj6snmts.fsf@udel.edu> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1428094403 22652 80.91.229.3 (3 Apr 2015 20:53:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 3 Apr 2015 20:53:23 +0000 (UTC) Cc: 20240@debbugs.gnu.org To: Stefan Monnier , Mark Oteiza Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 03 22:53:14 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ye8aV-0001SH-6w for geb-bug-gnu-emacs@m.gmane.org; Fri, 03 Apr 2015 22:53:11 +0200 Original-Received: from localhost ([::1]:35335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ye8aU-0000vp-CC for geb-bug-gnu-emacs@m.gmane.org; Fri, 03 Apr 2015 16:53:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ye8aR-0000vk-6y for bug-gnu-emacs@gnu.org; Fri, 03 Apr 2015 16:53:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ye8aQ-000622-Ak for bug-gnu-emacs@gnu.org; Fri, 03 Apr 2015 16:53:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ye8aM-00061I-Ns; Fri, 03 Apr 2015 16:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Ye8aM-0003ut-I4; Fri, 03 Apr 2015 16:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 03 Apr 2015 20:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20240 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 20240-submit@debbugs.gnu.org id=B20240.142809434515007 (code B ref 20240); Fri, 03 Apr 2015 20:53:02 +0000 Original-Received: (at 20240) by debbugs.gnu.org; 3 Apr 2015 20:52:25 +0000 Original-Received: from localhost ([127.0.0.1]:44170 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ye8Zk-0003tz-4n for submit@debbugs.gnu.org; Fri, 03 Apr 2015 16:52:24 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:34708 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ye8Zh-0003tp-24 for 20240@debbugs.gnu.org; Fri, 03 Apr 2015 16:52:22 -0400 Original-Received: (qmail 41892 invoked by uid 3782); 3 Apr 2015 20:52:19 -0000 In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (FreeBSD/10.1-RELEASE (amd64)) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:101164 Archived-At: Hello, Stefan and Mark. In article you wrote: > Alan Mackenzie writes: >> In article you wrote: >>>>>From emacs -Q: >> >>> 1. C-x C-f foo.c RET >>> 2. Insert: { RET } >>> 3. Select the first line and M-; >> >>> Only `/* ` is inserted at the beginning of the buffer, which is wrong. >> >> It actually signals an error at that point, which is indeed wrong. > Ah, I missed it then, thanks. >> I've just committed a fix to the Emacs repository. Could you please update >> your sources, rebuild, and confirm that the fix works, please. >> >> Thanks for taking the trouble to report this bug. > You're welcome. You fixed the example I gave, but as it turns out my > example was too minimal. Hopefully this is better: uncommenting the > commented line in the following will signal a jit-lock error > int main(void) { > for(;;) { > /* return 0; */ > } > } > Repeating M-; on that line, eventually I get `return 0;` uncommented but > fontified as a comment. That is actually a different (though similar) bug. Stefan, do you have any objections to the patch below, which widens the buffer in jit-lock-after-change before setting the 'fontified text properties? Mark's (latest) bug is happening because `comment-dwim' is narrowing to an existing comment which isn't at BOL, and jit-lock-after-change is erroring because it's trying to set the text properties at col 0, but can't (because of the narrowing). Like you said a while back, narrowing can cause problems. diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el index 0faabeb..d5651c6 100644 --- a/lisp/jit-lock.el +++ b/lisp/jit-lock.el @@ -650,12 +650,14 @@ will take place when text is fontified stealthily." (let ((jit-lock-start start) (jit-lock-end end)) (with-buffer-prepared-for-jit-lock - (run-hook-with-args 'jit-lock-after-change-extend-region-functions - start end old-len) - ;; Make sure we change at least one char (in case of deletions). - (setq jit-lock-end (min (max jit-lock-end (1+ start)) (point-max))) - ;; Request refontification. - (put-text-property jit-lock-start jit-lock-end 'fontified nil)) + (save-restriction + (widen) + (run-hook-with-args 'jit-lock-after-change-extend-region-functions + start end old-len) + ;; Make sure we change at least one char (in case of deletions). + (setq jit-lock-end (min (max jit-lock-end (1+ start)) (point-max))) + ;; Request refontification. + (put-text-property jit-lock-start jit-lock-end 'fontified nil))) ;; Mark the change for deferred contextual refontification. (when jit-lock-context-unfontify-pos (setq jit-lock-context-unfontify-pos -- Alan Mackenzie (Nuremberg, Germany).