Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add to prelude core #291

Merged
merged 3 commits into from

2 participants

@Abizern

I've added prelude-smart-open-line-above to prelude-core.

Sometimes - it's useful to be able to add code to the line above the one you are currently working on.

Abizern added some commits
@Abizern Abizern Add prelude-smart-open-line-above defun to prelude-core.el
Opens a line above the current line and indents it.

The counterpart to prelude-smart-open-line (bound to S-ret)

The new defun is bound to C-S-ret and is documented in the README.
773578d
@Abizern Abizern Minor corrections to doc lines in prelude-core
They sound better grammatically.
d4bf21e
core/prelude-core.el
@@ -79,6 +79,15 @@
(indent-rigidly (point-min) (point-max) arg)
(clipboard-kill-ring-save (point-min) (point-max)))))
+(defun prelude-smart-open-line-above ()
+ "Insert an empty line above the current line.
+Position the cursor at it's beginning, according to the current mode"
+ (interactive)
+ (beginning-of-line)
@bbatsov Owner
bbatsov added a note

This function could be reduced to (previous-line)(prelude-smart-open-line).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Abizern

Thanks for that - I've used your suggestion.

@bbatsov bbatsov merged commit aed6e3b into bbatsov:master
@Abizern Abizern deleted the Abizern:add-to-prelude-core branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 31, 2013
  1. @Abizern

    Add prelude-smart-open-line-above defun to prelude-core.el

    Abizern authored
    Opens a line above the current line and indents it.
    
    The counterpart to prelude-smart-open-line (bound to S-ret)
    
    The new defun is bound to C-S-ret and is documented in the README.
  2. @Abizern

    Minor corrections to doc lines in prelude-core

    Abizern authored
    They sound better grammatically.
  3. @Abizern

    Simplify implementation of prelude-smart-open-line-above

    Abizern authored
    As suggested by bbatsov.
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 2 deletions.
  1. +1 −0  README.md
  2. +9 −2 core/prelude-core.el
  3. +1 −0  core/prelude-mode.el
View
1  README.md
@@ -209,6 +209,7 @@ Keybinding | Description
-------------------|------------------------------------------------------------
<kbd>C-c o</kbd> | Open the currently visited file with an external program.
<kbd>C-c g</kbd> | Search in Google for the thing under point (or an interactive query).
+<kbd>C-S-RET</kbd> | Insert an empty line above the current line and indent it properly
<kbd>S-RET</kbd> | Insert an empty line and indent it properly (as in most IDEs).
<kbd>C-S-up</kbd> | Move the current line up.
<kbd>C-S-down</kbd> | Move the current line down.
View
11 core/prelude-core.el
@@ -79,6 +79,13 @@
(indent-rigidly (point-min) (point-max) arg)
(clipboard-kill-ring-save (point-min) (point-max)))))
+(defun prelude-smart-open-line-above ()
+ "Insert an empty line above the current line.
+Position the cursor at it's beginning, according to the current mode"
+ (interactive)
+ (previous-line)
+ (prelude-smart-open-line))
+
(defun prelude-smart-open-line ()
"Insert an empty line after the current line.
Position the cursor at its beginning, according to the current mode."
@@ -87,13 +94,13 @@ Position the cursor at its beginning, according to the current mode."
(newline-and-indent))
(defun prelude-move-line-up ()
- "Move up the current line."
+ "Move the current line up."
(interactive)
(transpose-lines 1)
(forward-line -2))
(defun prelude-move-line-down ()
- "Move down the current line."
+ "Move the current line down."
(interactive)
(forward-line 1)
(transpose-lines 1)
View
1  core/prelude-mode.el
@@ -39,6 +39,7 @@
(define-key map (kbd "C-c g") 'prelude-google)
;; mimic popular IDEs binding, note that it doesn't work in a terminal session
(define-key map [(shift return)] 'prelude-smart-open-line)
+ (define-key map [(control shift return)] 'prelude-smart-open-line-above)
(define-key map [(control shift up)] 'prelude-move-line-up)
(define-key map [(control shift down)] 'prelude-move-line-down)
(define-key map (kbd "C-c n") 'prelude-cleanup-buffer)
Something went wrong with that request. Please try again.