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/")
11 ;; Configure printing using CUPS network printer
17 ;; Enable the melpa archive for packages
20 (setq package-enable-at-startup nil)
21 (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
22 (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
23 (add-to-list 'package-archives
24 '("elpy" . "http://jorgenschaefer.github.io/packages/")))
26 (use-package system-packages
29 (use-package modus-themes
31 :demand t ;; Without this, the theme load is deferred due to the
34 ;; Add all customisation prior to loading the themes
35 (setq modus-themes-mixed-fonts t)
37 (modus-themes-select 'modus-vivendi-tinted)
39 :bind ("<f5>" . modus-themes-toggle))
41 (use-package orderless
44 (setq completion-styles '(orderless basic)
45 completion-category-overrides '((file (styles basic partial-completion)))))
47 ;; follow links to version-controlled files without confirming
50 ;; ESS - for working in R
51 (autoload 'R-mode "ess-site.el" "Major mode for editing R source." t)
52 (setq load-path (cons "/usr/share/emacs/site-lisp/ess" load-path))
53 (load "/usr/share/emacs/site-lisp/ess/lisp/ess-site")
54 (setq inferior-julia-program-name "/usr/bin/julia")
56 (use-package ess-view-data
59 ;; enable autocomplete
62 ;; Optional customizations
64 (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
65 (corfu-auto t) ;; Enable auto completion
66 ;; (corfu-separator ?\s) ;; Orderless field separator
67 ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
68 ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
69 ;; (corfu-preview-current nil) ;; Disable current candidate preview
70 ;; (corfu-preselect 'prompt) ;; Preselect the prompt
71 ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
72 ;; (corfu-scroll-margin 5) ;; Use scroll margin
74 ;; Enable Corfu only for certain modes. See also `global-corfu-modes'.
75 ;; :hook ((prog-mode . corfu-mode)
76 ;; (shell-mode . corfu-mode)
77 ;; (eshell-mode . corfu-mode))
79 ;; Recommended: Enable Corfu globally. This is recommended since Dabbrev can
80 ;; be used globally (M-/). See also the customization variable
81 ;; `global-corfu-modes' to exclude certain modes.
88 ;; Bind prefix keymap providing all Cape commands under a mnemonic key.
89 ;; Press C-c p ? to for help.
90 :bind ("C-c p" . cape-prefix-map) ;; Alternative keys: M-p, M-+, ...
91 ;; Alternatively bind Cape commands individually.
92 ;; :bind (("C-c p d" . cape-dabbrev)
93 ;; ("C-c p h" . cape-history)
94 ;; ("C-c p f" . cape-file)
97 ;; Add to the global default value of `completion-at-point-functions' which is
98 ;; used by `completion-at-point'. The order of the functions matters, the
99 ;; first function returning a result wins. Note that the list of buffer-local
100 ;; completion functions takes precedence over the global list.
101 (add-hook 'completion-at-point-functions #'cape-dict) ;; requires words package to be installed on Arch to provide /usr/share/dict/words
102 (add-hook 'completion-at-point-functions #'cape-dabbrev)
103 (add-hook 'completion-at-point-functions #'cape-file)
104 (add-hook 'completion-at-point-functions #'cape-elisp-block)
105 ;; (add-hook 'completion-at-point-functions #'cape-history)
112 (("C-c c" . org-capture)
113 ("C-c l" . org-store-link)
114 ("C-c a" . org-agenda))
116 (org-default-notes-file "~/Nextcloud/notes/inbox.org")
117 (org-agenda-files `(,org-default-notes-file "~/Nextcloud/notes/calendar.org"))
118 (org-capture-bookmark nil)
120 (org-capture-templates
121 '(("f" "Fleeting note" entry
122 (file+headline org-default-notes-file "Notes")
123 "* %?\nEntered on %U\n %i\n %a")
124 ("b" "Tax receipt" item
125 (file "~/Documents/belastingen/FY24-25.org")
127 ("a" "Appointment" entry
128 (file+olp+datetree "~/Nextcloud/notes/calendar.org")
129 "* %?\n :PROPERTIES:\n :location: %^{Location}\n :END:\n%^T--%^T\n\n"
134 ("p" "Permanent note" plain
135 (file denote-last-path)
138 :immediate-finish nil
141 ("t" "New task" entry
142 (file+headline org-default-notes-file "Tasks")
144 ("e" "Email follow-up" entry (file+headline org-default-notes-file "Tasks")
145 "* TODO %:fromname: %a %?\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+2d\"))")))
147 (org-agenda-custom-commands
148 '(("P" "Expired calendar events" ((tags "TIMESTAMP<=\"<now>\"")))
149 ("n" "Agenda and all TODOs" ((agenda "") (alltodo "")))))
152 (defun my/opened-buffer-files ()
153 "Return the list of org files currently opened in emacs"
156 (if (and (buffer-file-name x)
157 (string-match "\\.org$"
158 (buffer-file-name x)))
159 (buffer-file-name x)))
161 (setq org-refile-targets `((my/opened-buffer-files :maxlevel . 9)
162 (,(file-expand-wildcards "~/Nextcloud/notes/*.org") :maxlevel . 1)))
163 (setq org-agenda-skip-scheduled-if-done t)
164 (setq org-agenda-skip-deadline-if-done t)
165 (setq org-agenda-start-on-weekday nil)
166 (setq org-log-done 'time)
167 ;; Automatically flow lines based on window width and use
168 ;; variable width fonts in org-mode.
169 (add-hook 'org-mode-hook 'visual-line-mode)
170 (add-hook 'org-mode-hook 'variable-pitch-mode)
171 ;; org-mode support for R and LaTeX
172 (org-babel-do-load-languages
173 'org-babel-load-languages
177 (use-package org-caldav
180 (setq org-caldav-url "https://owncloud.vanrenterghem.biz/remote.php/dav/calendars/frederik")
181 (setq org-caldav-calendar-id "orgmode")
182 ;; Org filename where new entries from calendar stored
183 (setq org-caldav-inbox "~/Nextcloud/notes/calendar.org")
184 ;; Additional Org files to check for calendar events
185 (setq org-caldav-files nil)
186 ;; Usually a good idea to set the timezone manually
187 (setq org-icalendar-timezone "Australia/Perth"))
189 (use-package org-protocol)
194 (setq TeX-auto-save t
196 TeX-view-program-selection
197 '(((output-dvi has-no-display-manager)
199 ((output-dvi style-pstricks)
202 (output-pdf "PDF Tools")
203 (output-html "xdg-open"))))
204 ;; (load "preview-latex.el" nil t t)
207 ;; Automatically switch to various modes
208 (setq auto-mode-alist
209 '(("\\.mdwn\\'" . markdown-mode)
210 ("\\.md\\'" . markdown-mode)
211 ("\\.yarn\\'" . markdown-mode)
212 ("\\.cpp\\'" . c++-mode)
213 ("\\.js\\'" . js-mode)
214 ("\\.json\\'" . js-mode)
215 ("Makefile" . makefile-mode)
216 ("README" . markdown-mode)
217 ("NEWS" . markdown-mode)
218 ("COMMIT_EDITMSG\\'" . text-mode)
219 ("\\.html\\'" . html-mode)
220 ("\\.css\\'" . css-mode)
221 ("\\.yaml\\'" . yaml-mode)
222 ("\\.yml\\'" . yaml-mode)
223 ("\\.ick\\'" . yaml-mode)
224 ("\\.py\\'" . python-mode)
226 ("\\.org\\'" . org-mode)
227 ("\\.tex\\'" . latex-mode)
228 ("\\.sh\\'" . shell-script-mode)
229 ("\\.hs\\'" . haskell-mode)
230 ("\\.el\\'" . emacs-lisp-mode)))
233 (custom-set-variables
234 ;; custom-set-variables was added by Custom.
235 ;; If you edit it by hand, you could mess it up, so be careful.
236 ;; Your init file should contain only one such instance.
237 ;; If there is more than one, they won't work right.
238 '(browse-url-browser-function 'browse-url-firefox)
240 '("8d146df8bd640320d5ca94d2913392bc6f763d5bc2bb47bed8e14975017eea91"
241 "9a977ddae55e0e91c09952e96d614ae0be69727ea78ca145beea1aae01ac78d2"
242 "0cf95236abcf59e05b1ea69b4edd53d293a5baec4fe4c3484543fee99bfd2204"
243 "80b00f3bf7cdbdca6c80aadfbbb03145f3d0aacf6bf2a559301e61109954e30a"
245 '(org-export-backends '(ascii html icalendar latex md odt))
246 '(package-selected-packages
247 '(## ack all-the-icons-dired auctex calfw calfw-org company consult
248 consult-denote denote devdocs dired-preview
249 dired-quick-sort eat elfeed-protocol ellama elpy embark
250 embark-consult emms engrave-faces ess ess-R-data-view
251 ess-smart-underscore ess-view-data flx fontaine ftable
252 haskell-mode htmlize jinx julia-mode leuven-theme libmpdel
253 lsp-mode lua-mode magit marginalia mpdel-embark mu4e
254 mustache nerd-icons nerd-icons-dired nov orderless org
255 org-caldav org-contrib org-ql org-static-blog osm ox-rss
256 pass password-store powerthesaurus request straight
258 '(use-package-compute-statistics t))
260 ;; custom-set-faces was added by Custom.
261 ;; If you edit it by hand, you could mess it up, so be careful.
262 ;; Your init file should contain only one such instance.
263 ;; If there is more than one, they won't work right.
267 ;; Send mail using SMTP via mail.vanrenterghem.io.
268 (setq send-mail-function 'smtpmail-send-it)
269 (setq smtpmail-smtp-server "mail.vanrenterghem.io"
270 smtpmail-smtp-service 587
271 smtpmail-stream-type 'starttls)
272 (setq user-full-name "Frederik Vanrenterghem"
273 smtpmail-local-domain "vanrenterghem.io"
274 user-mail-address (concat "frederik@" smtpmail-local-domain))
275 ;; Ignored in mu4e as it sets user-agent
276 (setq mail-default-headers
277 (concat "X-Mailer: GNU Emacs " (symbol-value 'emacs-version)))
278 (setq w3m-pop-up-frames t)
280 (global-set-key [remap list-buffers] 'ibuffer)
282 ;;; use pass (~/.password-store)
283 ;;; (see The Unix password store)
287 (auth-source-pass-enable)
288 (setq pass-username-field "Username"))
290 ;; Elfeed news reader from Nextcloud
294 (setq elfeed-use-curl nil)
295 (elfeed-set-timeout 36000)
296 (define-key elfeed-search-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-search-toggle-all '(star))))
297 (define-key elfeed-show-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-show-tag '(star))))
298 (add-hook 'elfeed-show-mode 'variable-pitch-mode))
300 (use-package elfeed-protocol
304 (setq elfeed-protocol-feeds '(
305 ("owncloud+https://frederik@owncloud.vanrenterghem.biz" :use-authinfo t)
307 (elfeed-protocol-enable))
310 ;; Read and write email using mu4e
313 ;; :ensure-system-package mu ;; Install from aur
315 (setq mail-user-agent 'mu4e-user-agent)
316 ;; Also use mu4e when called from gnus-dired-attach
317 (setq gnus-dired-mail-mode 'mu4e-user-agent
318 mu4e-get-mail-command "mbsync io"
319 mu4e-update-interval 600
320 mu4e-use-fancy-chars t
321 mu4e-view-show-images t
322 mu4e-sent-folder "/Sent"
323 mu4e-drafts-folder "/Drafts"
324 mu4e-trash-folder "/Trash"
325 message-kill-buffer-on-exit t
326 ;;Fixing duplicate UID errors when using mbsync and mu4e
327 mu4e-change-filenames-when-moving t)
328 ;; attach files to mu4e messages by marking the file(s) in dired and pressing C-c RET C-a
329 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
330 ;; Define all bookmarks starting with favourite query used in mailcount modeline
332 '(( :name "Last 24h's messages"
335 :query "date:24h..now AND NOT flag:trashed")
336 ( :name "Unread messages"
337 :query "flag:unread AND NOT flag:trashed"
339 ( :name "Today's messages"
340 :query "date:today..now AND NOT flag:trashed"
342 ( :name "Last 7 days"
343 :query "date:7d..now AND NOT flag:trashed"
346 ( :name "Messages with images"
347 :query "mime:image/* AND NOT flag:trashed"
349 ;; Create custom spam status header and show in message view
350 (add-to-list 'mu4e-header-info-custom
352 ( :name "Spam-Status" ;; long name, as seen in the message-view
353 :shortname "Spam" ;; short name, as seen in the headers view
354 :help "The Spam status" ;; tooltip
355 ;; uses mu4e-fetch-field which is rel. slow, so only appropriate
356 ;; for mu4e-view-fields, and _not_ mu4e-headers-fields
357 :function (lambda (msg)
358 (or (string-join (seq-take (split-string (or (mu4e-fetch-field msg "X-Spam-Status") "") " ") 2) " ") "")))))
359 (add-to-list 'mu4e-view-fields :spam-status)
360 ;; Resize image attachments when sending email
361 (defvar mu4e-resize-image-types '("jpg" "png" "svg" "jpeg")
362 "List of attached image types to resize.")
363 (defvar mu4e-inhibit-resize nil)
364 (defun mu4e-resize-image-attachments ()
365 (unless mu4e-inhibit-resize
368 (mapconcat #'identity mu4e-resize-image-types "\\|")))
370 (message-goto-body-1)
371 (while (re-search-forward
372 (format "<#part.+\\(filename=\"\\)\\(.+\\(\\.%s\\)\\)\""
375 (let* ((infile (match-string-no-properties 2))
376 (outfile (concat (temporary-file-directory)
377 (file-name-nondirectory infile))))
378 (push (format "magick convert %s -resize 1200x1200\\> %s"
379 (shell-quote-argument infile)
380 (shell-quote-argument outfile))
382 (replace-match outfile t t nil 2)))
383 (mapcar #'shell-command cmds)))))
384 (add-hook 'message-send-hook 'mu4e-resize-image-attachments)
385 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode) ;; Attach files to messages using dired C-c RET C-a
386 (defun mu4e-inhibit-resize()
388 (set (make-local-variable 'mu4e-inhibit-resize) t)))
390 ;; Load configuration for website
391 ;(load "mustache-html")
396 :hook (dired-mode . denote-dired-mode)
398 (("C-c n n" . denote)
399 ("C-c n r" . denote-rename-file)
400 ("C-c n l" . denote-link)
401 ("C-c n b" . denote-backlinks))
403 (setq denote-directory "/home/frederik/Nextcloud/notes/")
404 (denote-rename-buffer-mode 1))
406 (use-package nerd-icons
408 ;; The Nerd Font you want to use in GUI
409 ;; "Symbols Nerd Font Mono" is the default and is recommended
410 ;; but you can use any other Nerd Font if you want
411 ;; (nerd-icons-font-family "Symbols Nerd Font Mono")
414 ;; Dired configuration
415 (with-eval-after-load 'dired
417 ;; Set dired-x global variables here. For example:
418 ;; (setq dired-x-hands-off-my-keys nil)
420 (add-hook 'dired-mode-hook
422 ;; Set dired-x buffer-local variables here.
424 (dired-hide-details-mode 1)
425 (nerd-icons-dired-mode 1)
427 (setq delete-by-moving-to-trash t)
428 (setq dired-guess-shell-alist-user
429 '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open")
430 ("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open")
433 ;; Use `vertico' package to get a vertical view of the minibuffer.
437 (setq vertico-resize nil)
440 ;; Persist history over Emacs restarts. Vertico sorts by history position.
441 (use-package savehist
445 ;; Use `marginalia' package. This will display useful
446 ;; annotations next to entries in the minibuffer. For example, when
447 ;; using M-x it will show a brief description of the command as well
448 ;; as the keybinding associated with it (if any).
449 (use-package marginalia
454 ;; Use 'winner' mode to undo and redo windows changes
455 ;; using C-c <left> and C-c <right>.
461 ;; Use a different spell checker, always
465 (keymap-global-set "M-$" #'jinx-correct)
466 :hook (emacs-startup . global-jinx-mode))
468 (use-package powerthesaurus
472 (transient-define-prefix my/transient-spelling ()
476 ("y" "Synonyms" powerthesaurus-lookup-synonyms-dwim)
477 ("a" "Antonyms" powerthesaurus-lookup-antonyms-dwim)]
479 ("x" "Jinx" jinx-mode)
480 ("c" "Jinx correct" jinx-correct)]
482 ("d" "Lookup" dictionary-lookup-definition)]
484 ("q" "Quit" transient-quit-one)]])
486 ("C-c s" . my/transient-spelling))
492 (keymap-global-set "C-." #'embark-act)
493 (keymap-global-set "C-;" #'embark-dwim))
498 ;; Change default bindings to consult- ones
500 (;; C-x bindings in `ctl-x-map'
501 ("C-x b" . consult-buffer) ;; orig. switch-to-buffer
502 ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
503 ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
504 ;; Other custom bindings
505 ("M-y" . consult-yank-pop))) ;; orig. yank-pop
507 (use-package consult-mu
508 :ensure nil ;; cloned in
509 :load-path "~/.emacs.d/lisp/consult-mu"
510 :after (consult mu4e)
512 ;;maximum number of results shown in minibuffer
513 (consult-mu-maxnum 200)
514 ;;show preview when pressing any keys
515 (consult-mu-preview-key 'any)
516 ;;do not mark email as read when previewed
517 (consult-mu-mark-previewed-as-read nil)
518 ;;do not amrk email as read when selected. This is a good starting point to ensure you would not miss important emails marked as read by mistake especially when trying this package out. Later you can change this to t.
519 (consult-mu-mark-viewed-as-read nil)
520 ;; open the message in mu4e-view-buffer when selected.
521 (consult-mu-action #'consult-mu--view-action)
524 (use-package consult-denote
527 ;; Configure `world-clock'
531 (setq zoneinfo-style-world-list '(("Europe/Brussels" "Leuven")))
532 (add-to-list 'zoneinfo-style-world-list '("Australia/Perth" "Perth")))
535 ;; View PDFs in Emacs
536 (pdf-loader-install) ; On demand loading, leads to faster startup time
537 (setq pdf-misc-print-programm "/usr/bin/lpr")
545 ;; For `eat-eshell-mode'.
546 (add-hook 'eshell-load-hook #'eat-eshell-mode)
547 (setq eshell-visual-commands '()))
553 (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
555 (add-hook 'nov-mode-hook #'variable-pitch-mode))
557 ;; Set some preset fonts
558 (use-package fontaine
561 (setq fontaine-presets
563 :default-family "Iosevka Nerd Font"
565 :variable-pitch-family "Linux Biolinum O"
566 :variable-pitch-weight normal
567 :variable-pitch-height 1.1
568 :italic-family "Iosevka Etoile"
571 :default-family "Iosevka Nerd Font"
573 :variable-pitch-family "Literata"
574 :variable-pitch-weight normal
575 :variable-pitch-height 1.0
578 :default-family "Fira Mono Nerd Font"
580 :variable-pitch-family "Fira Sans Book"
581 :variable-pitch-weight normal
582 :variable-pitch-height 1.0
585 :default-family "Fira Mono Nerd Font"
587 :variable-pitch-family "Fira Sans Book"
588 :variable-pitch-weight normal
589 :variable-pitch-height 1.0
592 :variable-pitch-family "Libre Baskerville"
593 :variable-pitch-weight normal
594 :variable-pitch-height 1.0
597 :variable-pitch-family "Noto Serif"
598 :variable-pitch-weight normal
599 :variable-pitch-height 1.0
602 :variable-pitch-family "ETBembo"
603 :variable-pitch-weight normal
604 :variable-pitch-height 1.1
607 :variable-pitch-family "Literata"
608 :variable-pitch-weight normal
609 :variable-pitch-height 1.0
615 ("C-h D" . devdocs-lookup))
620 (require 'emms-setup)
621 (require 'emms-player-mpd)
622 (emms-all) ; don't change this to values you see on stackoverflow questions if you expect emms to work
623 (setq emms-player-list '(emms-player-mpd))
624 (add-to-list 'emms-info-functions 'emms-info-mpd)
625 (add-to-list 'emms-player-list 'emms-player-mpd)
627 ;; Socket is not supported
628 (setq emms-player-mpd-server-name "mea-hookani-pila")
629 (setq emms-player-mpd-server-port "6600")
630 (emms-player-mpd-connect))
634 ;; Might want to run this automatically
635 ;; using variable after-focus-change-function
636 (defun my/adjust-font-size-based-on-display ()
637 "Change size of fonts based on monitor."
639 (let* ((display-name (cdr (assq 'name (frame-monitor-attributes))))
640 (font-height (cond ((string-equal display-name "eDP-1") 140)
643 (set-face-attribute 'default (selected-frame) :height font-height)))