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)
134 ;; Elfeed news reader from Nextcloud
136 (require 'elfeed-protocol)
138 (setq elfeed-use-curl nil)
139 (elfeed-set-timeout 36000)
140 (setq elfeed-protocol-feeds '(
141 ("owncloud+https://frederik@owncloud.vanrenterghem.biz" :use-authinfo t)
143 (elfeed-protocol-enable)
144 (define-key elfeed-search-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-search-toggle-all '(star))))
145 (define-key elfeed-show-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-show-tag '(star))))
146 (add-hook 'elfeed-show-mode 'variable-pitch-mode)
148 ;; Read and write email using mu4e
150 (setq mail-user-agent 'mu4e-user-agent)
151 ;; Also use mu4e when called from gnus-dired-attach
152 (setq gnus-dired-mail-mode 'mu4e-user-agent)
153 (setq mu4e-get-mail-command "mbsync io")
154 (setq mu4e-update-interval 600)
155 (setq mu4e-use-fancy-chars t)
156 (setq mu4e-view-show-images t)
157 (setq mu4e-sent-folder "/Sent"
158 mu4e-drafts-folder "/Drafts"
159 mu4e-trash-folder "/Trash")
160 (setq message-kill-buffer-on-exit t)
161 ;; attach files to mu4e messages by marking the file(s) in dired and pressing C-c RET C-a
162 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
163 ;; Define all bookmarks starting with favourite query used in mailcount modeline
165 '(( :name "Last 24h's messages"
168 :query "date:24h..now AND NOT flag:trashed")
169 ( :name "Unread messages"
170 :query "flag:unread AND NOT flag:trashed"
172 ( :name "Today's messages"
173 :query "date:today..now AND NOT flag:trashed"
175 ( :name "Last 7 days"
176 :query "date:7d..now AND NOT flag:trashed"
179 ( :name "Messages with images"
180 :query "mime:image/* AND NOT flag:trashed"
183 ;; Create custom spam status header and show in message view
184 (add-to-list 'mu4e-header-info-custom
186 ( :name "Spam-Status" ;; long name, as seen in the message-view
187 :shortname "Spam" ;; short name, as seen in the headers view
188 :help "The Spam status" ;; tooltip
189 ;; uses mu4e-fetch-field which is rel. slow, so only appropriate
190 ;; for mu4e-view-fields, and _not_ mu4e-headers-fields
191 :function (lambda (msg)
192 (or (string-join (seq-take (split-string (or (mu4e-fetch-field msg "X-Spam-Status") "") " ") 2) " ") "")))))
193 (add-to-list 'mu4e-view-fields :spam-status)
195 ;; Resize image attachments when sending email
196 (defvar mu4e-resize-image-types '("jpg" "png" "svg" "jpeg")
197 "List of attached image types to resize.")
199 (defvar mu4e-inhibit-resize nil)
201 (defun mu4e-resize-image-attachments ()
202 (unless mu4e-inhibit-resize
205 (mapconcat #'identity mu4e-resize-image-types "\\|")))
207 (message-goto-body-1)
208 (while (re-search-forward
209 (format "<#part.+\\(filename=\"\\)\\(.+\\(\\.%s\\)\\)\""
212 (let* ((infile (match-string-no-properties 2))
213 (outfile (concat (temporary-file-directory)
214 (file-name-nondirectory infile))))
215 (push (format "magick convert %s -resize 1200x1200\\> %s"
216 (shell-quote-argument infile)
217 (shell-quote-argument outfile))
219 (replace-match outfile t t nil 2)))
220 (mapcar #'shell-command cmds)))))
222 (add-hook 'message-send-hook 'mu4e-resize-image-attachments)
224 (defun mu4e-inhibit-resize()
226 (set (make-local-variable 'mu4e-inhibit-resize) t))
228 ;; Load configuration for website
229 ;(load "mustache-html")
232 (setq denote-directory "/home/frederik/Nextcloud/notes/")
234 ;; Dired configuration
235 (with-eval-after-load 'dired
237 ;; Set dired-x global variables here. For example:
238 ;; (setq dired-x-hands-off-my-keys nil)
240 (add-hook 'dired-mode-hook
242 ;; Set dired-x buffer-local variables here.
244 (dired-hide-details-mode 1)
245 (nerd-icons-dired-mode 1)
247 (setq delete-by-moving-to-trash t)
248 (setq dired-guess-shell-alist-user
249 '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open")
250 ("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open")
253 ;; Use `vertico' package to get a vertical view of the minibuffer.
254 (setq vertico-resize nil)
257 ;; Use `marginalia' package. This will display useful
258 ;; annotations next to entries in the minibuffer. For example, when
259 ;; using M-x it will show a brief description of the command as well
260 ;; as the keybinding associated with it (if any).
263 ;; Use 'winner' mode to undo and redo windows changes
264 ;; using C-c <left> and C-c <right>.
267 ;; Use a different spell checker, always
268 (add-hook 'emacs-startup-hook #'global-jinx-mode)
269 (keymap-global-set "M-$" #'jinx-correct)
272 (keymap-global-set "C-." #'embark-act)
273 (keymap-global-set "C-;" #'embark-dwim)
275 ;; Change default bindings to consult- ones
276 (keymap-set ctl-x-map "b" #'consult-buffer)
277 (global-set-key (kbd "M-y") 'consult-yank-pop)
279 ;; Configure `world-clock'
281 (with-eval-after-load 'time
282 (setq zoneinfo-style-world-list '(("Europe/Brussels" "Leuven")))
283 (add-to-list 'zoneinfo-style-world-list '("Australia/Perth" "Perth")))
286 ;; View PDFs in Emacs
287 (pdf-loader-install) ; On demand loading, leads to faster startup time