aboutsummaryrefslogtreecommitdiffstats
path: root/local-lib
diff options
context:
space:
mode:
authorjason2017-06-30 18:42:24 -0600
committerjason2017-06-30 18:46:07 -0600
commitbfb30ab9ff71bc63d95c4eabbf9add6dd42cb460 (patch)
treee01d336967132199498858390b6470eaf7b88240 /local-lib
parentd471ae48795673ed03f35d3b50b4eb4082457c79 (diff)
downloaddotemacs-bfb30ab9ff71bc63d95c4eabbf9add6dd42cb460.tar.gz
dotemacs-bfb30ab9ff71bc63d95c4eabbf9add6dd42cb460.zip
Treat whitespace as a word when removing by word
Diffstat (limited to 'local-lib')
-rw-r--r--local-lib/zzq-funcs.el37
1 files changed, 37 insertions, 0 deletions
diff --git a/local-lib/zzq-funcs.el b/local-lib/zzq-funcs.el
index 3d38b11..c1bb4a9 100644
--- a/local-lib/zzq-funcs.el
+++ b/local-lib/zzq-funcs.el
@@ -14,4 +14,41 @@
14 "Convert the output of (current-time) to epoch in milliseconds" 14 "Convert the output of (current-time) to epoch in milliseconds"
15 (truncate (* 1000 (+ (+ (* (nth 0 time) (expt 2 16)) (nth 1 time)) (* (nth 2 time) (expt 10 -6)))))) 15 (truncate (* 1000 (+ (+ (* (nth 0 time) (expt 2 16)) (nth 1 time)) (* (nth 2 time) (expt 10 -6))))))
16 16
17(defun kill-whitespace ()
18 "Remove all whitepspace seperating two non-whitespace characters"
19 (interactive "*")
20 (save-excursion
21 (save-restriction
22 (progn
23 ;; Move backward to the last non-whitespace character
24 (re-search-backward "[^ \t\r\n]" nil)
25 ;; Then search for all whitespace to the next non-whitespace character
26 (re-search-forward "[ \t\r\n]+")
27 ;; Replace everything from the last match (all whitespace) with nothing
28 (replace-match "")))))
29
30(defun maybe-backward-kill-word (arg)
31 "Removes all whitespace backward up to the next non-whitespace character. If
32the first character left of the cursor is not whitespace then remove the word. I
33like to bind this to C-backspace."
34 (interactive "p")
35 (if (looking-back "[ \t\r\n]")
36 (let ((start (point)))
37 (re-search-backward "[^ \t\r\n]" nil)
38 (forward-char 1)
39 (delete-region (point) start))
40 (backward-kill-word arg)))
41
42(defun maybe-kill-word (arg)
43 "Removes all whitespace up to the next non-whitespace character. If the first
44character right of the cursor is not whitespace then remove the word. I like to
45bind this to C-delete and M-d"
46 (interactive "p")
47 (if (looking-at "[ \t\r\n]")
48 (let ((start (point)))
49 (re-search-forward "[\t\r\n]+" nil)
50 (delete-region (point) start))
51 (kill-word arg)))
52
53
17(provide 'zzq-funcs) 54(provide 'zzq-funcs)