-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.el
102 lines (97 loc) · 3.64 KB
/
functions.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
(defun comment-uncomment-line-or-region (&optional arg)
"comments or uncomments a line according to state before.
With key pressed, continues with next line.
With arg copies and reinserts last line."
(interactive "*P")
(comment-normalize-vars)
(let* ((arg (if arg (prefix-numeric-value arg) 0))
(start (if (and mark-active transient-mark-mode)
(region-beginning)
(line-beginning-position)))
(end (if (and mark-active transient-mark-mode)
(region-end)
(line-end-position)))
(line-to-comment-or-uncomment (buffer-substring-no-properties
(or
start (line-beginning-position))
(or end
(line-end-position)))))
(cond ((eq 1 arg) ;; comment and reinsert
(comment-or-uncomment-region start end)
(indent-according-to-mode)
(end-of-line)
(newline)
(insert line-to-comment-or-uncomment)
(indent-according-to-mode))
((< 1 arg) ;; comment as many lines are given
(while (<= 1 (prefix-numeric-value arg))
(comment-or-uncomment-region (line-beginning-position)
(line-end-position))
(indent-according-to-mode)
(end-of-line)
(forward-line 1)
;; (indent-according-to-mode)
(setq arg (1- arg))))
((and start end)
(comment-or-uncomment-region start end)
(indent-according-to-mode)
(if (eobp)
(progn (newline)
(indent-according-to-mode))
(progn
(forward-line 1)
(indent-according-to-mode))))
(t ;; just one line
(progn (comment-or-uncomment-region (line-beginning-position)
(line-end-position))
(indent-according-to-mode)
(if (eobp)
(progn (newline)
(indent-according-to-mode))
(progn
(forward-line 1)
(indent-according-to-mode))))))))
(provide 'comment-uncomment-line-or-region)
;;; comment-uncomment-line-or-region.el ends here
(defun move-text-internal (arg)
(cond
((and mark-active transient-mark-mode)
(if (> (point) (mark))
(exchange-point-and-mark))
(let ((column (current-column))
(text (delete-and-extract-region (point) (mark))))
(forward-line arg)
(move-to-column column t)
(set-mark (point))
(insert text)
(exchange-point-and-mark)
(setq deactivate-mark nil)))
(t
(beginning-of-line)
(when (or (> arg 0) (not (bobp)))
(forward-line)
(when (or (< arg 0) (not (eobp)))
(transpose-lines arg))
(forward-line -1)))))
(defun move-text-down (arg)
"Move region (transient-mark-mode active) or current line
arg lines down."
(interactive "*p")
(move-text-internal arg))
(defun move-text-up (arg)
"Move region (transient-mark-mode active) or current line
arg lines up."
(interactive "*p")
(move-text-internal (- arg)))
;; function for transparency
;;(set-frame-parameter (selected-frame) 'alpha '(<active> [<inactive>]))
(set-frame-parameter (selected-frame) 'alpha '(85 50))
(add-to-list 'default-frame-alist '(alpha 85 50))
(eval-when-compile (require 'cl))
(defun toggle-transparency ()
(interactive)
(if (/=
(cadr (frame-parameter nil 'alpha))
100)
(set-frame-parameter nil 'alpha '(85 85))
(set-frame-parameter nil 'alpha '(85 50))))