From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Skip Montanaro Newsgroups: gmane.emacs.help Subject: Can I have my electric cake and eat it too? (Python mode question) Date: Mon, 30 Jan 2017 15:23:04 -0600 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1485811428 2300 195.159.176.226 (30 Jan 2017 21:23:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 30 Jan 2017 21:23:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 30 22:23:44 2017 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 1cYJQN-0000GP-GO for geh-help-gnu-emacs@m.gmane.org; Mon, 30 Jan 2017 22:23:43 +0100 Original-Received: from localhost ([::1]:35133 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYJQP-0005BI-K5 for geh-help-gnu-emacs@m.gmane.org; Mon, 30 Jan 2017 16:23:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYJPr-0005AE-4Q for help-gnu-emacs@gnu.org; Mon, 30 Jan 2017 16:23:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYJPm-0003j4-U6 for help-gnu-emacs@gnu.org; Mon, 30 Jan 2017 16:23:11 -0500 Original-Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:35710) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cYJPm-0003iw-MG for help-gnu-emacs@gnu.org; Mon, 30 Jan 2017 16:23:06 -0500 Original-Received: by mail-wm0-x234.google.com with SMTP id b65so51626065wmf.0 for ; Mon, 30 Jan 2017 13:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=tHK7fSADSCvFrdqQk/4kjGa1tZa7pUpMho4BKKVJask=; b=oXeQEq6VUOmKSjljwwyIEQ9mwoEOYgmJqusdZkGnhEAOc64/AQY1nMom7lgegWMGO8 4CEkEUGOeRyRa51Q5SHCy6F8Aa9sF6HtFlCr363apzaNDxshJHL5Av1BXUOKOCVD0dnr puhtyXEGyB0+xjuSl+8sSSQnH2CguDUySMljAlevwz7+RX1hJ0GK+pu/09Wn3uHzQa+s jV2sB6A3sHtBX5Kn8abFdRcQ0fXcOkjdBAIFKcOHWJwz3OPIfLeI3oGwgDYouk90zePb qY4zx4WOwHhwbUsugZrsEZGASXmkc2LsIjEP7pib0hhr90CrRLaCmg5tKBnnKh8hCa+h A5qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=tHK7fSADSCvFrdqQk/4kjGa1tZa7pUpMho4BKKVJask=; b=ftwCvGkMALoI8PTrRZom8Urp7e0Qtm8sd0lkTHd0Fjlx8B3tfoN803RiTILwj8T7Ax WZeNEBE0g4fKaOcEjQX7QZTUuq6tIk23Q9i086ruZOOyoyeuEFdZ1q8QX8x1dW+lq7qQ WCK0Aso+9QQbwEmrUYscD5swj75C4oCtGdKj2+oaTn63sXOpQzrvIoHj1yCrywEQJEwK h3GGF76XYNlYi4wOpXu4fWT4HFuVJ3kTTNBhVwrEnrugSK8S0Z1dQFuJLmpGrjRC44l6 pUJwMq6cQN4EfUY86fPOU6uyhJb8GqtA+EBnUOcBOLPXuDz8Gdz0qimBnG6xhPPwW7bU Thzg== X-Gm-Message-State: AIkVDXKMw7ZnyT3k7KoJy24boOoToLipTUyx/Zez5emWEA8agFQtuM8iLWUc+yW8wttUlpKXgfn7JhqPRVDeMg== X-Received: by 10.223.133.164 with SMTP id 33mr20813913wrt.39.1485811385371; Mon, 30 Jan 2017 13:23:05 -0800 (PST) Original-Received: by 10.28.224.86 with HTTP; Mon, 30 Jan 2017 13:23:04 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::234 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:112206 Archived-At: I was annoyed that entering a colon at the end of a line in a Python buffer didn't automatically reindent the line (say, entering a colon after typing "else" didn't line it up with its matching "if"). After a little reading, I figured out I needed to call (electric-indent-mode) in my python-mode-hook. Done. Now, however, C-j (bound to electric-newline-and-maybe-indent) no longer indents. The doc for that function says, "Insert a newline. If `electric-indent-mode' is enabled, that's it..." Is there no way to have my cake (colon reindents the current line) and eat it too (C-j inserts a newline *and* reindents the line)? I've been programming in Python for over 20 years (my how time flies). (re)Indenting lines is a really common activity. Having it happen automatically only about half the time seems suboptimal. If there was an electric-newline-and-indent function, I could just bind it to C-j in my python-mode-hook. It obviously won't be hard to write (just remove the mode check), but maybe I'm missing some good reason why you wouldn't always want to reindent after a newline while entering Python code. My environment is currently Emacs 24.5.1 on RH Linux, using the Emacs which apparently comes with Continuum Analytics' Anaconda distro. Thx, Skip Montanaro