unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Break code lines fluently
@ 2014-03-12  5:42 Andrey Tykhonov
  2014-03-12 10:07 ` Andreas Röhler
  2014-03-12 14:25 ` Drew Adams
  0 siblings, 2 replies; 5+ messages in thread
From: Andrey Tykhonov @ 2014-03-12  5:42 UTC (permalink / raw)
  To: help-gnu-emacs


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!



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-03-13  0:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-12  5:42 Break code lines fluently Andrey Tykhonov
2014-03-12 10:07 ` Andreas Röhler
2014-03-12 14:25 ` Drew Adams
2014-03-12 15:55   ` Drew Adams
2014-03-13  0:14   ` Andrey Tykhonov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).