forked from gahag-config/dotemacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
defuns.el
93 lines (63 loc) · 2.68 KB
/
defuns.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
;; ctags ---------------------------------------------------------------------------------
(defun create-tags (dir-name)
"Create tags file."
(interactive "DDirectory: ")
(let ((dir (directory-file-name dir-name)))
(shell-command (format "%s -e -R -f \"%s\"/TAGS \"%s\"" ctags-program dir dir))))
;; desktops ------------------------------------------------------------------------------
(defun desktop-save-in-desktop-dir-release ()
"Save the desktop in directory `desktop-dirname' and release."
(interactive)
(if desktop-dirname
(desktop-save desktop-dirname t)
(call-interactively 'desktop-save))
(message "Desktop saved in %s" (abbreviate-file-name desktop-dirname)))
(defun desktop-create (desktop-name)
"Create new desktop"
(interactive "sDesktop name: ")
(let ((desktop-dir (concat desktop-home desktop-name)))
(desktop-save-in-desktop-dir-release)
(make-directory desktop-dir)
(desktop-save desktop-dir)
(desktop-change-dir desktop-dir)))
(defun desktop-switch (dir-name)
"Switch to desktop"
(interactive (list (read-directory-name "Directory: "
desktop-home)))
(desktop-save-in-desktop-dir)
(desktop-change-dir dir-name))
;; indent --------------------------------------------------------------------------------
(defun set-tab-size (size)
"Set the tab size for the current buffer."
(interactive "NSize: ") ;; Number
(setq-local tab-width size)
(setq-local tab-stop-list (number-sequence 0 200 size))
(setq-local c-basic-offset size)
(setq-local haskell-indent-offset size))
(defun align-whitespace (size)
"Align columns delimited by whitespace."
(interactive "NSize: ") ;; Number
(align-regexp (region-beginning) (region-end) "\\(\\s-*\\)\\s-" 1 size 't))
;; etc -----------------------------------------------------------------------------------
(defun find-temp-file (filename)
"Find new temporary file"
(interactive "sFile name: ") ;; String
(find-file (make-temp-file filename)))
(defun context-kill-buffer (arg)
"Kill buffer, taking gnuclient into account."
(interactive "p")
(if (daemonp)
(condition-case nil
(server-edit)
(error (kill-buffer (current-buffer)))))
(kill-buffer (current-buffer)))
(defun shell-command-on-buffer ()
(interactive)
(shell-command-on-region (point-min)
(point-max)
(read-shell-command "Shell command on buffer: ")
(current-buffer)))
(defun reload-local-variables ()
"reload file local variables for the current buffer"
(interactive)
(hack-local-variables))