blob: fcbebb3c4605d1b9006e71c47275e99d10be25b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)
|