From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Customizing C-mode indentation Date: Wed, 19 Oct 2016 11:42:26 -0700 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1476902615 18423 195.159.176.226 (19 Oct 2016 18:43:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 19 Oct 2016 18:43:35 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 19 20:43:32 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bwvpg-0002qN-Mo for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Oct 2016 20:43:20 +0200 Original-Received: from localhost ([::1]:50419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwvpi-0002DU-Ka for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Oct 2016 14:43:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwvpC-0002DN-OP for help-gnu-emacs@gnu.org; Wed, 19 Oct 2016 14:42:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwvpC-0006Dw-0m for help-gnu-emacs@gnu.org; Wed, 19 Oct 2016 14:42:50 -0400 Original-Received: from mail-yw0-x244.google.com ([2607:f8b0:4002:c05::244]:34637) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bwvpB-0006CW-SG for help-gnu-emacs@gnu.org; Wed, 19 Oct 2016 14:42:49 -0400 Original-Received: by mail-yw0-x244.google.com with SMTP id u124so1118546ywg.1 for ; Wed, 19 Oct 2016 11:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=9dAKL/vtq6jfnezQGiEpwINwmVOZuD1h5sy3LWGsq+Y=; b=YBMVqhQBQds+TNs/sCQYApv92rDKKacYBRVM2MsUT+fI8cIiB1g3RkDVJuM/scIfzq ju2ayiXDOlUl77nbiSIfjyekghG6N/iMzI9EkyYPg3VBFR4YOG0Gt2L7BwxkGHX6e8vM YVKHidUOqoENI9NXhazvlz9Wb1TJVsi0SeAWHsqzo/JeP2U8bf3A0WuAXQ0KXU3Vc82W KvQ1Y+N32Pl3C3NEM42qu7nDDxubLVF0NfF54T2d60bLz12crf/OoarwjINfhj+KA0qn JTVWCRYc/veNbyXyl0lpqnskAKGyJ1BkajA5OjJ8/EfEXnsSOppG04V8V5zZif9Z709v z3xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=9dAKL/vtq6jfnezQGiEpwINwmVOZuD1h5sy3LWGsq+Y=; b=L+LTCWLkAX+f/BvuhQGCo7OJROMLo+F4oU6fDHF3OmlcHbg8y+3oImYrSfM04kNnG9 KC0xcjX6GZC+hVSnDngzkB4JeA9JT83bTB4SvBprWgl3VQmD7ATQfxPtO/J6IF2sMAl6 4QShASn7BU7qGgTuFwwSXRozObuyPWiOe8q86gJdRrQHyry+GeRsmc/irmxzD0zl4efK i8n5bSpOEav4uxJQmsEUVfd633m1m/HoE3ce+8Ad9MkAIJkVxIBiC3TQef59M5i6A7Uo iuBpImzDyBk43ibdttI6LszzCxce2l/dWG/8AwmQzejFbEQedCiJX2uY7eTLARigI4UC XymQ== X-Gm-Message-State: AA6/9RlyEgg/eqPd5+FrKk9j8HYrTBkG3KwYmQLMgyMzVQmvk2hjCKcxQLo82jL9TmZxLxHeMCyNg8DqZblK8A== X-Received: by 10.129.49.129 with SMTP id x123mr7967784ywx.223.1476902567444; Wed, 19 Oct 2016 11:42:47 -0700 (PDT) Original-Received: by 10.37.163.4 with HTTP; Wed, 19 Oct 2016 11:42:26 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4002:c05::244 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111572 Archived-At: Hello Emacsers, I have a question about customizing c-mode's indention, specifically regarding teaching c-mode about loop macros. I have some C code that defines a preprocessor macro like: #define iter_each(iter, v) (void * v; iter_next((iter), v); ) An example use would be: struct iter it; iter_init(&it, data); for iter_each(&it, p) { /* ... */ } However, because the `iter_each' hides the fact that this is a `for' loop, c-mode indents it like this: for iter_each(&it, p) { /* ... */ } What's the best way to teach c-mode the correct way to indent this construct? So far what I've found is `c-special-indent-hook', which works, but I'm wondering if there's a better way I haven't found (e.g. by customizing a regexp, which would be easier to stick in a .dir-locals.el). Thanks John