-
Notifications
You must be signed in to change notification settings - Fork 0
/
notmuch-config.el
260 lines (232 loc) · 9.25 KB
/
notmuch-config.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
(let ((default-directory "/usr/share/emacs/site-lisp/"))
(normal-top-level-add-to-load-path '("."))
(normal-top-level-add-subdirs-to-load-path))
(setq backup-directory-alist '((".*" . "~/.emacs.d/.temp")))
(with-eval-after-load "persp-mode-autoloads"
(setq wg-morph-on nil)
(add-hook 'after-init-hook #'(lambda ()
(progn
(persp-mode 1)
(setq persp-add-buffer-on-after-change-major-mode t)))))
(package-initialize)
(setq package-enable-at-startup nil)
(unless package-archive-contents
(package-refresh-contents))
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(column-number-mode)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(show-paren-mode)
(fringe-mode 0)
(global-subword-mode 1)
(setq auto-save-default nil)
(setq-default truncate-lines t)
(set-display-table-slot standard-display-table 'truncation ? )
(setq comment-style 'multi-line)
(setq comment-style 'extra-line)
(add-to-list 'default-frame-alist '(font . "monospace-11"))
(add-to-list 'default-frame-alist '(fullscreen . fullboth))
(setq next-line-add-newlines nil)
(setq inhibit-startup-screen t)
(fset 'yes-or-no-p 'y-or-n-p)
(setq display-time-default-load-average nil)
(setq display-time-24hr-format t)
(setq display-time-format nil)
(display-time-mode)
(setq scroll-step 1)
(setq hscroll-margin 1)
(setq hscroll-step 1)
(defun link ()
(interactive)
(notmuch-show-stash-mlarchive-link "Lore"))
(defun id ()
(interactive)
(notmuch-show-stash-message-id-stripped))
(defun extract-patch (dir)
(interactive "Ddir: ")
(let ((id (notmuch-show-get-message-id t)))
;; https://github.com/aaptel/notmuch-extract-patch
(shell-command (format "notmuch-extract-patch %s > %s"
(shell-quote-argument (notmuch-id-to-query id))
(shell-quote-argument (concat (expand-file-name dir) id ".patch"))))))
(defun apply-thread-patchset (repo branch)
(interactive "Dgit repo: \nsnew branch name: ")
(let ((tid (notmuch-search-find-thread-id))
(tmp "/tmp/notmuch-patchset"))
;; https://github.com/aaptel/notmuch-extract-patch
(shell-command (format "notmuch-extract-patch %s > %s && ( cd %s && git checkout -b %s && git am %s )"
(shell-quote-argument tid)
(shell-quote-argument tmp)
(shell-quote-argument (expand-file-name repo))
(shell-quote-argument branch)
(shell-quote-argument tmp)))))
(defun delete-current-buffer-file ()
"Removes file connected to current buffer and kills buffer."
(interactive)
(let ((filename (buffer-file-name))
(buffer (current-buffer))
(name (buffer-name)))
(if (not (and filename (file-exists-p filename)))
(ido-kill-buffer)
(when (yes-or-no-p "Are you sure you want to remove this file? ")
(delete-file filename)
(kill-buffer buffer)
(message "File '%s' successfully removed" filename)))))
(defun dos2unix ()
"Convert EOLs from dos to unix"
(interactive)
(goto-char (point-min))
(while (search-forward "\r" nil t) (replace-match "")))
(defun eval-and-replace ()
"Replace the preceding sexp with its value."
(interactive)
(backward-kill-sexp)
(prin1 (eval (read (current-kill 0)))
(current-buffer)))
(defun insert-date ()
"Insert date at point."
(insert (format-time-string "%d/%m/%y-%R")))
(defun smart-tab ()
;; TODO: make this a list of functions
(interactive)
(if (minibufferp)
(minibuffer-complete)
(if mark-active
(indent-region (region-beginning)
(region-end))
(if (and (bound-and-true-p go-mode)
(bound-and-true-p auto-complete-mode))
(ac-complete-go)
(if (looking-at "\\_>")
(dabbrev-expand nil)
(indent-for-tab-command))))))
(defun unix2dos ()
"Convert EOLs from unix to dos"
(interactive)
(goto-char (point-min))
(while (search-forward "\n" nil t) (replace-match "\r\n")))
(defun mailto-compose-mail (mailto-url)
"Parse MAILTO-URL and start composing mail."
(if (and (stringp mailto-url)
(string-match "\\`mailto:" mailto-url))
(progn
(require 'rfc2368)
(require 'rfc2047)
(require 'mailheader)
(let ((hdr-alist (rfc2368-parse-mailto-url mailto-url))
(body "")
to subject
;; In addition to To, Subject and Body these headers are
;; allowed:
(allowed-xtra-hdrs '(cc bcc in-reply-to)))
(with-temp-buffer
;; Extract body if it's defined
(when (assoc "Body" hdr-alist)
(dolist (hdr hdr-alist)
(when (equal "Body" (car hdr))
(insert (format "%s\n" (cdr hdr)))))
(rfc2047-decode-region (point-min) (point-max))
(setq body (buffer-substring-no-properties
(point-min) (point-max)))
(erase-buffer))
;; Extract headers
(dolist (hdr hdr-alist)
(unless (equal "Body" (car hdr))
(insert (format "%s: %s\n" (car hdr) (cdr hdr)))))
(rfc2047-decode-region (point-min) (point-max))
(goto-char (point-min))
(setq hdr-alist (mail-header-extract-no-properties)))
(setq to (or (cdr (assq 'to hdr-alist)) "")
subject (or (cdr (assq 'subject hdr-alist)) "")
hdr-alist
(remove nil (mapcar
#'(lambda (item)
(when (memq (car item) allowed-xtra-hdrs)
(cons (capitalize (symbol-name (car item)))
(cdr item))))
hdr-alist)))
(compose-mail to subject hdr-alist nil nil
(list (lambda (string)
(insert string))
body))))
(compose-mail)))
;; key bindings
(global-set-key (kbd "<C-up>") 'shrink-window)
(global-set-key (kbd "<C-down>") 'enlarge-window)
(global-set-key (kbd "<C-left>") 'shrink-window-horizontally)
(global-set-key (kbd "<C-right>") 'enlarge-window-horizontally)
(global-set-key (kbd "C-x C-k") 'delete-current-buffer-file)
(global-set-key (kbd "C-.") 'mc/mark-next-like-this)
(global-set-key (kbd "C-,") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c mi") 'mc/insert-numbers)
(global-set-key (kbd "C-c rr") 'mc/reverse-regions)
(global-set-key (kbd "C-=") 'er/expand-region)
(global-set-key (vector (list 'control mouse-wheel-down-event)) 'zoom-frm-in)
(global-set-key (vector (list 'control mouse-wheel-up-event)) 'zoom-frm-out)
(global-set-key (kbd "C-c C-z") 'zoom-frm-unzoom)
(global-set-key (kbd "C-c C-e") 'eval-and-replace)
(global-set-key [(control h)] 'delete-backward-char)
(global-set-key [(super h)] 'help-command)
(global-set-key (kbd "C-z") nil)
(global-set-key (kbd "M-j")
(lambda ()
(interactive)
(join-line -1)))
(global-set-key [(tab)] 'smart-tab)
(define-key notmuch-hello-mode-map (kbd "<C-tab>") nil)
(define-key notmuch-show-mode-map (kbd "<C-tab>") nil)
(global-set-key (kbd "<C-tab>") 'awesome-tab-forward)
(global-set-key (kbd "C-S-<iso-lefttab>") 'awesome-tab-backward)
;; ------------------------------------------------------------
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-enabled-themes (quote (tango-dark)))
'(read-file-name-completion-ignore-case t)
'(vc-handled-backends nil)
'(sendmail-program "/usr/bin/msmtp")
'(send-mail-function 'sendmail-send-it)
'(notmuch-fcc-dirs "Sent")
'(notmuch-search-oldest-first nil)
'(notmuch-mua-cite-function 'message-cite-original-without-signature)
'(frame-title-format "notmuch")
'(awesome-tab-common-group-name "notmuch")
'(awesome-tab-cycle-scope 'tabs)
'(awesome-tab-display-sticky-function-name nil)
'(awesome-tab-buffer-groups-function
'(lambda ()
(list
(cond
((string-equal "*notmuch-hello*" (buffer-name)) "notmuch")
((string-equal "*scratch*" (buffer-name)) "notmuch")
((string-equal "*Messages*" (buffer-name)) "emacs")
((string-equal "*Completions*" (buffer-name)) "emacs")
((string-equal "*Help*" (buffer-name)) "emacs")
((string-equal "*Apropos*" (buffer-name)) "emacs")
(t "notmuch")
)))
)
'(notmuch-saved-searches
(quote
((:name "inbox" :query "to:farosas tag:unread")
(:name "qemu-devel" :query "folder:qemu.qemu-devel")
(:name "qemu-ppc" :query "folder:qemu.qemu-ppc")
(:name "kvm-ppc" :query "folder:kvm-ppc")
(:name "linuxppc-dev" :query "folder:linuxppc-dev")
(:name "linuxppc-issues" :query "folder:github")
(:name "kvm" :query "folder:kvm")
(:name "power-port-tune" :query "folder:power-port-tune")
(:name "slof" :query "folder:slof")
(:name "virtiofs" :query "folder:virtiofs")
(:name "skiboot" :query "folder:skiboot")
(:name "linuxppc-uv" :query "folder:uv")
(:name "virtio-dev" :query "folder:virtio-dev")
(:name "libre-soc" :query "folder:libre-soc")
(:name "openbios" :query "folder:openbios")
(:name "sent" :query "folder:Sent")
(:name "recv" :query "folder:INBOX")
)))
)