From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478. Date: Sat, 22 Feb 2014 18:27:04 +0000 Message-ID: <20140222182704.GA2639@acm.acm> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1393093850 22705 80.91.229.3 (22 Feb 2014 18:30:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Feb 2014 18:30:50 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 22 19:30:58 2014 Return-path: Envelope-to: ged-emacs-devel@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 1WHHLl-0000aJ-Ht for ged-emacs-devel@m.gmane.org; Sat, 22 Feb 2014 19:30:57 +0100 Original-Received: from localhost ([::1]:50482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHHLl-0006mx-6O for ged-emacs-devel@m.gmane.org; Sat, 22 Feb 2014 13:30:57 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHHLa-0006mo-Q9 for emacs-devel@gnu.org; Sat, 22 Feb 2014 13:30:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WHHLT-0006Qv-FB for emacs-devel@gnu.org; Sat, 22 Feb 2014 13:30:46 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:63248 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHHLT-0006Qh-3T for emacs-devel@gnu.org; Sat, 22 Feb 2014 13:30:39 -0500 Original-Received: (qmail 40748 invoked by uid 3782); 22 Feb 2014 18:30:36 -0000 Original-Received: from acm.muc.de (pD951BBA9.dip0.t-ipconnect.de [217.81.187.169]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 22 Feb 2014 19:30:35 +0100 Original-Received: (qmail 2762 invoked by uid 1000); 22 Feb 2014 18:27:04 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:169815 Archived-At: Hi, Stefan. On Mon, Feb 17, 2014 at 07:11:18PM -0500, Stefan Monnier wrote: > > + ;; In Emacs 24.4 onwards, prevent Emacs's built in electric indentation from > > + ;; messing up CC Mode's, and set `c-electric-flag' if `electric-indent-mode' > > + ;; has been called by the user. > > + (when (boundp 'electric-indent-inhibit) (setq electric-indent-inhibit t)) > > + (when (and (boundp 'electric-indent-mode-has-been-called) > > + (> electric-indent-mode-has-been-called 1)) > > + (setq c-electric-flag electric-indent-mode)) > Could you explain what problem this is trying to avoid? Setting electric-indent-inhibit is intended to protect CC Mode from the dangers of CC Mode's electricity clashing with electric.el's. The other bit takes over the value of c-electric-indent-mode into CC Mode only when it has been set by the user, thus preventing electric.el's default overriding CC Mode's. (As we've already discussed, CC Mode's indentation doesn't work properly with electric indentation disabled.) > > + ;; Emacs has en/disabled `electric-indent-mode'. Propagate this through to > > + ;; each CC Mode buffer. > > + (when (and (boundp 'electric-indent-mode-has-been-called) > > + (> electric-indent-mode-has-been-called 1)) > > + (mapc (lambda (buf) > > + (with-current-buffer buf > > + (when c-buffer-is-cc-mode > > + ;; Don't use `c-toggle-electric-state' here due to recursion. > > + (setq c-electric-flag electric-indent-mode) > > + (c-update-modeline)))) > > + (buffer-list)))) > And could you also explain what this one is trying to avoid? Basically the same thing. It's preventing an inopportune default (as contrasted with an explicit user setting) overriding CC Mode's default. > Stefan -- Alan Mackenzie (Nuremberg, Germany).