From unknown Sat Sep 13 11:13:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12527: 24.2; idented preprocessor directives confusing cc-mode indent Resent-From: Kevin Burge Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Sep 2012 19:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 12527 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 12527@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.134877483917127 (code B ref -1); Thu, 27 Sep 2012 19:41:01 +0000 Received: (at submit) by debbugs.gnu.org; 27 Sep 2012 19:40:39 +0000 Received: from localhost ([127.0.0.1]:59273 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1THJwr-0004SB-WB for submit@debbugs.gnu.org; Thu, 27 Sep 2012 15:40:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49915) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1THIje-0002dm-S1 for submit@debbugs.gnu.org; Thu, 27 Sep 2012 14:22:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THIjY-0000AA-Kz for submit@debbugs.gnu.org; Thu, 27 Sep 2012 14:22:49 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:46952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THIjY-0000A6-GO for submit@debbugs.gnu.org; Thu, 27 Sep 2012 14:22:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THIjX-0002Rx-7P for bug-gnu-emacs@gnu.org; Thu, 27 Sep 2012 14:22:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THIjS-00009q-2M for bug-gnu-emacs@gnu.org; Thu, 27 Sep 2012 14:22:47 -0400 Received: from mail-la0-f41.google.com ([209.85.215.41]:62699) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THIjR-00009j-Qp for bug-gnu-emacs@gnu.org; Thu, 27 Sep 2012 14:22:41 -0400 Received: by lagp5 with SMTP id p5so486173lag.0 for ; Thu, 27 Sep 2012 11:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=9se6dVB1XHG3Bz36xR5xD5iOZ2WZdfwfRvUMdEifJFU=; b=gsElfbWysKmJsCJKejLhbMbOdR0hJTiI+WeXB519eSisPDlMkjTGJrx4K3Tk1CvgkU /4jmq8d2hNKRupO72N+gHka0D9p90b02msayRnjhG9ogH0IECLZgdnYMjnXw9D/9PpAa 4vUTQIWzx4wxDVKsmmkPOOCcMOOjTdXPpKgJdVX4tJileLMNx8usf/i94NZSeVzegWji FYfnj3tUkO2ENkxfmLirv8+udWLYxh69WhkNiFENE58KBKYthRsMqSMLznmvEfkDh8QO Wp3HOWIaHeGDPGMHoEsAEhQhf8kOTGQZ+6ngunULwo9Bp+2r0r9M+obja9Ci7GAEf2v+ 8xrg== MIME-Version: 1.0 Received: by 10.152.148.34 with SMTP id tp2mr3982147lab.15.1348770160161; Thu, 27 Sep 2012 11:22:40 -0700 (PDT) Received: by 10.112.108.71 with HTTP; Thu, 27 Sep 2012 11:22:39 -0700 (PDT) Date: Thu, 27 Sep 2012 13:22:39 -0500 Message-ID: From: Kevin Burge Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.1 (------) X-Mailman-Approved-At: Thu, 27 Sep 2012 15:40:36 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) Summary: Indenting the preprocessor blocks at least 1 space completely throws off the cc-mode indentation for anything after the preprocessor block. To reproduce: Create the simple file "test.cpp": === int f(void) { #if defined(A) printf("test\n"); #endif if (test) { int i = 0; } } === IMPORTANT: "#if.....#endif" block MUST be indented at least 1 space. If you navigate inside the "if (test)" block and hit tab, it un-indents the line, and any lines after it, to the end of the file. If you reindent the entire file, it works just fine, because the indented preprocessor directives, which works around the problem. You have to play around with this, too. There are certain variations of the #if line that affect the behavior. And, each time you test, you MUST re-open the file, because the caching seems to completely throw it off. I.e. if you change the #if block to === #if 0 printf("test\n"); #endif === And re-load the file, then try to indent the "if (test)" block, it does what it should. Also, changing it to (and reloading): === #if A printf("test\n"); #endif === Is sufficient to break it again. So, it seems like whatever follows the #if affects the behavior. Note: I ran with emacs -q, so, it's not processing any of my configuration. I have hundreds of thousands of lines of codes that use indented preprocessor directives, so making all those changes is not really an option for us. =========================== In GNU Emacs 24.2.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars) of 2012-09-27 on kevin Windowing system distributor `CentOS', version 11.0.11006000 Configured using: `configure '--prefix=/usr/local/emacs24' '--with-x-toolkit=lucid'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: nil value of $XMODIFIERS: @im=none locale-coding-system: nil default enable-multibyte-characters: t Major mode: C++/l Minor modes in effect: 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: C-x C-f t e s t . c p C-n C-n C-/ C-n C-n C-/ C-x C-s C-n C-n C-a C-n C-a C-n C-a C-p C-p C-p C-p C-p C-p C-p C-p C-p C-SPC C-n C-n C-n C-n C-n C-n C-n C-n C-n M-w M-x b u r e p o r t - b u g Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Undo! [2 times] (No changes need to be saved) byte-code: Beginning of buffer [2 times] Mark set Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message 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 cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs regexp-opt time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image fringe 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 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 x-toolkit x multi-tty emacs) From unknown Sat Sep 13 11:13:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12527: 24.2; idented preprocessor directives confusing cc-mode indent Resent-From: Alex Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 14 Aug 2016 20:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12527 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: To: Kevin Burge Cc: 12527@debbugs.gnu.org Received: via spool by 12527-submit@debbugs.gnu.org id=B12527.147120791922115 (code B ref 12527); Sun, 14 Aug 2016 20:52:02 +0000 Received: (at 12527) by debbugs.gnu.org; 14 Aug 2016 20:51:59 +0000 Received: from localhost ([127.0.0.1]:57551 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZ2Nz-0005kZ-EC for submit@debbugs.gnu.org; Sun, 14 Aug 2016 16:51:59 -0400 Received: from mail-it0-f44.google.com ([209.85.214.44]:38716) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZ2Nx-0005kF-BB; Sun, 14 Aug 2016 16:51:57 -0400 Received: by mail-it0-f44.google.com with SMTP id i128so1155463itf.1; Sun, 14 Aug 2016 13:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=+Z9PFzVdEe2VIQvDHF+Ri4zAwF9s9g3wgtbb1BA8gtE=; b=tEOvm7w3eKkEIjG9iVU2UPwIER8e6M7OHvBKBp0QO1ZW3co7/DFlbaeqkr+B29ml9u g0mXsB/Hj9D8GIfFHnh2PvLhC5iFseddWRg35NnZYHmUWlt7w47ay5PmfhJenQmQCo71 oioCbmK7zyqR9kF1idrR7BBVu1alp/mzgLPDUi/u3Phiuw6Q8b/oPCWuvHWV7h7H5rfE Y5abaS4eoRPa3LBt2rll5Ne6hXYltXg/0zWBeZk96bcvSoLOAEdJDUNDzGY65NY5UvAg 5HbimOU8hVAMGVwSKmFy1oHpDg4eTlae7EEVQ2XiPbpEEw0S8BpfGq/k2iRoRRx8rmKF On+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=+Z9PFzVdEe2VIQvDHF+Ri4zAwF9s9g3wgtbb1BA8gtE=; b=jqYmFtRO13dRB5t/knbS5vnTlj8mcLGXxXiFNWTAePKeyL8oxLXdwgJ2JSMPzelr2Z ZTtNNG/85YBVKVjVpcits7JFFIxSR53Kynoy1xZud8s+94vE7NHKLNlGXvEtBKkbSRV8 GON7l39j7PyXuv6h2rB4NRzrhTwBOORU23nREF2uTM6RoK8Bjzg2/JqrRnfycr3HtUW/ 6MszYxcr3D8TlliYH1X9eYPWEm83AIDe2DmDkcPsw9jEMy3SePLABnG38yABFKKHJomW Tl0AUQPYWLM3QZUIvHOV6n+SHrXwXNlpLydRKwe000m3iQOo2m9MiKElvCvu18CpKN1/ kFUg== X-Gm-Message-State: AEkoouubY8T8SGbt2ZLTiFsS3XCFQX44+9a01yvdfRBA1cC8WUC43HDbq3NMQHMSy1f+pg== X-Received: by 10.36.76.16 with SMTP id a16mr10083947itb.86.1471207911656; Sun, 14 Aug 2016 13:51:51 -0700 (PDT) Received: from lylat (S01061859339e9903.ss.shawcable.net. [174.2.107.88]) by smtp.gmail.com with ESMTPSA id e196sm8370719ioe.3.2016.08.14.13.51.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Aug 2016 13:51:51 -0700 (PDT) From: Alex References: Date: Sun, 14 Aug 2016 14:51:49 -0600 In-Reply-To: (Kevin Burge's message of "Thu, 27 Sep 2012 13:22:39 -0500") Message-ID: <87eg5rqdju.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 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 (/) close 12527 24.5 quit Kevin Burge writes: > Summary: Indenting the preprocessor blocks at least 1 space completely > throws off the cc-mode indentation for anything after the > preprocessor block. > > To reproduce: Create the simple file "test.cpp": > > === > int f(void) { > #if defined(A) > printf("test\n"); > #endif > > if (test) { > int i = 0; > } > } > === > > IMPORTANT: "#if.....#endif" block MUST be indented at least 1 space. > > If you navigate inside the "if (test)" block and hit tab, it > un-indents the line, and any lines after it, to the end of the file. > If you reindent the entire file, it works just fine, because the > indented preprocessor directives, which works around the problem. > > You have to play around with this, too. There are certain variations > of the #if line that affect the behavior. And, each time you test, > you MUST re-open the file, because the caching seems to completely > throw it off. > > I.e. if you change the #if block to > > === > #if 0 > printf("test\n"); > #endif > === > > And re-load the file, then try to indent the "if (test)" block, it > does what it should. Also, changing it to (and reloading): > > === > #if A > printf("test\n"); > #endif > === > > Is sufficient to break it again. So, it seems like whatever follows > the #if affects the behavior. This appears to work fine in 24.5.