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)
160 (("C-c c" . org-capture)
161 ("C-c l" . org-store-link)
162 ("C-c a" . org-agenda))
164 (org-default-notes-file "~/Nextcloud/notes/inbox.org")
165 (org-agenda-files `(,org-default-notes-file "~/Nextcloud/notes/calendar-nextcloud.org"))
166 (org-capture-bookmark nil)
168 (org-capture-templates
169 '(("f" "Fleeting note" entry
170 (file+headline org-default-notes-file "Notes")
171 "* %?\nEntered on %U\n %i\n %a")
172 ("b" "Tax receipt" item
173 (file "~/Documents/belastingen/FY24-25.org")
175 ("a" "Appointment" entry
176 (file+olp+datetree "~/Nextcloud/notes/calendar-nextcloud.org")
177 "* %?\n :PROPERTIES:\n :location: %^{Location}\n :END:\n%(fv/org-capture-appointment-timestamp)\n\n"
182 ("p" "Permanent note" plain
183 (file denote-last-path)
186 :immediate-finish nil
189 ("t" "New task" entry
190 (file+headline org-default-notes-file "Tasks")
192 ("e" "Email follow-up" entry (file+headline org-default-notes-file "Tasks")
193 "* TODO %:fromname: %a %?\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+2d\") t)")))
195 (org-agenda-custom-commands
196 '(("P" "Expired calendar events" ((tags "TIMESTAMP<=\"<now>\"")))
197 ("n" "Agenda and all TODOs" ((agenda "") (alltodo "")))))
200 (defun my/opened-buffer-files ()
201 "Return the list of org files currently opened in emacs"
204 (if (and (buffer-file-name x)
205 (string-match "\\.org$"
206 (buffer-file-name x)))
207 (buffer-file-name x)))
209 (setq org-refile-targets `((my/opened-buffer-files :maxlevel . 9)
210 (,(file-expand-wildcards "~/Nextcloud/notes/*.org") :maxlevel . 1)))
211 (setq org-agenda-skip-scheduled-if-done t)
212 (setq org-agenda-skip-deadline-if-done t)
213 (setq org-agenda-start-on-weekday nil)
214 (setq org-log-done 'time)
216 (defun fv/org-babel-after-execute-redisplay ()
217 "Redisplay inline images in subtree if cursor in source block with :result graphics."
219 (when-let ((info (org-babel-get-src-block-info t))
220 (params (org-babel-process-params (nth 2 info)))
221 (result-params (cdr (assq :result-params params)))
222 ((member "graphics" result-params)))
223 (org-display-inline-images nil t)))
224 (add-hook 'org-babel-after-execute-hook #'fv/org-babel-after-execute-redisplay)
225 ;; Automatically flow lines based on window width and use
226 ;; variable width fonts in org-mode.
227 (add-hook 'org-mode-hook 'visual-line-mode)
228 (add-hook 'org-mode-hook 'variable-pitch-mode)
229 ;; org-mode support for R and LaTeX
230 (org-babel-do-load-languages
231 'org-babel-load-languages
237 (defun fv/org-capture-appointment-timestamp (&optional duration)
238 "Get an Org timestamp for an appointment.
239 Prompt for a start time, calculate the end time by adding DURATION (default 30
240 minutes), and return a formatted Org timestamp with start and end times."
241 (let* ((duration (or duration 30))
242 (start-time (org-read-date t t nil "From:"))
243 (end-time (time-add start-time (seconds-to-time (* duration 60)))))
244 (concat (format-time-string (org-time-stamp-format t) start-time)
246 (format-time-string (org-time-stamp-format t) end-time))))
248 (use-package org-caldav
251 (setq org-caldav-url "https://owncloud.vanrenterghem.biz/remote.php/dav/calendars/frederik")
252 (setq org-caldav-calendar-id "default%20calendar")
253 ;; Org filename where new entries from calendar stored
254 (setq org-caldav-inbox '(file+olp+datetree "~/Nextcloud/notes/calendar-nextcloud.org"))
255 ;; Additional Org files to check for calendar events
256 (setq org-caldav-files `(,org-default-notes-file))
257 (setq org-export-with-broken-links t)
258 ;; This makes sure to-do items as a category can show up on the calendar
259 (setq org-icalendar-include-todo t)
260 ;; This ensures all org "deadlines" show up, and show up as due dates
261 (setq org-icalendar-use-deadline '(event-if-todo event-if-not-todo todo-due))
262 ;; This ensures "scheduled" org items show up, and show up as start times
263 (setq org-icalendar-use-scheduled '(todo-start event-if-todo event-if-not-todo))
264 ;; Usually a good idea to set the timezone manually
265 (setq org-icalendar-timezone "Australia/Perth")
266 (setq org-caldav-delete-calendar-entries 'ask))
268 (use-package org-protocol)
270 (use-package edraw-org
271 :ensure nil ;; cloned in
272 :load-path "~/.emacs.d/lisp/el-easydraw/"
275 (edraw-org-setup-default)
276 (edraw-org-setup-exporter))
281 (setq TeX-auto-save t
283 TeX-view-program-selection
284 '(((output-dvi has-no-display-manager)
286 ((output-dvi style-pstricks)
289 (output-pdf "PDF Tools")
290 (output-html "xdg-open"))))
291 ;; (load "preview-latex.el" nil t t)
294 ;; Automatically switch to various modes
295 (setq auto-mode-alist
296 '(("\\.mdwn\\'" . markdown-mode)
297 ("\\.md\\'" . markdown-mode)
298 ("\\.yarn\\'" . markdown-mode)
299 ("\\.cpp\\'" . c++-mode)
300 ("\\.js\\'" . js-mode)
301 ("\\.json\\'" . js-mode)
302 ("Makefile" . makefile-mode)
303 ("README" . markdown-mode)
304 ("NEWS" . markdown-mode)
305 ("COMMIT_EDITMSG\\'" . text-mode)
306 ("\\.html\\'" . html-mode)
307 ("\\.css\\'" . css-mode)
308 ("\\.yaml\\'" . yaml-mode)
309 ("\\.yml\\'" . yaml-mode)
310 ("\\.ick\\'" . yaml-mode)
311 ("\\.py\\'" . python-mode)
313 ("\\.org\\'" . org-mode)
314 ("\\.tex\\'" . latex-mode)
315 ("\\.sh\\'" . shell-script-mode)
316 ("\\.hs\\'" . haskell-mode)
317 ("\\.el\\'" . emacs-lisp-mode)))
319 ;; Send mail using SMTP via mail.vanrenterghem.io.
320 (setq send-mail-function 'smtpmail-send-it)
321 (setq smtpmail-smtp-server "mail.vanrenterghem.io"
322 smtpmail-smtp-service 587
323 smtpmail-stream-type 'starttls)
324 (setq user-full-name "Frederik Vanrenterghem"
325 smtpmail-local-domain "vanrenterghem.io"
326 user-mail-address (concat "frederik@" smtpmail-local-domain))
327 ;; Ignored in mu4e as it sets user-agent
328 (setq mail-default-headers
329 (concat "X-Mailer: GNU Emacs " (symbol-value 'emacs-version)))
330 (setq w3m-pop-up-frames t)
332 (setq gnus-select-method '(nntp "news.eternal-september.org"
333 (nntp-open-connection-function nntp-open-tls-stream)
334 (nntp-port-number 563)
335 (nntp-authinfo-user "frederikv")
336 (nntp-authinfo-force t)))
338 (global-set-key [remap list-buffers] 'ibuffer)
340 ;;; use pass (~/.password-store)
341 ;;; (see The Unix password store)
345 (auth-source-pass-enable)
346 (setq pass-username-field "Username"))
348 ;; Elfeed news reader from Nextcloud
352 (setq elfeed-use-curl nil)
353 (elfeed-set-timeout 36000)
354 (define-key elfeed-search-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-search-toggle-all '(star))))
355 (define-key elfeed-show-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-show-tag '(star))))
356 (add-hook 'elfeed-show-mode 'variable-pitch-mode))
358 (use-package elfeed-protocol
362 (setq elfeed-protocol-feeds '(
363 ("owncloud+https://frederik@owncloud.vanrenterghem.biz" :use-authinfo t)
365 (elfeed-protocol-enable))
368 ;; Read and write email using mu4e
371 ;; :ensure-system-package mu ;; Install from aur
373 (setq mail-user-agent 'mu4e-user-agent)
374 ;; Also use mu4e when called from gnus-dired-attach
375 (setq gnus-dired-mail-mode 'mu4e-user-agent
376 mu4e-get-mail-command "mbsync io"
377 mu4e-update-interval 600
378 mu4e-use-fancy-chars t
379 mu4e-view-show-images t
380 mu4e-sent-folder "/Sent"
381 mu4e-drafts-folder "/Drafts"
382 mu4e-trash-folder "/Trash"
383 message-kill-buffer-on-exit t
384 ;;Fixing duplicate UID errors when using mbsync and mu4e
385 mu4e-change-filenames-when-moving t)
386 ;; attach files to mu4e messages by marking the file(s) in dired and pressing C-c RET C-a
387 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
388 ;; Define all bookmarks starting with favourite query used in mailcount modeline
390 '(( :name "Last 24h's messages"
393 :query "date:24h..now AND NOT flag:trashed")
394 ( :name "Unread messages"
395 :query "flag:unread AND NOT flag:trashed"
397 ( :name "Today's messages"
398 :query "date:today..now AND NOT flag:trashed"
400 ( :name "Last 7 days"
401 :query "date:7d..now AND NOT flag:trashed"
404 ( :name "Messages with images"
405 :query "mime:image/* AND NOT flag:trashed"
407 ;; Create custom spam status header and show in message view
408 (add-to-list 'mu4e-header-info-custom
410 ( :name "Spam-Status" ;; long name, as seen in the message-view
411 :shortname "Spam" ;; short name, as seen in the headers view
412 :help "The Spam status" ;; tooltip
413 ;; uses mu4e-fetch-field which is rel. slow, so only appropriate
414 ;; for mu4e-view-fields, and _not_ mu4e-headers-fields
415 :function (lambda (msg)
416 (or (string-join (seq-take (split-string (or (mu4e-fetch-field msg "X-Spam-Status") "") " ") 2) " ") "")))))
417 (add-to-list 'mu4e-view-fields :spam-status)
418 ;; Resize image attachments when sending email
419 (defvar mu4e-resize-image-types '("jpg" "png" "svg" "jpeg")
420 "List of attached image types to resize.")
421 (defvar mu4e-inhibit-resize nil)
422 (defun mu4e-resize-image-attachments ()
423 (unless mu4e-inhibit-resize
426 (mapconcat #'identity mu4e-resize-image-types "\\|")))
428 (message-goto-body-1)
429 (while (re-search-forward
430 (format "<#part.+\\(filename=\"\\)\\(.+\\(\\.%s\\)\\)\""
433 (let* ((infile (match-string-no-properties 2))
434 (outfile (concat (temporary-file-directory)
435 (file-name-nondirectory infile))))
436 (push (format "magick convert %s -resize 1200x1200\\> %s"
437 (shell-quote-argument infile)
438 (shell-quote-argument outfile))
440 (replace-match outfile t t nil 2)))
441 (mapcar #'shell-command cmds)))))
442 (add-hook 'message-send-hook 'mu4e-resize-image-attachments)
443 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode) ;; Attach files to messages using dired C-c RET C-a
444 (defun mu4e-inhibit-resize()
446 (set (make-local-variable 'mu4e-inhibit-resize) t)))
448 ;; Load configuration for website
449 ;(load "mustache-html")
454 :hook (dired-mode . denote-dired-mode)
456 (("C-c n n" . denote)
457 ("C-c n r" . denote-rename-file)
458 ("C-c n l" . denote-link)
459 ("C-c n b" . denote-backlinks))
461 (setq denote-directory "/home/frederik/Nextcloud/notes/")
462 (denote-rename-buffer-mode 1))
464 (use-package nerd-icons
466 ;; The Nerd Font you want to use in GUI
467 ;; "Symbols Nerd Font Mono" is the default and is recommended
468 ;; but you can use any other Nerd Font if you want
469 ;; (nerd-icons-font-family "Symbols Nerd Font Mono")
472 ;; Dired configuration
473 (with-eval-after-load 'dired
475 ;; Set dired-x global variables here. For example:
476 ;; (setq dired-x-hands-off-my-keys nil)
478 (add-hook 'dired-mode-hook
480 ;; Set dired-x buffer-local variables here.
482 (dired-hide-details-mode 1)
483 (nerd-icons-dired-mode 1)
485 (setq delete-by-moving-to-trash t)
486 (setq dired-guess-shell-alist-user
487 '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open")
488 ("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open")
491 ;; Use `vertico' package to get a vertical view of the minibuffer.
495 (setq vertico-resize nil)
498 ;; Persist history over Emacs restarts. Vertico sorts by history position.
499 (use-package savehist
503 ;; Use `marginalia' package. This will display useful
504 ;; annotations next to entries in the minibuffer. For example, when
505 ;; using M-x it will show a brief description of the command as well
506 ;; as the keybinding associated with it (if any).
507 (use-package marginalia
512 ;; Use 'winner' mode to undo and redo windows changes
513 ;; using C-c <left> and C-c <right>.
519 ;; Use a different spell checker, always
523 (keymap-global-set "M-$" #'jinx-correct)
524 :hook (emacs-startup . global-jinx-mode))
526 (use-package powerthesaurus
530 (transient-define-prefix my/transient-spelling ()
534 ("y" "Synonyms" powerthesaurus-lookup-synonyms-dwim)
535 ("a" "Antonyms" powerthesaurus-lookup-antonyms-dwim)]
537 ("x" "Jinx" jinx-mode)
538 ("c" "Jinx correct" jinx-correct)]
540 ("d" "Lookup" dictionary-lookup-definition)]
542 ("q" "Quit" transient-quit-one)]])
544 ("C-c s" . my/transient-spelling))
550 (keymap-global-set "C-." #'embark-act)
551 (keymap-global-set "C-;" #'embark-dwim))
556 ;; Change default bindings to consult- ones
558 (;; C-x bindings in `ctl-x-map'
559 ("C-x b" . consult-buffer) ;; orig. switch-to-buffer
560 ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
561 ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
562 ;; Other custom bindings
563 ("M-y" . consult-yank-pop))) ;; orig. yank-pop
565 (use-package consult-mu
566 :ensure nil ;; cloned in
567 :load-path "~/.emacs.d/lisp/consult-mu"
568 :after (consult mu4e)
570 ;;maximum number of results shown in minibuffer
571 (consult-mu-maxnum 200)
572 ;;show preview when pressing any keys
573 (consult-mu-preview-key 'any)
574 ;;do not mark email as read when previewed
575 (consult-mu-mark-previewed-as-read nil)
576 ;;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.
577 (consult-mu-mark-viewed-as-read nil)
578 ;; open the message in mu4e-view-buffer when selected.
579 (consult-mu-action #'consult-mu--view-action)
582 (use-package consult-denote
585 ;; Configure `world-clock'
589 (setq zoneinfo-style-world-list '(("Europe/Brussels" "Leuven")))
590 (add-to-list 'zoneinfo-style-world-list '("Australia/Perth" "Perth")))
593 ;; View PDFs in Emacs
594 (pdf-loader-install) ; On demand loading, leads to faster startup time
595 (setq pdf-misc-print-programm "/usr/bin/lpr")
603 ;; For `eat-eshell-mode'.
604 (add-hook 'eshell-load-hook #'eat-eshell-mode)
605 (setq eshell-visual-commands '()))
611 (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
613 (add-hook 'nov-mode-hook #'variable-pitch-mode))
615 ;; Set some preset fonts
616 (use-package fontaine
619 (setq fontaine-presets
621 :default-family "Iosevka Nerd Font"
623 :variable-pitch-family "Linux Biolinum O"
624 :variable-pitch-weight normal
625 :variable-pitch-height 1.1
626 :italic-family "Iosevka Etoile"
629 :default-family "Iosevka Nerd Font"
631 :variable-pitch-family "Literata"
632 :variable-pitch-weight normal
633 :variable-pitch-height 1.0
636 :default-family "Fira Mono Nerd Font"
638 :variable-pitch-family "Fira Sans Book"
639 :variable-pitch-weight normal
640 :variable-pitch-height 1.0
643 :default-family "Fira Mono Nerd Font"
645 :variable-pitch-family "Fira Sans Book"
646 :variable-pitch-weight normal
647 :variable-pitch-height 1.0
650 :variable-pitch-family "Libre Baskerville"
651 :variable-pitch-weight normal
652 :variable-pitch-height 1.0
655 :variable-pitch-family "Noto Serif"
656 :variable-pitch-weight normal
657 :variable-pitch-height 1.0
660 :variable-pitch-family "ETBembo"
661 :variable-pitch-weight normal
662 :variable-pitch-height 1.1
665 :variable-pitch-family "Literata"
666 :variable-pitch-weight normal
667 :variable-pitch-height 1.0
673 ("C-h D" . devdocs-lookup))
678 (require 'emms-setup)
679 (require 'emms-player-mpd)
680 (emms-all) ; don't change this to values you see on stackoverflow questions if you expect emms to work
681 (setq emms-player-list '(emms-player-mpd))
682 (add-to-list 'emms-info-functions 'emms-info-mpd)
683 (add-to-list 'emms-player-list 'emms-player-mpd)
685 ;; Socket is not supported
686 (setq emms-player-mpd-server-name "mea-hookani-pila")
687 (setq emms-player-mpd-server-port "6600")
688 (emms-player-mpd-connect))
692 ;; Might want to run this automatically
693 ;; using variable after-focus-change-function
694 (defun my/adjust-font-size-based-on-display ()
695 "Change size of fonts based on monitor."
697 (let* ((display-name (cdr (assq 'name (frame-monitor-attributes))))
698 (font-height (cond ((string-equal display-name "eDP-1") 140)
701 (set-face-attribute 'default (selected-frame) :height font-height)))