-
Notifications
You must be signed in to change notification settings - Fork 2
/
wordplay.el
74 lines (66 loc) · 2.28 KB
/
wordplay.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
;;======================================================================
;; Custom Features
;;----------------------------------------------------------------------
;;; duplicate lines
(defun duplicate-current-line()
(interactive)
(beginning-of-line nil)
(let ((b (point)))
(end-of-line nil)
(copy-region-as-kill b (point)))
(beginning-of-line 2)
(open-line 1)
(yank)
(back-to-indentation))
;;----------------------------------------------------------------------
;; duplicate word
(defun duplicate-current-word()
(interactive)
(beginning-of-sexp)
(insert (word-at-point)))
;;----------------------------------------------------------------------
;; additional copy function
(defun kill-ring-save-current-line()
"on point line copy"
(interactive)
(if (use-region-p)
(kill-ring-save (point) (mark))
(kill-new (thing-at-point 'line))))
;;----------------------------------------------------------------------
;; word-sort
;; http://www.emacswiki.org/emacs/SortWords
(defun sort-words (reverse beg end)
"Sort words in region alphabetically, in REVERSE if negative.
Prefixed with negative \\[universal-argument], sorts in
reverse.
The variable `sort-fold-case' determines whether alphabetic
case affects the sort order.
See `sort-regexp-fields'.
"
(interactive "*P\nr")
(sort-regexp-fields reverse "\\w+" "\\&" beg end))
;;----------------------------------------------------------------------
;; popup kill ring
(require 'popup-kill-ring)
(setq repetitive_yank_region_point 0) ;; 0 doesn't exist min is 1
(defun repetitive-yanking()
"yank and yank whats rest are in the kill ring"
(interactive)
(message "last-command: %S" last-command)
(if (string= last-command "yank")
(progn
(undo-only)
(when (= (point) repetitive_yank_region_point)
(progn
(goto-char repetitive_yank_region_mark)
(set-mark-command nil)
(goto-char repetitive_yank_region_point)
(delete-selection-helper "yank")))
(popup-kill-ring))
(progn
(when (use-region-p)
(setq repetitive_yank_region_mark (mark))
(setq repetitive_yank_region_point (point))
(message "%s" repetitive_yank_region_point)
(delete-selection-helper "yank"))
(yank))))