1 ;; Added by Package.el. This must come before configurations of
2 ;; installed packages. Don't delete this line. If you don't want it,
3 ;; just comment it out by adding a semicolon to the start of the line.
4 ;; You may delete these explanatory comments.
7 (add-to-list 'load-path "~/.emacs.d/lisp/")
9 ;; Use a dark theme now
10 ;(load-theme 'wheatgrass)
13 ;;(load-theme 'leuven t)
14 (require 'modus-themes)
15 (setq modus-themes-mixed-fonts t)
16 (load-theme 'modus-operandi t)
18 (define-key global-map (kbd "<f5>") #'modus-themes-toggle)
21 (setq completion-styles '(orderless basic)
22 completion-category-overrides '((file (styles basic partial-completion))))
24 ;; follow links to version-controlled files without confirming
27 ;; ESS - for working in R
28 (autoload 'R-mode "ess-site.el" "Major mode for editing R source." t)
29 (setq load-path (cons "/usr/share/emacs/site-lisp/ess" load-path))
30 (load "/usr/share/emacs/site-lisp/ess/lisp/ess-site")
31 (setq inferior-julia-program-name "/usr/bin/julia")
33 ;; enable autocomplete
34 (add-hook 'after-init-hook 'global-company-mode)
38 ;; Automatically flow lines based on window width and use
39 ;; variable width fonts in org-mode.
40 (add-hook 'org-mode-hook 'visual-line-mode)
41 (add-hook 'org-mode-hook 'variable-pitch-mode)
44 (load "auctex.el" nil t t)
45 (load "preview-latex.el" nil t t)
47 ;; org-mode support for R and LaTeX
48 (org-babel-do-load-languages
49 'org-babel-load-languages
52 ;; Security risk - This is somewhat ill-advised it appears
53 (setq org-confirm-babel-evaluate nil)
55 ;; Automatically switch to various modes
57 '(("\\.mdwn\\'" . markdown-mode)
58 ("\\.md\\'" . markdown-mode)
59 ("\\.yarn\\'" . markdown-mode)
60 ("\\.js\\'" . js-mode)
61 ("\\.json\\'" . js-mode)
62 ("Makefile" . makefile-mode)
63 ("README" . markdown-mode)
64 ("NEWS" . markdown-mode)
65 ("COMMIT_EDITMSG\\'" . text-mode)
66 ("\\.html\\'" . html-mode)
67 ("\\.css\\'" . css-mode)
68 ("\\.yaml\\'" . yaml-mode)
69 ("\\.yml\\'" . yaml-mode)
70 ("\\.ick\\'" . yaml-mode)
71 ("\\.py\\'" . python-mode)
73 ("\\.org\\'" . org-mode)
74 ("\\.tex\\'" . latex-mode)
75 ("\\.sh\\'" . shell-script-mode)
76 ("\\.hs\\'" . haskell-mode)
77 ("\\.el\\'" . emacs-lisp-mode)))
79 ;; Enable the melpa archive for packages
81 (setq package-enable-at-startup nil)
82 (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
83 (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
84 (add-to-list 'package-archives
85 '("elpy" . "http://jorgenschaefer.github.io/packages/"))
88 ;; custom-set-variables was added by Custom.
89 ;; If you edit it by hand, you could mess it up, so be careful.
90 ;; Your init file should contain only one such instance.
91 ;; If there is more than one, they won't work right.
92 '(TeX-view-program-selection
93 '(((output-dvi has-no-display-manager)
95 ((output-dvi style-pstricks)
98 (output-pdf "PDF Tools")
99 (output-html "xdg-open")))
100 '(browse-url-browser-function 'browse-url-firefox)
102 '("0cf95236abcf59e05b1ea69b4edd53d293a5baec4fe4c3484543fee99bfd2204" "80b00f3bf7cdbdca6c80aadfbbb03145f3d0aacf6bf2a559301e61109954e30a" default))
103 '(denote-directory "/home/frederik/Nextcloud/notes/" t)
104 '(org-export-backends '(ascii html icalendar latex md odt))
105 '(package-selected-packages
106 '(emms mpdel-embark libmpdel pass password-store fontaine osm orderless embark-consult embark consult jinx dired-preview ftable flx nerd-icons-dired nerd-icons all-the-icons-dired marginalia vertico denote ox-rss org-ql org-contrib mustache org-static-blog haskell-mode julia-mode elfeed-protocol ack company magit auctex lsp-mode elpy ## org htmlize leuven-theme lua-mode ess-smart-underscore ess-R-data-view ess)))
108 ;; custom-set-faces was added by Custom.
109 ;; If you edit it by hand, you could mess it up, so be careful.
110 ;; Your init file should contain only one such instance.
111 ;; If there is more than one, they won't work right.
115 ;; Send mail using SMTP via mail.vanrenterghem.io.
116 (setq send-mail-function 'smtpmail-send-it)
117 (setq smtpmail-smtp-server "mail.vanrenterghem.io"
118 smtpmail-smtp-service 587
119 smtpmail-stream-type 'starttls)
120 (setq user-full-name "Frederik Vanrenterghem"
121 smtpmail-local-domain "vanrenterghem.io"
122 user-mail-address (concat "frederik@" smtpmail-local-domain))
123 ;; Ignored in mu4e as it sets user-agent
124 (setq mail-default-headers
125 (concat "X-Mailer: GNU Emacs " (symbol-value 'emacs-version)))
126 (setq w3m-pop-up-frames t)
128 (global-set-key [remap list-buffers] 'ibuffer)
130 ;;; use pass (~/.password-store)
131 ;;; (see The Unix password store)
132 (auth-source-pass-enable)
133 (setq pass-username-field "Username")
135 ;; Elfeed news reader from Nextcloud
137 (require 'elfeed-protocol)
139 (setq elfeed-use-curl nil)
140 (elfeed-set-timeout 36000)
141 (setq elfeed-protocol-feeds '(
142 ("owncloud+https://frederik@owncloud.vanrenterghem.biz" :use-authinfo t)
144 (elfeed-protocol-enable)
145 (define-key elfeed-search-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-search-toggle-all '(star))))
146 (define-key elfeed-show-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-show-tag '(star))))
147 (add-hook 'elfeed-show-mode 'variable-pitch-mode)
149 ;; Read and write email using mu4e
151 (setq mail-user-agent 'mu4e-user-agent)
152 ;; Also use mu4e when called from gnus-dired-attach
153 (setq gnus-dired-mail-mode 'mu4e-user-agent)
154 (setq mu4e-get-mail-command "mbsync io")
155 (setq mu4e-update-interval 600)
156 (setq mu4e-use-fancy-chars t)
157 (setq mu4e-view-show-images t)
158 (setq mu4e-sent-folder "/Sent"
159 mu4e-drafts-folder "/Drafts"
160 mu4e-trash-folder "/Trash")
161 (setq message-kill-buffer-on-exit t)
162 ;; attach files to mu4e messages by marking the file(s) in dired and pressing C-c RET C-a
163 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
164 ;; Define all bookmarks starting with favourite query used in mailcount modeline
166 '(( :name "Last 24h's messages"
169 :query "date:24h..now AND NOT flag:trashed")
170 ( :name "Unread messages"
171 :query "flag:unread AND NOT flag:trashed"
173 ( :name "Today's messages"
174 :query "date:today..now AND NOT flag:trashed"
176 ( :name "Last 7 days"
177 :query "date:7d..now AND NOT flag:trashed"
180 ( :name "Messages with images"
181 :query "mime:image/* AND NOT flag:trashed"
184 ;; Create custom spam status header and show in message view
185 (add-to-list 'mu4e-header-info-custom
187 ( :name "Spam-Status" ;; long name, as seen in the message-view
188 :shortname "Spam" ;; short name, as seen in the headers view
189 :help "The Spam status" ;; tooltip
190 ;; uses mu4e-fetch-field which is rel. slow, so only appropriate
191 ;; for mu4e-view-fields, and _not_ mu4e-headers-fields
192 :function (lambda (msg)
193 (or (string-join (seq-take (split-string (or (mu4e-fetch-field msg "X-Spam-Status") "") " ") 2) " ") "")))))
194 (add-to-list 'mu4e-view-fields :spam-status)
196 ;; Resize image attachments when sending email
197 (defvar mu4e-resize-image-types '("jpg" "png" "svg" "jpeg")
198 "List of attached image types to resize.")
200 (defvar mu4e-inhibit-resize nil)
202 (defun mu4e-resize-image-attachments ()
203 (unless mu4e-inhibit-resize
206 (mapconcat #'identity mu4e-resize-image-types "\\|")))
208 (message-goto-body-1)
209 (while (re-search-forward
210 (format "<#part.+\\(filename=\"\\)\\(.+\\(\\.%s\\)\\)\""
213 (let* ((infile (match-string-no-properties 2))
214 (outfile (concat (temporary-file-directory)
215 (file-name-nondirectory infile))))
216 (push (format "magick convert %s -resize 1200x1200\\> %s"
217 (shell-quote-argument infile)
218 (shell-quote-argument outfile))
220 (replace-match outfile t t nil 2)))
221 (mapcar #'shell-command cmds)))))
223 (add-hook 'message-send-hook 'mu4e-resize-image-attachments)
225 (defun mu4e-inhibit-resize()
227 (set (make-local-variable 'mu4e-inhibit-resize) t))
229 ;; Load configuration for website
230 ;(load "mustache-html")
233 (setq denote-directory "/home/frederik/Nextcloud/notes/")
235 ;; Dired configuration
236 (with-eval-after-load 'dired
238 ;; Set dired-x global variables here. For example:
239 ;; (setq dired-x-hands-off-my-keys nil)
241 (add-hook 'dired-mode-hook
243 ;; Set dired-x buffer-local variables here.
245 (dired-hide-details-mode 1)
246 (nerd-icons-dired-mode 1)
248 (setq delete-by-moving-to-trash t)
249 (setq dired-guess-shell-alist-user
250 '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open")
251 ("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open")
254 ;; Use `vertico' package to get a vertical view of the minibuffer.
255 (setq vertico-resize nil)
258 ;; Use `marginalia' package. This will display useful
259 ;; annotations next to entries in the minibuffer. For example, when
260 ;; using M-x it will show a brief description of the command as well
261 ;; as the keybinding associated with it (if any).
264 ;; Use 'winner' mode to undo and redo windows changes
265 ;; using C-c <left> and C-c <right>.
268 ;; Use a different spell checker, always
269 (add-hook 'emacs-startup-hook #'global-jinx-mode)
270 (keymap-global-set "M-$" #'jinx-correct)
273 (keymap-global-set "C-." #'embark-act)
274 (keymap-global-set "C-;" #'embark-dwim)
276 ;; Change default bindings to consult- ones
277 (keymap-set ctl-x-map "b" #'consult-buffer)
278 (global-set-key (kbd "M-y") 'consult-yank-pop)
280 ;; Configure `world-clock'
282 (with-eval-after-load 'time
283 (setq zoneinfo-style-world-list '(("Europe/Brussels" "Leuven")))
284 (add-to-list 'zoneinfo-style-world-list '("Australia/Perth" "Perth")))
287 ;; View PDFs in Emacs
288 (pdf-loader-install) ; On demand loading, leads to faster startup time