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/")
12 (setopt custom-file "~/.emacs.d/custom.el")
15 ;; Configure printing using CUPS network printer
21 ;; Enable the melpa archive for packages
24 (setq package-enable-at-startup nil)
25 (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
26 (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
27 (add-to-list 'package-archives
28 '("elpy" . "http://jorgenschaefer.github.io/packages/")))
30 (use-package system-packages
33 (use-package modus-themes
35 :demand t ;; Without this, the theme load is deferred due to the
38 ;; Add all customisation prior to loading the themes
39 (setq modus-themes-mixed-fonts t)
41 (modus-themes-select 'modus-vivendi-tinted)
43 :bind ("<f5>" . modus-themes-toggle))
45 (use-package orderless
48 (setq completion-styles '(orderless basic)
49 completion-category-overrides '((file (styles basic partial-completion)))))
51 ;; follow links to version-controlled files without confirming
54 ;; ESS - for working in R
55 (autoload 'R-mode "ess-site.el" "Major mode for editing R source." t)
56 (setq load-path (cons "/usr/share/emacs/site-lisp/ess" load-path))
57 (load "/usr/share/emacs/site-lisp/ess/lisp/ess-site")
58 (setq inferior-julia-program-name "/usr/bin/julia")
60 (use-package ess-view-data
66 ;; Require trigger prefix before template name when completing.
68 ;; (tempel-trigger-prefix "<")
70 :bind (("M-+" . tempel-complete) ;; Alternative tempel-expand
71 ("M-*" . tempel-insert))
75 ;; Setup completion at point
76 (defun tempel-setup-capf ()
77 ;; Add the Tempel Capf to `completion-at-point-functions'.
78 ;; `tempel-expand' only triggers on exact matches. Alternatively use
79 ;; `tempel-complete' if you want to see all matches, but then you
80 ;; should also configure `tempel-trigger-prefix', such that Tempel
81 ;; does not trigger too often when you don't expect it. NOTE: We add
82 ;; `tempel-expand' *before* the main programming mode Capf, such
83 ;; that it will be tried first.
84 (setq-local completion-at-point-functions
86 completion-at-point-functions)))
88 (add-hook 'conf-mode-hook 'tempel-setup-capf)
89 (add-hook 'prog-mode-hook 'tempel-setup-capf)
90 (add-hook 'text-mode-hook 'tempel-setup-capf)
92 ;; Optionally make the Tempel templates available to Abbrev,
93 ;; either locally or globally. `expand-abbrev' is bound to C-x '.
94 ;; (add-hook 'prog-mode-hook #'tempel-abbrev-mode)
95 ;; (global-tempel-abbrev-mode)
98 ;; Optional: Add tempel-collection.
99 ;; The package is young and doesn't have comprehensive coverage.
100 (use-package tempel-collection
104 ;; enable autocomplete
107 ;; Optional customizations
109 (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
110 (corfu-auto t) ;; Enable auto completion
111 ;; (corfu-separator ?\s) ;; Orderless field separator
112 ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
113 ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
114 ;; (corfu-preview-current nil) ;; Disable current candidate preview
115 ;; (corfu-preselect 'prompt) ;; Preselect the prompt
116 ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
117 ;; (corfu-scroll-margin 5) ;; Use scroll margin
119 ;; Enable Corfu only for certain modes. See also `global-corfu-modes'.
120 ;; :hook ((prog-mode . corfu-mode)
121 ;; (shell-mode . corfu-mode)
122 ;; (eshell-mode . corfu-mode))
124 ;; Recommended: Enable Corfu globally. This is recommended since Dabbrev can
125 ;; be used globally (M-/). See also the customization variable
126 ;; `global-corfu-modes' to exclude certain modes.
129 (corfu-history-mode))
133 ;; Bind prefix keymap providing all Cape commands under a mnemonic key.
134 ;; Press C-c p ? to for help.
135 :bind ("C-c p" . cape-prefix-map) ;; Alternative keys: M-p, M-+, ...
136 ;; Alternatively bind Cape commands individually.
137 ;; :bind (("C-c p d" . cape-dabbrev)
138 ;; ("C-c p h" . cape-history)
139 ;; ("C-c p f" . cape-file)
142 ;; Add to the global default value of `completion-at-point-functions' which is
143 ;; used by `completion-at-point'. The order of the functions matters, the
144 ;; first function returning a result wins. Note that the list of buffer-local
145 ;; completion functions takes precedence over the global list.
146 (add-hook 'completion-at-point-functions #'cape-dict) ;; requires words package to be installed on Arch to provide /usr/share/dict/words
147 (add-hook 'completion-at-point-functions #'cape-dabbrev)
148 (add-hook 'completion-at-point-functions #'cape-file)
149 (add-hook 'completion-at-point-functions #'cape-elisp-block)
150 ;; (add-hook 'completion-at-point-functions #'cape-history)
157 (("C-c c" . org-capture)
158 ("C-c l" . org-store-link)
159 ("C-c a" . org-agenda))
161 (org-default-notes-file "~/Nextcloud/notes/inbox.org")
162 (org-agenda-files `(,org-default-notes-file "~/Nextcloud/notes/calendar-nextcloud.org"))
163 (org-capture-bookmark nil)
165 (org-capture-templates
166 '(("f" "Fleeting note" entry
167 (file+headline org-default-notes-file "Notes")
168 "* %?\nEntered on %U\n %i\n %a")
169 ("b" "Tax receipt" item
170 (file "~/Documents/belastingen/FY24-25.org")
172 ("a" "Appointment" entry
173 (file+olp+datetree "~/Nextcloud/notes/calendar-nextcloud.org")
174 "* %?\n :PROPERTIES:\n :location: %^{Location}\n :END:\n%(fv/org-capture-appointment-timestamp)\n\n"
179 ("p" "Permanent note" plain
180 (file denote-last-path)
183 :immediate-finish nil
186 ("t" "New task" entry
187 (file+headline org-default-notes-file "Tasks")
189 ("e" "Email follow-up" entry (file+headline org-default-notes-file "Tasks")
190 "* TODO %:fromname: %a %?\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+2d\") t)")))
192 (org-agenda-custom-commands
193 '(("P" "Expired calendar events" ((tags "TIMESTAMP<=\"<now>\"")))
194 ("n" "Agenda and all TODOs" ((agenda "") (alltodo "")))))
197 (defun my/opened-buffer-files ()
198 "Return the list of org files currently opened in emacs"
201 (if (and (buffer-file-name x)
202 (string-match "\\.org$"
203 (buffer-file-name x)))
204 (buffer-file-name x)))
206 (setq org-refile-targets `((my/opened-buffer-files :maxlevel . 9)
207 (,(file-expand-wildcards "~/Nextcloud/notes/*.org") :maxlevel . 1)))
208 (setq org-agenda-skip-scheduled-if-done t)
209 (setq org-agenda-skip-deadline-if-done t)
210 (setq org-agenda-start-on-weekday nil)
211 (setq org-log-done 'time)
212 ;; Automatically flow lines based on window width and use
213 ;; variable width fonts in org-mode.
214 (add-hook 'org-mode-hook 'visual-line-mode)
215 (add-hook 'org-mode-hook 'variable-pitch-mode)
216 ;; org-mode support for R and LaTeX
217 (org-babel-do-load-languages
218 'org-babel-load-languages
222 (defun fv/org-capture-appointment-timestamp (&optional duration)
223 "Get an Org timestamp for an appointment.
224 Prompt for a start time, calculate the end time by adding DURATION (default 30
225 minutes), and return a formatted Org timestamp with start and end times."
226 (let* ((duration (or duration 30))
227 (start-time (org-read-date t t nil "From:"))
228 (end-time (time-add start-time (seconds-to-time (* duration 60)))))
229 (concat (format-time-string (org-time-stamp-format t) start-time)
231 (format-time-string (org-time-stamp-format t) end-time))))
233 (use-package org-caldav
236 (setq org-caldav-url "https://owncloud.vanrenterghem.biz/remote.php/dav/calendars/frederik")
237 (setq org-caldav-calendar-id "default%20calendar")
238 ;; Org filename where new entries from calendar stored
239 (setq org-caldav-inbox '(file+olp+datetree "~/Nextcloud/notes/calendar-nextcloud.org"))
240 ;; Additional Org files to check for calendar events
241 (setq org-caldav-files nil)
242 ;; Usually a good idea to set the timezone manually
243 (setq org-icalendar-timezone "Australia/Perth")
244 (setq org-caldav-delete-calendar-entries 'ask))
246 (use-package org-protocol)
251 (setq TeX-auto-save t
253 TeX-view-program-selection
254 '(((output-dvi has-no-display-manager)
256 ((output-dvi style-pstricks)
259 (output-pdf "PDF Tools")
260 (output-html "xdg-open"))))
261 ;; (load "preview-latex.el" nil t t)
264 ;; Automatically switch to various modes
265 (setq auto-mode-alist
266 '(("\\.mdwn\\'" . markdown-mode)
267 ("\\.md\\'" . markdown-mode)
268 ("\\.yarn\\'" . markdown-mode)
269 ("\\.cpp\\'" . c++-mode)
270 ("\\.js\\'" . js-mode)
271 ("\\.json\\'" . js-mode)
272 ("Makefile" . makefile-mode)
273 ("README" . markdown-mode)
274 ("NEWS" . markdown-mode)
275 ("COMMIT_EDITMSG\\'" . text-mode)
276 ("\\.html\\'" . html-mode)
277 ("\\.css\\'" . css-mode)
278 ("\\.yaml\\'" . yaml-mode)
279 ("\\.yml\\'" . yaml-mode)
280 ("\\.ick\\'" . yaml-mode)
281 ("\\.py\\'" . python-mode)
283 ("\\.org\\'" . org-mode)
284 ("\\.tex\\'" . latex-mode)
285 ("\\.sh\\'" . shell-script-mode)
286 ("\\.hs\\'" . haskell-mode)
287 ("\\.el\\'" . emacs-lisp-mode)))
289 ;; Send mail using SMTP via mail.vanrenterghem.io.
290 (setq send-mail-function 'smtpmail-send-it)
291 (setq smtpmail-smtp-server "mail.vanrenterghem.io"
292 smtpmail-smtp-service 587
293 smtpmail-stream-type 'starttls)
294 (setq user-full-name "Frederik Vanrenterghem"
295 smtpmail-local-domain "vanrenterghem.io"
296 user-mail-address (concat "frederik@" smtpmail-local-domain))
297 ;; Ignored in mu4e as it sets user-agent
298 (setq mail-default-headers
299 (concat "X-Mailer: GNU Emacs " (symbol-value 'emacs-version)))
300 (setq w3m-pop-up-frames t)
302 (setq gnus-select-method '(nntp "news.eternal-september.org"
303 (nntp-open-connection-function nntp-open-tls-stream)
304 (nntp-port-number 563)
305 (nntp-authinfo-user "frederikv")
306 (nntp-authinfo-force t)))
308 (global-set-key [remap list-buffers] 'ibuffer)
310 ;;; use pass (~/.password-store)
311 ;;; (see The Unix password store)
315 (auth-source-pass-enable)
316 (setq pass-username-field "Username"))
318 ;; Elfeed news reader from Nextcloud
322 (setq elfeed-use-curl nil)
323 (elfeed-set-timeout 36000)
324 (define-key elfeed-search-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-search-toggle-all '(star))))
325 (define-key elfeed-show-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-show-tag '(star))))
326 (add-hook 'elfeed-show-mode 'variable-pitch-mode))
328 (use-package elfeed-protocol
332 (setq elfeed-protocol-feeds '(
333 ("owncloud+https://frederik@owncloud.vanrenterghem.biz" :use-authinfo t)
335 (elfeed-protocol-enable))
338 ;; Read and write email using mu4e
341 ;; :ensure-system-package mu ;; Install from aur
343 (setq mail-user-agent 'mu4e-user-agent)
344 ;; Also use mu4e when called from gnus-dired-attach
345 (setq gnus-dired-mail-mode 'mu4e-user-agent
346 mu4e-get-mail-command "mbsync io"
347 mu4e-update-interval 600
348 mu4e-use-fancy-chars t
349 mu4e-view-show-images t
350 mu4e-sent-folder "/Sent"
351 mu4e-drafts-folder "/Drafts"
352 mu4e-trash-folder "/Trash"
353 message-kill-buffer-on-exit t
354 ;;Fixing duplicate UID errors when using mbsync and mu4e
355 mu4e-change-filenames-when-moving t)
356 ;; attach files to mu4e messages by marking the file(s) in dired and pressing C-c RET C-a
357 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
358 ;; Define all bookmarks starting with favourite query used in mailcount modeline
360 '(( :name "Last 24h's messages"
363 :query "date:24h..now AND NOT flag:trashed")
364 ( :name "Unread messages"
365 :query "flag:unread AND NOT flag:trashed"
367 ( :name "Today's messages"
368 :query "date:today..now AND NOT flag:trashed"
370 ( :name "Last 7 days"
371 :query "date:7d..now AND NOT flag:trashed"
374 ( :name "Messages with images"
375 :query "mime:image/* AND NOT flag:trashed"
377 ;; Create custom spam status header and show in message view
378 (add-to-list 'mu4e-header-info-custom
380 ( :name "Spam-Status" ;; long name, as seen in the message-view
381 :shortname "Spam" ;; short name, as seen in the headers view
382 :help "The Spam status" ;; tooltip
383 ;; uses mu4e-fetch-field which is rel. slow, so only appropriate
384 ;; for mu4e-view-fields, and _not_ mu4e-headers-fields
385 :function (lambda (msg)
386 (or (string-join (seq-take (split-string (or (mu4e-fetch-field msg "X-Spam-Status") "") " ") 2) " ") "")))))
387 (add-to-list 'mu4e-view-fields :spam-status)
388 ;; Resize image attachments when sending email
389 (defvar mu4e-resize-image-types '("jpg" "png" "svg" "jpeg")
390 "List of attached image types to resize.")
391 (defvar mu4e-inhibit-resize nil)
392 (defun mu4e-resize-image-attachments ()
393 (unless mu4e-inhibit-resize
396 (mapconcat #'identity mu4e-resize-image-types "\\|")))
398 (message-goto-body-1)
399 (while (re-search-forward
400 (format "<#part.+\\(filename=\"\\)\\(.+\\(\\.%s\\)\\)\""
403 (let* ((infile (match-string-no-properties 2))
404 (outfile (concat (temporary-file-directory)
405 (file-name-nondirectory infile))))
406 (push (format "magick convert %s -resize 1200x1200\\> %s"
407 (shell-quote-argument infile)
408 (shell-quote-argument outfile))
410 (replace-match outfile t t nil 2)))
411 (mapcar #'shell-command cmds)))))
412 (add-hook 'message-send-hook 'mu4e-resize-image-attachments)
413 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode) ;; Attach files to messages using dired C-c RET C-a
414 (defun mu4e-inhibit-resize()
416 (set (make-local-variable 'mu4e-inhibit-resize) t)))
418 ;; Load configuration for website
419 ;(load "mustache-html")
424 :hook (dired-mode . denote-dired-mode)
426 (("C-c n n" . denote)
427 ("C-c n r" . denote-rename-file)
428 ("C-c n l" . denote-link)
429 ("C-c n b" . denote-backlinks))
431 (setq denote-directory "/home/frederik/Nextcloud/notes/")
432 (denote-rename-buffer-mode 1))
434 (use-package nerd-icons
436 ;; The Nerd Font you want to use in GUI
437 ;; "Symbols Nerd Font Mono" is the default and is recommended
438 ;; but you can use any other Nerd Font if you want
439 ;; (nerd-icons-font-family "Symbols Nerd Font Mono")
442 ;; Dired configuration
443 (with-eval-after-load 'dired
445 ;; Set dired-x global variables here. For example:
446 ;; (setq dired-x-hands-off-my-keys nil)
448 (add-hook 'dired-mode-hook
450 ;; Set dired-x buffer-local variables here.
452 (dired-hide-details-mode 1)
453 (nerd-icons-dired-mode 1)
455 (setq delete-by-moving-to-trash t)
456 (setq dired-guess-shell-alist-user
457 '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open")
458 ("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open")
461 ;; Use `vertico' package to get a vertical view of the minibuffer.
465 (setq vertico-resize nil)
468 ;; Persist history over Emacs restarts. Vertico sorts by history position.
469 (use-package savehist
473 ;; Use `marginalia' package. This will display useful
474 ;; annotations next to entries in the minibuffer. For example, when
475 ;; using M-x it will show a brief description of the command as well
476 ;; as the keybinding associated with it (if any).
477 (use-package marginalia
482 ;; Use 'winner' mode to undo and redo windows changes
483 ;; using C-c <left> and C-c <right>.
489 ;; Use a different spell checker, always
493 (keymap-global-set "M-$" #'jinx-correct)
494 :hook (emacs-startup . global-jinx-mode))
496 (use-package powerthesaurus
500 (transient-define-prefix my/transient-spelling ()
504 ("y" "Synonyms" powerthesaurus-lookup-synonyms-dwim)
505 ("a" "Antonyms" powerthesaurus-lookup-antonyms-dwim)]
507 ("x" "Jinx" jinx-mode)
508 ("c" "Jinx correct" jinx-correct)]
510 ("d" "Lookup" dictionary-lookup-definition)]
512 ("q" "Quit" transient-quit-one)]])
514 ("C-c s" . my/transient-spelling))
520 (keymap-global-set "C-." #'embark-act)
521 (keymap-global-set "C-;" #'embark-dwim))
526 ;; Change default bindings to consult- ones
528 (;; C-x bindings in `ctl-x-map'
529 ("C-x b" . consult-buffer) ;; orig. switch-to-buffer
530 ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
531 ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
532 ;; Other custom bindings
533 ("M-y" . consult-yank-pop))) ;; orig. yank-pop
535 (use-package consult-mu
536 :ensure nil ;; cloned in
537 :load-path "~/.emacs.d/lisp/consult-mu"
538 :after (consult mu4e)
540 ;;maximum number of results shown in minibuffer
541 (consult-mu-maxnum 200)
542 ;;show preview when pressing any keys
543 (consult-mu-preview-key 'any)
544 ;;do not mark email as read when previewed
545 (consult-mu-mark-previewed-as-read nil)
546 ;;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.
547 (consult-mu-mark-viewed-as-read nil)
548 ;; open the message in mu4e-view-buffer when selected.
549 (consult-mu-action #'consult-mu--view-action)
552 (use-package consult-denote
555 ;; Configure `world-clock'
559 (setq zoneinfo-style-world-list '(("Europe/Brussels" "Leuven")))
560 (add-to-list 'zoneinfo-style-world-list '("Australia/Perth" "Perth")))
563 ;; View PDFs in Emacs
564 (pdf-loader-install) ; On demand loading, leads to faster startup time
565 (setq pdf-misc-print-programm "/usr/bin/lpr")
573 ;; For `eat-eshell-mode'.
574 (add-hook 'eshell-load-hook #'eat-eshell-mode)
575 (setq eshell-visual-commands '()))
581 (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
583 (add-hook 'nov-mode-hook #'variable-pitch-mode))
585 ;; Set some preset fonts
586 (use-package fontaine
589 (setq fontaine-presets
591 :default-family "Iosevka Nerd Font"
593 :variable-pitch-family "Linux Biolinum O"
594 :variable-pitch-weight normal
595 :variable-pitch-height 1.1
596 :italic-family "Iosevka Etoile"
599 :default-family "Iosevka Nerd Font"
601 :variable-pitch-family "Literata"
602 :variable-pitch-weight normal
603 :variable-pitch-height 1.0
606 :default-family "Fira Mono Nerd Font"
608 :variable-pitch-family "Fira Sans Book"
609 :variable-pitch-weight normal
610 :variable-pitch-height 1.0
613 :default-family "Fira Mono Nerd Font"
615 :variable-pitch-family "Fira Sans Book"
616 :variable-pitch-weight normal
617 :variable-pitch-height 1.0
620 :variable-pitch-family "Libre Baskerville"
621 :variable-pitch-weight normal
622 :variable-pitch-height 1.0
625 :variable-pitch-family "Noto Serif"
626 :variable-pitch-weight normal
627 :variable-pitch-height 1.0
630 :variable-pitch-family "ETBembo"
631 :variable-pitch-weight normal
632 :variable-pitch-height 1.1
635 :variable-pitch-family "Literata"
636 :variable-pitch-weight normal
637 :variable-pitch-height 1.0
643 ("C-h D" . devdocs-lookup))
648 (require 'emms-setup)
649 (require 'emms-player-mpd)
650 (emms-all) ; don't change this to values you see on stackoverflow questions if you expect emms to work
651 (setq emms-player-list '(emms-player-mpd))
652 (add-to-list 'emms-info-functions 'emms-info-mpd)
653 (add-to-list 'emms-player-list 'emms-player-mpd)
655 ;; Socket is not supported
656 (setq emms-player-mpd-server-name "mea-hookani-pila")
657 (setq emms-player-mpd-server-port "6600")
658 (emms-player-mpd-connect))
662 ;; Might want to run this automatically
663 ;; using variable after-focus-change-function
664 (defun my/adjust-font-size-based-on-display ()
665 "Change size of fonts based on monitor."
667 (let* ((display-name (cdr (assq 'name (frame-monitor-attributes))))
668 (font-height (cond ((string-equal display-name "eDP-1") 140)
671 (set-face-attribute 'default (selected-frame) :height font-height)))