(skip-syntax-backward " "))
(delete-region old-point (point))))
-;; TODO: if inside a comment, on enter should continue with comment
-;; (call indent-new-comment-line was M-j)... or is this really useful?
-(defun open-next-line ()
- "Instead of going to the beginning of line, autoindent according
+(defun my-newline (&optional arg)
+ "Call `newline' and autoindent according to the active mode."
-(defun vi-open-next-line (arg)
- "Move to the next line (like vi) and then opens a line."
+(defun my-open-line (arg)
+ "If point is before the beginning of \"code\", open new line,
+keep the cursor at the current line and autoindent.
+If point is in the middle of the line, create a blank line under
+current line, move cursor to this new line and autoindent."
+ (if (<= (point) (save-excursion
(defun forward-line-and-indent (arg)
+ "Move point ARG lines forward and autoindent."
(or (eq 'font-lock-comment-face face)
(eq 'font-lock-comment-delimiter-face face))))
+(defun my-back-to-indentation ()
+ (flet ((beginning-of-line (arg) (beginning-of-visual-line arg)))
(defun my-back-to-indentation-or-beginning ()
"Jump back to indentation of the current line. If already
there, jump to the beginning of current line. If visual mode is
enabled, move according to the visual lines."
- (flet ((my-back-to-indentation
- (flet ((beginning-of-line (arg) (beginning-of-visual-line arg)))
- (if (= (point) (save-excursion
+ (if (= (point) (save-excursion
(defun my-end-of-code-or-line ()
"Move to the end of code. If already there, move to the end of line,