diff options
author | Alan Pearce | 2013-04-28 20:54:18 +0100 |
---|---|---|
committer | Alan Pearce | 2013-04-28 20:54:18 +0100 |
commit | e7657d6ba54ad5714657cff9be86ec416d342a4c (patch) | |
tree | 50a2fada14e8d5f76ef890c4b860fbdd4faf812f /emacs/elisp/electric-return.el | |
parent | 6bec14c2d18c915a3510aba36a37e78a8b83170f (diff) | |
download | nixfiles-e7657d6ba54ad5714657cff9be86ec416d342a4c.tar.lz nixfiles-e7657d6ba54ad5714657cff9be86ec416d342a4c.tar.zst nixfiles-e7657d6ba54ad5714657cff9be86ec416d342a4c.zip |
Migrate repository from mercurial without history
Diffstat (limited to 'emacs/elisp/electric-return.el')
-rw-r--r-- | emacs/elisp/electric-return.el | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/emacs/elisp/electric-return.el b/emacs/elisp/electric-return.el new file mode 100644 index 00000000..fcbebb3c --- /dev/null +++ b/emacs/elisp/electric-return.el @@ -0,0 +1,16 @@ +(defvar electrify-return-match + "[\]}\)\"]" + "If this regexp matches the text after the cursor, do an \"electric\" + return.") +(defun electrify-return-if-match (arg) + "If the text after the cursor matches `electrify-return-match' then + open and indent an empty line between the cursor and the text. Move the + cursor to the new line." + (interactive "P") + (let ((case-fold-search nil)) + (if (looking-at electrify-return-match) + (save-excursion (newline-and-indent))) + (newline arg) + (indent-according-to-mode))) +;; Using local-set-key in a mode-hook is a better idea. +;(global-set-key (kbd "RET") 'electrify-return-if-match) \ No newline at end of file |