added function for electric punctuation in text-mode

This commit is contained in:
syl20bnr 2013-02-19 23:13:55 -05:00
parent 943d8e2c36
commit 3942c0d169
2 changed files with 14 additions and 0 deletions

View file

@ -157,4 +157,15 @@ argument makes the windows rotate backwards."
(if dedicated "no longer " "")
(buffer-name))))
;; from http://blog.everythingtastesbetterwithchilli.com/2013/02/18/electric-punctuation-in-emacs/
(defun electric-punctuation ()
"Tidy up whitespace around punctuation: delete any preceding
whitespace and insert one space afterwards. Idea stolen from
the SwiftKey android keyboard."
(interactive)
(when (looking-back "\s+" nil t)
(delete-region (match-beginning 0) (match-end 0)))
(call-interactively 'self-insert-command)
(just-one-space))
(provide 'my-funcs)

View file

@ -12,6 +12,9 @@
; (define-key ac-complete-mode-map (kbd "RET") 'ac-complete)
;; mu4e -----------------------------------------------------------------------
(define-key mu4e-main-mode-map (kbd "q") 'mu4e-quit-session)
;; text-mode ------------------------------------------------------------------
(dolist (punc '(?, ?\; ?.))
(define-key text-mode-map `[,punc] 'electric-punctuation))
;; evil-leader shortcuts ======================================================