From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrey Tykhonov Newsgroups: gmane.emacs.help Subject: Break code lines fluently Date: Wed, 12 Mar 2014 07:42:56 +0200 Message-ID: <87wqg0t1jz.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1394603015 8222 80.91.229.3 (12 Mar 2014 05:43:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Mar 2014 05: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 Mar 12 06:43:43 2014 Return-path: Envelope-to: geh-help-gnu-emacs@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 1WNbx6-0005Y9-Ut for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Mar 2014 06:43:41 +0100 Original-Received: from localhost ([::1]:58661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNbx6-00081m-JC for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Mar 2014 01:43:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNbwt-00081V-3y for help-gnu-emacs@gnu.org; Wed, 12 Mar 2014 01:43:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNbwo-0002e2-MT for help-gnu-emacs@gnu.org; Wed, 12 Mar 2014 01:43:27 -0400 Original-Received: from mail-ea0-x22f.google.com ([2a00:1450:4013:c01::22f]:55859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNbwo-0002bM-Eg for help-gnu-emacs@gnu.org; Wed, 12 Mar 2014 01:43:22 -0400 Original-Received: by mail-ea0-f175.google.com with SMTP id d10so4717219eaj.34 for ; Tue, 11 Mar 2014 22:43:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:user-agent:date:message-id:mime-version :content-type; bh=2MBD9zzW5+Vjb1A2fGXCgeKQw1M66W210cQgyYLEDUA=; b=Keq4PYzQyeHn034+nrOJ39nejhE8fn+naKsTvJp015Fz5hxfxFKxJNoLBER/tuvClN JjYC/ZEzg9dV5xm4i52saRi1It+Lu41QPQCs6YToeQ2zc+kzdXLBkfgGu//eIrhY6gwK Z4PtTSYxmXkCpnOtQG6d41fnrinR/t3LoilEXXP+hQXwNFKEbyjpMxdidTX11oa5hd48 SSneHCHaYoPjctcM7HtUKLxSX7cAgcybi6/Sk01L+LIAU3PvQjXKuiMtdYOPw7vKfARq ifAR37fRy+3zo9YnFA5UFYPpyQ4sySesUVJdmfEx727Fxdj3MqVpfN4da2kUnsXCUzS0 b9lw== X-Received: by 10.15.44.202 with SMTP id z50mr1677730eev.81.1394603000971; Tue, 11 Mar 2014 22:43:20 -0700 (PDT) Original-Received: from demi.gmail ([193.84.22.38]) by mx.google.com with ESMTPSA id q44sm65808822eez.1.2014.03.11.22.43.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 11 Mar 2014 22:43:20 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::22f X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96447 Archived-At: Hi all! When I've used Eclipse I liked its default key binding "Shift-Enter" which inserts an empty line (with indentation) after the current line. It is very easy to implement such function in Emacs, please read, if you're interested: http://emacsredux.com/blog/2013/03/26/smarter-open-line/ . I used to use this function. It is, as for me, quite handy while browsing the code to hit "Shift-Enter" and just insert some piece of code. But what I really were missing is having the same line opening command but for elisp. It would be better explain by means of example. Let say I have the following code: (defun test () (let ((test t)) (if test (message "True") (mes|sage "False")))) Point is located in the middle of "message" function. And I would like to insert more code to the `let' form (after the `if'). What I was always doing in such situations, I did always navigate to the appropriate closing bracket (in this case closing bracket of the `if') and hit Enter. (Yes, probably there are more better ways to do that. Please share. It is very interesting to know). Despite the fact that I quite often investigate emacs configurations of others, wiki, documentation and packages only today I found the solution to have possibility to break the lines more fluently. So having such mentioned code I can execute sequentially the command several times and have the following code to be ready to be extended in the right place: (defun test () (let ((test t)) (if test (message "True") (message "False")) |)) (First execution of this command breaks a line for "message", the second execution undos this change, the third execution will break a line for `if', the fourth undos and fifth will break a line for `let'). The command which I just mentioned is the `smart-return' command from the `emacs-smart-return' tiny package which I just recently wrote and which you could find at https://github.com/atykhonov/emacs-smart-return It is a very thin wrapper around `smart-forward' package (Read: https://github.com/magnars/smart-forward.el). This is just very initial version. Thus any comments, suggestions are highly appreciated. With hope that mentioned functionality will be helpful and useful, Andrey. Thanks!