Comment functions

This commit is contained in:
Henrik Lissner 2014-09-05 17:29:24 -04:00
parent acef486d46
commit ce2ca64b74

View File

@ -1,3 +1,4 @@
;;; Library Defuns ;;;;;;;;;;;;;;;;;;;;;
(defun my/surrounded-p () (defun my/surrounded-p ()
(and (looking-back "[[{(]\s*") (and (looking-back "[[{(]\s*")
(looking-at-p "\s*[]})]")) (looking-at-p "\s*[]})]"))
@ -11,8 +12,7 @@
(defun my/get-line () (defun my/get-line ()
(buffer-substring (line-beginning-position) (line-end-position))) (buffer-substring (line-beginning-position) (line-end-position)))
;;; ;;; Text Defuns ;;;;;;;;;;;;;;;;;;;;;;;;
(defun my.backward-kill-to-bol () (defun my.backward-kill-to-bol ()
(interactive) (interactive)
(evil-delete (point-at-bol) (point))) (evil-delete (point-at-bol) (point)))
@ -28,8 +28,9 @@ afterwards, kill line to column 1."
;; Mimic expandtab in vim ;; Mimic expandtab in vim
(defun my.backward-delete-whitespace-to-column () (defun my.backward-delete-whitespace-to-column ()
"delete back to the previous column of whitespace, or as much whitespace as possible, "Delete back to the previous column of whitespace, or as much
or just one char if that's not possible. If it's at the beginning of the line, join with the previous line." whitespace as possible, or just one char (using `autopair-backspace')
if that's not possible."
(interactive) (interactive)
(if indent-tabs-mode (if indent-tabs-mode
(call-interactively 'backward-delete-char) (call-interactively 'backward-delete-char)
@ -43,18 +44,25 @@ or just one char if that's not possible. If it's at the beginning of the line, j
;; TODO Make inflate/deflate smarter ;; TODO Make inflate/deflate smarter
(defun my.inflate-space-maybe () (defun my.inflate-space-maybe ()
"Checks if point is surrounded by {} [] () delimiters and adds a
space on either side of the point if so."
(interactive) (interactive)
(if (my/surrounded-p) (if (my/surrounded-p)
(progn (insert " ") (save-excursion (insert " "))) (progn (insert " ") (save-excursion (insert " ")))
(insert " "))) (insert " ")))
(defun my.deflate-space-maybe () (defun my.deflate-space-maybe ()
"Checks if point is surrounded by {} [] () delimiters, and deletes
spaces on either side of the point if so. Resorts to
`my.backward-delete-whitespace-to-column' otherwise."
(interactive) (interactive)
(if (my/surrounded-p) (if (my/surrounded-p)
(progn (delete-char -1) (save-excursion (delete-char 1))) (progn (delete-char -1) (save-excursion (delete-char 1)))
(my.backward-delete-whitespace-to-column))) (my.backward-delete-whitespace-to-column)))
(defun my.dumb-indent () (defun my.dumb-indent ()
"Inserts a tab character (or spaces x tab-width). Checks if the
auto-complete window is open."
(interactive) (interactive)
(when (not (ac-menu-live-p)) (when (not (ac-menu-live-p))
(let ((indent-mode indent-tabs-mode)) (let ((indent-mode indent-tabs-mode))
@ -70,9 +78,9 @@ indent the next line."
(evil-ret-and-indent)))) (evil-ret-and-indent))))
(defun my.minibuffer-quit () (defun my.minibuffer-quit ()
"Abort recursive edit. "Abort recursive edit. In Delete Selection mode, if the mark is
In Delete Selection mode, if the mark is active, just deactivate it; active, just deactivate it; then it takes a second \\[keyboard-quit]
then it takes a second \\[keyboard-quit] to abort the minibuffer." to abort the minibuffer."
(interactive) (interactive)
(if (and delete-selection-mode transient-mark-mode mark-active) (if (and delete-selection-mode transient-mark-mode mark-active)
(setq deactivate-mark t) (setq deactivate-mark t)