From unknown Thu Aug 14 12:23:14 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#16910 <16910@debbugs.gnu.org> To: bug#16910 <16910@debbugs.gnu.org> Subject: Status: 24.3; c++ mode: autoindent stops working Reply-To: bug#16910 <16910@debbugs.gnu.org> Date: Thu, 14 Aug 2025 19:23:14 +0000 retitle 16910 24.3; c++ mode: autoindent stops working reassign 16910 emacs,cc-mode submitter 16910 admin@practicealgebra.net severity 16910 normal tag 16910 moreinfo thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 28 12:42:50 2014 Received: (at submit) by debbugs.gnu.org; 28 Feb 2014 17:42:50 +0000 Received: from localhost ([127.0.0.1]:44867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WJRSR-0007xN-2T for submit@debbugs.gnu.org; Fri, 28 Feb 2014 12:42:48 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56676) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WJQnr-0006L7-3G for submit@debbugs.gnu.org; Fri, 28 Feb 2014 12:00:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJQnj-0005Mf-MU for submit@debbugs.gnu.org; Fri, 28 Feb 2014 12:00:50 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: *** X-Spam-Status: No, score=3.3 required=5.0 tests=AC_HTML_NONSENSE_TAGS, BAYES_50, RECEIVED_FROM_WINDOWS_HOST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:40759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJQni-0005MV-OQ for submit@debbugs.gnu.org; Fri, 28 Feb 2014 12:00:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJQnb-0003Io-B7 for bug-gnu-emacs@gnu.org; Fri, 28 Feb 2014 12:00:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJQnU-0005IQ-QA for bug-gnu-emacs@gnu.org; Fri, 28 Feb 2014 12:00:35 -0500 Received: from mail.99main.com ([208.28.184.11]:49840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJQnU-0005HG-4T for bug-gnu-emacs@gnu.org; Fri, 28 Feb 2014 12:00:28 -0500 Received: from practicealgebra.net (65.172.152.38.dsl.99main.com [65.172.152.38]) by mail.99main.com (8.12.8+Sun/8.12.8) with ESMTP id s1SGML3q008105 for ; Fri, 28 Feb 2014 11:22:21 -0500 (EST) From: admin@practicealgebra.net To: bug-gnu-emacs@gnu.org Subject: 24.3; c++ mode: autoindent stops working Date: Fri, 28 Feb 2014 11:26:22 -0500 Message-ID: <874n3j2ogh.fsf@practicealgebra.net> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 28 Feb 2014 12:42:43 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Hi- While editing files in c++ mode, autoindent sometimes stops working after a while. Saving, making a trivial change and then immediately reverting sometimes solves the problem, but usually not. I'm afraid I can't give a recipe, since I myself don't understand when it happens; it seems unpredictable. But (some of) the error messages from emacs (which appear in the echo area) are below. -Andrew Warshall In GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 3.10.7) of 2014-02-24 on warshall Windowing system distributor `The X.Org Foundation', version 11.0.11202000 Configured using: `configure '--prefix=/usr' '--localstatedir=/var' '--with-gif=no' 'CFLAGS=-march=amdfam10'' Important settings: value of $LANG: en_US.ISO-8859-1 locale-coding-system: iso-latin-1-unix default enable-multibyte-characters: t Major mode: C++/l Minor modes in effect: shell-dirtrack-mode: t show-paren-mode: t tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t abbrev-mode: t Recent input: ) . t o _ g e n _ e x p SPC ( ) . t o _ g e n _ e x p SPC ( . ) ) . SPC SPC SPC SPC SPC SPC SPC SPC SPC SPC SPC ) C-x C-s SPC r e p o r Recent messages: c-parse-state inconsistency at 1692: using cache: ((1415 . 1506) 220), from scratch: nil Old state: (setq c-state-cache '((1415 . 1506) 220) c-state-cache-good-pos 1636 c-state-nonlit-pos-cache '(3001) c-state-nonlit-pos-cache-limit 1 c-state-semi-nonlit-pos-cache nil c-state-semi-nonlit-pos-cache-limit 1 c-state-brace-pair-desert '(220 . 322) c-state-point-min 1 c-state-point-min-lit-type nil c-state-point-min-lit-start nil c-state-min-scan-pos 1 c-state-old-cpp-beg nil c-state-old-cpp-end nil c-parse-state-point 1764) c-parse-state inconsistency at 1417: using cache: (1415 (1001 . 1156) 220), from scratch: nil Old state: (setq c-state-cache '((1415 . 1506) 220) c-state-cache-good-pos 1636 c-state-nonlit-pos-cache '(3001) c-state-nonlit-pos-cache-limit 1 c-state-semi-nonlit-pos-cache nil c-state-semi-nonlit-pos-cache-limit 1 c-state-brace-pair-desert '(220 . 322) c-state-point-min 1 c-state-point-min-lit-type nil c-state-point-min-lit-start nil c-state-min-scan-pos 1 c-state-old-cpp-beg nil c-state-old-cpp-end nil c-parse-state-point 1692) c-parse-state inconsistency at 1417: using cache: (1415 (1001 . 1156) 220), from scratch: nil Old state: (setq c-state-cache '(1415 (1001 . 1156) 220) c-state-cache-good-pos 1416 c-state-nonlit-pos-cache '(3001) c-state-nonlit-pos-cache-limit 1 c-state-semi-nonlit-pos-cache nil c-state-semi-nonlit-pos-cache-limit 1 c-state-brace-pair-desert '(220 . 322) c-state-point-min 1 c-state-point-min-lit-type nil c-state-point-min-lit-start nil c-state-min-scan-pos 1 c-state-old-cpp-beg nil c-state-old-cpp-end nil c-parse-state-point 1417) completing-read-default: Command attempted to use minibuffer while in minibuffer Load-path shadows: /usr/share/emacs/site-lisp/t-mouse hides /usr/share/emacs/24.3/lisp/t-mouse Features: (shadow sort gnus-util mail-extr emacsbug message cl-macs gv format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils jka-compr gud easy-mmode vc vc-dispatcher misearch multi-isearch ispell sgml-mode skeleton tex-mode shell pcomplete latexenc make-mode cc-langs cl cl-lib cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs help-mode haskell-mode-autoloads edmacro kmacro imenu info easymenu package compile comint ansi-color ring paren cus-start cus-load time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dbusbind dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs) From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 01 02:39:21 2014 Received: (at 16910) by debbugs.gnu.org; 1 Mar 2014 07:39:21 +0000 Received: from localhost ([127.0.0.1]:45276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WJeW0-0007dp-I2 for submit@debbugs.gnu.org; Sat, 01 Mar 2014 02:39:21 -0500 Received: from mtaout22.012.net.il ([80.179.55.172]:46694) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WJeVu-0007dc-DV for 16910@debbugs.gnu.org; Sat, 01 Mar 2014 02:39:15 -0500 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0N1Q00500YL85000@a-mtaout22.012.net.il> for 16910@debbugs.gnu.org; Sat, 01 Mar 2014 09:39:13 +0200 (IST) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N1Q005ELYLC0I30@a-mtaout22.012.net.il>; Sat, 01 Mar 2014 09:39:13 +0200 (IST) Date: Sat, 01 Mar 2014 09:39:17 +0200 From: Eli Zaretskii Subject: Re: bug#16910: 24.3; c++ mode: autoindent stops working In-reply-to: <874n3j2ogh.fsf@practicealgebra.net> X-012-Sender: halo1@inter.net.il To: admin@practicealgebra.net Message-id: <83txbiv04a.fsf@gnu.org> References: <874n3j2ogh.fsf@practicealgebra.net> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 16910 Cc: 16910@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > From: admin@practicealgebra.net > Date: Fri, 28 Feb 2014 11:26:22 -0500 > > While editing files in c++ mode, autoindent sometimes stops working > after a while. Saving, making a trivial change and then immediately > reverting sometimes solves the problem, but usually not. I'm afraid I > can't give a recipe, since I myself don't understand when it happens; it > seems unpredictable. But (some of) the error messages from emacs (which > appear in the echo area) are below. When this happens to me (and it does, although there are no messages I could spot in my cases), I usually save and kill the buffer, then visit the file anew -- the problems are usually gone after that. From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 01 19:10:11 2014 Received: (at 16910) by debbugs.gnu.org; 2 Mar 2014 00:10:11 +0000 Received: from localhost ([127.0.0.1]:47133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WJtys-0003HX-Np for submit@debbugs.gnu.org; Sat, 01 Mar 2014 19:10:11 -0500 Received: from mail.99main.com ([208.28.184.11]:42576) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WJtyp-0003HN-T3 for 16910@debbugs.gnu.org; Sat, 01 Mar 2014 19:10:08 -0500 Received: from practicealgebra.net (65.172.152.38.dsl.99main.com [65.172.152.38]) by mail.99main.com (8.12.8+Sun/8.12.8) with ESMTP id s220A63q006533; Sat, 1 Mar 2014 19:10:06 -0500 (EST) Date: Sat, 1 Mar 2014 19:15:01 -0500 From: Andrew Warshall To: Eli Zaretskii Subject: Re: bug#16910: 24.3; c++ mode: autoindent stops working Message-ID: <20140301191501.55cbed6c@practicealgebra.net> In-Reply-To: <83txbiv04a.fsf@gnu.org> References: <874n3j2ogh.fsf@practicealgebra.net> <83txbiv04a.fsf@gnu.org> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.22; i686-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16910 Cc: 16910@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi- Yes, this did work. (The messages appeared in debug mode only.) But I thought the bug should still be reported. Thanks, Andrew Warshall On Sat, 01 Mar 2014 09:39:17 +0200 Eli Zaretskii wrote: > > From: admin@practicealgebra.net > > Date: Fri, 28 Feb 2014 11:26:22 -0500 > > > > While editing files in c++ mode, autoindent sometimes stops working > > after a while. Saving, making a trivial change and then immediately > > reverting sometimes solves the problem, but usually not. I'm afraid > > I can't give a recipe, since I myself don't understand when it > > happens; it seems unpredictable. But (some of) the error messages > > from emacs (which appear in the echo area) are below. > > When this happens to me (and it does, although there are no messages I > could spot in my cases), I usually save and kill the buffer, then > visit the file anew -- the problems are usually gone after that. > From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 02 09:41:44 2014 Received: (at 16910) by debbugs.gnu.org; 2 Mar 2014 14:41:44 +0000 Received: from localhost ([127.0.0.1]:47622 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WK7aJ-0002cC-IQ for submit@debbugs.gnu.org; Sun, 02 Mar 2014 09:41:44 -0500 Received: from colin.muc.de ([193.149.48.1]:48572 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WK7aE-0002br-5V for 16910@debbugs.gnu.org; Sun, 02 Mar 2014 09:41:39 -0500 Received: (qmail 1811 invoked by uid 3782); 2 Mar 2014 14:41:36 -0000 Received: from acm.muc.de (pD9518496.dip0.t-ipconnect.de [217.81.132.150]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 02 Mar 2014 15:41:34 +0100 Received: (qmail 4847 invoked by uid 1000); 2 Mar 2014 14:38:00 -0000 Date: Sun, 2 Mar 2014 14:38:00 +0000 To: admin@practicealgebra.net Subject: Re: bug#16910: 24.3; c++ mode: autoindent stops working Message-ID: <20140302143800.GB3768@acm.acm> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 16910 Cc: 16910@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Hi, Andrew. > Hi- > While editing files in c++ mode, autoindent sometimes stops working > after a while. Saving, making a trivial change and then immediately > reverting sometimes solves the problem, but usually not. I'm afraid I > can't give a recipe, since I myself don't understand when it happens; it > seems unpredictable. But (some of) the error messages from emacs (which > appear in the echo area) are below. > -Andrew Warshall > In GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 3.10.7) > of 2014-02-24 on warshall [ .... ] > Recent messages: > c-parse-state inconsistency at 1692: using cache: ((1415 . 1506) 220), from scratch: nil > Old state: > (setq c-state-cache '((1415 . 1506) 220) c-state-cache-good-pos 1636 c-state-nonlit-pos-cache '(3001) c-state-nonlit-pos-cache-limit 1 c-state-semi-nonlit-pos-cache nil c-state-semi-nonlit-pos-cache-limit 1 c-state-brace-pair-desert '(220 . 322) c-state-point-min 1 c-state-point-min-lit-type nil c-state-point-min-lit-start nil c-state-min-scan-pos 1 c-state-old-cpp-beg nil c-state-old-cpp-end nil c-parse-state-point 1764) > c-parse-state inconsistency at 1417: using cache: (1415 (1001 . 1156) 220), from scratch: nil > Old state: > (setq c-state-cache '((1415 . 1506) 220) c-state-cache-good-pos 1636 c-state-nonlit-pos-cache '(3001) c-state-nonlit-pos-cache-limit 1 c-state-semi-nonlit-pos-cache nil c-state-semi-nonlit-pos-cache-limit 1 c-state-brace-pair-desert '(220 . 322) c-state-point-min 1 c-state-point-min-lit-type nil c-state-point-min-lit-start nil c-state-min-scan-pos 1 c-state-old-cpp-beg nil c-state-old-cpp-end nil c-parse-state-point 1692) > c-parse-state inconsistency at 1417: using cache: (1415 (1001 . 1156) 220), from scratch: nil > Old state: > (setq c-state-cache '(1415 (1001 . 1156) 220) c-state-cache-good-pos 1416 c-state-nonlit-pos-cache '(3001) c-state-nonlit-pos-cache-limit 1 c-state-semi-nonlit-pos-cache nil c-state-semi-nonlit-pos-cache-limit 1 c-state-brace-pair-desert '(220 . 322) c-state-point-min 1 c-state-point-min-lit-type nil c-state-point-min-lit-start nil c-state-min-scan-pos 1 c-state-old-cpp-beg nil c-state-old-cpp-end nil c-parse-state-point 1417) These debug messages originate from a particular CC Mode function `c-parse-state' which crawls through the buffer recording the position of certain near and enclosing braces/brackets/parentheses. Somewhere, e.g. in your .emacs, you presumably have toggled `c-toggle-parse-state-debug' to get this output. `c-parse-state' in Emacs 24.3 was buggy. The latest version, which will be getting released along with Emacs 24.4, is less buggy. I suggest you apply the following patch to ..../emacs-24.3/lisp/progmodes/cc-engine.el to bring that file up to the latest state, which should hopefully make CC Mode indentation run more smoothly, or even correctly. After applying the patch, recompile cc-engine.el with either M-x byte-compile-file, or (from the command line) emacs -Q -batch -f batch-byte-compile cc-engine.el . --- cc-engine.el 2013-04-26 12:35:20.000000000 +0000 +++ cc-engine.el.new 2014-02-02 16:16:42.000000000 +0000 @@ -2180,32 +2187,46 @@ ;; reduced by buffer changes, and increased by invocations of ;; `c-state-literal-at'. FIXME!!! -(defsubst c-state-pp-to-literal (from to) +(defsubst c-state-pp-to-literal (from to &optional not-in-delimiter) ;; Do a parse-partial-sexp from FROM to TO, returning either ;; (STATE TYPE (BEG . END)) if TO is in a literal; or ;; (STATE) otherwise, ;; where STATE is the parsing state at TO, TYPE is the type of the literal ;; (one of 'c, 'c++, 'string) and (BEG . END) is the boundaries of the literal. ;; + ;; Unless NOT-IN-DELIMITER is non-nil, when TO is inside a two-character + ;; comment opener, this is recognized as being in a comment literal. + ;; ;; Only elements 3 (in a string), 4 (in a comment), 5 (following a quote), ;; 7 (comment type) and 8 (start of comment/string) (and possibly 9) of ;; STATE are valid. (save-excursion (let ((s (parse-partial-sexp from to)) - ty) - (when (or (nth 3 s) (nth 4 s)) ; in a string or comment + ty co-st) + (cond + ((or (nth 3 s) (nth 4 s)) ; in a string or comment (setq ty (cond ((nth 3 s) 'string) - ((eq (nth 7 s) t) 'c++) + ((nth 7 s) 'c++) (t 'c))) (parse-partial-sexp (point) (point-max) - nil ; TARGETDEPTH - nil ; STOPBEFORE - s ; OLDSTATE - 'syntax-table)) ; stop at end of literal - (if ty - `(,s ,ty (,(nth 8 s) . ,(point))) - `(,s))))) + nil ; TARGETDEPTH + nil ; STOPBEFORE + s ; OLDSTATE + 'syntax-table) ; stop at end of literal + `(,s ,ty (,(nth 8 s) . ,(point)))) + + ((and (not not-in-delimiter) ; inside a comment starter + (not (bobp)) + (progn (backward-char) + (and (not (looking-at "\\s!")) + (looking-at c-comment-start-regexp)))) + (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++) + co-st (point)) + (forward-comment 1) + `(,s ,ty (,co-st . ,(point)))) + + (t `(,s)))))) (defun c-state-safe-place (here) ;; Return a buffer position before HERE which is "safe", i.e. outside any @@ -2280,25 +2301,25 @@ (while (and c (> (car c) c-state-semi-nonlit-pos-cache-limit)) (setq c (cdr c))) (setq c-state-semi-nonlit-pos-cache c) - + (while (and c (> (car c) here)) (setq high-pos (car c)) (setq c (cdr c))) (setq pos (or (car c) (point-min))) - + (unless high-pos (while ;; Add an element to `c-state-semi-nonlit-pos-cache' each iteration. (and (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here) - + ;; Test for being in a literal. If so, go to after it. (progn (setq lit (car (cddr (c-state-pp-to-literal pos npos)))) (or (null lit) (prog1 (<= (cdr lit) here) (setq npos (cdr lit)))))) - + (setq pos npos) (setq c-state-semi-nonlit-pos-cache (cons pos c-state-semi-nonlit-pos-cache)))) @@ -2532,8 +2553,11 @@ ;; The return value is a list, one of the following: ;; ;; o - ('forward START-POINT) - scan forward from START-POINT, - ;; which is not less than the highest position in `c-state-cache' below here. + ;; which is not less than the highest position in `c-state-cache' below HERE, + ;; which is after GOOD-POS. ;; o - ('backward nil) - scan backwards (from HERE). + ;; o - ('back-and-forward START-POINT) - like 'forward, but when HERE is earlier + ;; than GOOD-POS. ;; o - ('IN-LIT nil) - point is inside the literal containing point-min. (let ((cache-pos (c-get-cache-scan-pos here)) ; highest position below HERE in cache (or 1) strategy ; 'forward, 'backward, or 'IN-LIT. @@ -2548,9 +2572,9 @@ ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting. (setq strategy 'backward)) (t - (setq strategy 'forward + (setq strategy 'back-and-forward start-point cache-pos))) - (list strategy (and (eq strategy 'forward) start-point)))) + (list strategy start-point))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2606,11 +2630,11 @@ ;; OLD: { (.) {...........} ;; ^ ^ ;; FROM HERE - ;; + ;; ;; NEW: { {....} (.) {......... ;; ^ ^ ^ ;; LOWER BRACE PAIR HERE or HERE - ;; + ;; ;; This routine should be fast. Since it can get called a LOT, we maintain ;; `c-state-brace-pair-desert', a small cache of "failures", such that we ;; reduce the time wasted in repeated fruitless searches in brace deserts. @@ -2822,9 +2846,10 @@ (defun c-remove-stale-state-cache (start-point here pps-point) ;; Remove stale entries from the `c-cache-state', i.e. those which will - ;; not be in it when it is amended for position HERE. Additionally, the - ;; "outermost" open-brace entry before HERE will be converted to a cons if - ;; the matching close-brace is scanned. + ;; not be in it when it is amended for position HERE. This may involve + ;; replacing a CONS element for a brace pair containing HERE with its car. + ;; Additionally, the "outermost" open-brace entry before HERE will be + ;; converted to a cons if the matching close-brace is below HERE. ;; ;; START-POINT is a "maximal" "safe position" - there must be no open ;; parens/braces/brackets between START-POINT and HERE. @@ -2835,7 +2860,7 @@ ;; adjust it to get outside a string/comment. (Sorry about this! The code ;; needs to be FAST). ;; - ;; Return a list (GOOD-POS SCAN-BACK-POS PPS-STATE), where + ;; Return a list (GOOD-POS SCAN-BACK-POS CONS-SEPARATED PPS-STATE), where ;; o - GOOD-POS is a position where the new value `c-state-cache' is known ;; to be good (we aim for this to be as high as possible); ;; o - SCAN-BACK-POS, if not nil, indicates there may be a brace pair @@ -2843,6 +2868,9 @@ ;; position to scan backwards from. It is the position of the "{" of the ;; last element to be removed from `c-state-cache', when that elt is a ;; cons, otherwise nil. + ;; o - CONS-SEPARATED is t when a cons element in `c-state-cache' has been + ;; replaced by its car because HERE lies inside the brace pair represented + ;; by the cons. ;; o - PPS-STATE is the parse-partial-sexp state at PPS-POINT. (save-excursion (save-restriction @@ -2870,6 +2898,7 @@ pos upper-lim ; ,beyond which `c-state-cache' entries are removed scan-back-pos + cons-separated pair-beg pps-point-state target-depth) ;; Remove entries beyond HERE. Also remove any entries inside @@ -2891,7 +2920,8 @@ (consp (car c-state-cache)) (> (cdar c-state-cache) upper-lim)) (setcar c-state-cache (caar c-state-cache)) - (setq scan-back-pos (car c-state-cache))) + (setq scan-back-pos (car c-state-cache) + cons-separated t)) ;; The next loop jumps forward out of a nested level of parens each ;; time round; the corresponding elements in `c-state-cache' are @@ -2907,7 +2937,7 @@ start-point)) (goto-char pos) (while (and c-state-cache - (or (numberp (car c-state-cache)) ; Have we a { at all? + (or (numberp (car c-state-cache)) ; Have we a { at all? (cdr c-state-cache)) (< (point) here)) (cond @@ -2963,7 +2993,7 @@ (setq c-state-cache (cons (cons pair-beg pos) c-state-cache))) - (list pos scan-back-pos pps-state))))) + (list pos scan-back-pos cons-separated pps-state))))) (defun c-remove-stale-state-cache-backwards (here) ;; Strip stale elements of `c-state-cache' by moving backwards through the @@ -3143,10 +3173,13 @@ ;; This function is called from c-after-change. ;; The caches of non-literals: - (if (< here c-state-nonlit-pos-cache-limit) - (setq c-state-nonlit-pos-cache-limit here)) - (if (< here c-state-semi-nonlit-pos-cache-limit) - (setq c-state-semi-nonlit-pos-cache-limit here)) + ;; Note that we use "<=" for the possibility of the second char of a two-char + ;; comment opener being typed; this would invalidate any cache position at + ;; HERE. + (if (<= here c-state-nonlit-pos-cache-limit) + (setq c-state-nonlit-pos-cache-limit (1- here))) + (if (<= here c-state-semi-nonlit-pos-cache-limit) + (setq c-state-semi-nonlit-pos-cache-limit (1- here))) ;; `c-state-cache': ;; Case 1: if `here' is in a literal containing point-min, everything @@ -3160,7 +3193,8 @@ ;; Truncate `c-state-cache' and set `c-state-cache-good-pos' to a value ;; below `here'. To maintain its consistency, we may need to insert a new ;; brace pair. - (let ((here-bol (c-point 'bol here)) + (let (open-paren-in-column-0-is-defun-start + (here-bol (c-point 'bol here)) too-high-pa ; recorded {/(/[ next above here, or nil. dropped-cons ; was the last removed element a brace pair? pa) @@ -3231,6 +3265,7 @@ ;; This function might do hidden buffer changes. (let* ((here (point)) (here-bopl (c-point 'bopl)) + open-paren-in-column-0-is-defun-start strategy ; 'forward, 'backward etc.. ;; Candidate positions to start scanning from: cache-pos ; highest position below HERE already existing in @@ -3240,6 +3275,7 @@ ; are no open parens/braces between it and HERE. bopl-state res + cons-separated scan-backward-pos scan-forward-p) ; used for 'backward. ;; If POINT-MIN has changed, adjust the cache (unless (= (point-min) c-state-point-min) @@ -3252,13 +3288,15 @@ ;; SCAN! (cond - ((eq strategy 'forward) + ((memq strategy '(forward back-and-forward)) (setq res (c-remove-stale-state-cache start-point here here-bopl)) (setq cache-pos (car res) scan-backward-pos (cadr res) - bopl-state (car (cddr res))) ; will be nil if (< here-bopl + cons-separated (car (cddr res)) + bopl-state (cadr (cddr res))) ; will be nil if (< here-bopl ; start-point) - (if scan-backward-pos + (if (and scan-backward-pos + (or cons-separated (eq strategy 'forward))) ;scan-backward-pos (c-append-lower-brace-pair-to-state-cache scan-backward-pos here)) (setq good-pos (c-append-to-state-cache cache-pos here)) -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 03 18:20:28 2014 Received: (at 16910) by debbugs.gnu.org; 3 Mar 2014 23:20:28 +0000 Received: from localhost ([127.0.0.1]:49493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WKc9s-0000xv-Fk for submit@debbugs.gnu.org; Mon, 03 Mar 2014 18:20:28 -0500 Received: from mail.99main.com ([208.28.184.11]:60246) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WKc9o-0000xh-QX for 16910@debbugs.gnu.org; Mon, 03 Mar 2014 18:20:26 -0500 Received: from practicealgebra.net (65.172.152.38.dsl.99main.com [65.172.152.38]) by mail.99main.com (8.12.8+Sun/8.12.8) with ESMTP id s23NKNuN002821; Mon, 3 Mar 2014 18:20:23 -0500 (EST) Date: Mon, 3 Mar 2014 18:25:32 -0500 From: Andrew Warshall To: Alan Mackenzie Subject: Re: bug#16910: 24.3; c++ mode: autoindent stops working Message-ID: <20140303182532.22695c27@practicealgebra.net> In-Reply-To: <20140302143800.GB3768@acm.acm> References: <20140302143800.GB3768@acm.acm> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.22; i686-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16910 Cc: 16910@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Sun, 2 Mar 2014 14:38:00 +0000 Alan Mackenzie wrote: > Hi, Andrew. > > > Hi- > > > While editing files in c++ mode, autoindent sometimes stops working > > after a while. Saving, making a trivial change and then immediately > > reverting sometimes solves the problem, but usually not. I'm afraid > > I can't give a recipe, since I myself don't understand when it > > happens; it seems unpredictable. But (some of) the error messages > > from emacs (which appear in the echo area) are below. > > > -Andrew Warshall > Hi- The patch seems to work so far. Thanks, Andrew Warshall From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 06 11:59:18 2014 Received: (at control) by debbugs.gnu.org; 6 Mar 2014 16:59:18 +0000 Received: from localhost ([127.0.0.1]:53525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WLbdd-0008SE-F3 for submit@debbugs.gnu.org; Thu, 06 Mar 2014 11:59:17 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:38462) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WLbdb-0008S6-CM for control@debbugs.gnu.org; Thu, 06 Mar 2014 11:59:15 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1WLbda-0000z2-OY for control@debbugs.gnu.org; Thu, 06 Mar 2014 11:59:14 -0500 Date: Thu, 06 Mar 2014 11:59:14 -0500 Message-Id: Subject: control message for bug 16910 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) close 16910 24.4 From unknown Thu Aug 14 12:23:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 04 Apr 2014 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator