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
63 ;; enable autocomplete
66 ;; Optional customizations
68 (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
69 (corfu-auto t) ;; Enable auto completion
70 ;; (corfu-separator ?\s) ;; Orderless field separator
71 ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
72 ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
73 ;; (corfu-preview-current nil) ;; Disable current candidate preview
74 ;; (corfu-preselect 'prompt) ;; Preselect the prompt
75 ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
76 ;; (corfu-scroll-margin 5) ;; Use scroll margin
78 ;; Enable Corfu only for certain modes. See also `global-corfu-modes'.
79 ;; :hook ((prog-mode . corfu-mode)
80 ;; (shell-mode . corfu-mode)
81 ;; (eshell-mode . corfu-mode))
83 ;; Recommended: Enable Corfu globally. This is recommended since Dabbrev can
84 ;; be used globally (M-/). See also the customization variable
85 ;; `global-corfu-modes' to exclude certain modes.
92 ;; Bind prefix keymap providing all Cape commands under a mnemonic key.
93 ;; Press C-c p ? to for help.
94 :bind ("C-c p" . cape-prefix-map) ;; Alternative keys: M-p, M-+, ...
95 ;; Alternatively bind Cape commands individually.
96 ;; :bind (("C-c p d" . cape-dabbrev)
97 ;; ("C-c p h" . cape-history)
98 ;; ("C-c p f" . cape-file)
101 ;; Add to the global default value of `completion-at-point-functions' which is
102 ;; used by `completion-at-point'. The order of the functions matters, the
103 ;; first function returning a result wins. Note that the list of buffer-local
104 ;; completion functions takes precedence over the global list.
105 (add-hook 'completion-at-point-functions #'cape-dict) ;; requires words package to be installed on Arch to provide /usr/share/dict/words
106 (add-hook 'completion-at-point-functions #'cape-dabbrev)
107 (add-hook 'completion-at-point-functions #'cape-file)
108 (add-hook 'completion-at-point-functions #'cape-elisp-block)
109 ;; (add-hook 'completion-at-point-functions #'cape-history)
116 (("C-c c" . org-capture)
117 ("C-c l" . org-store-link)
118 ("C-c a" . org-agenda))
120 (org-default-notes-file "~/Nextcloud/notes/inbox.org")
121 (org-agenda-files `(,org-default-notes-file "~/Nextcloud/notes/calendar-nextcloud.org"))
122 (org-capture-bookmark nil)
124 (org-capture-templates
125 '(("f" "Fleeting note" entry
126 (file+headline org-default-notes-file "Notes")
127 "* %?\nEntered on %U\n %i\n %a")
128 ("b" "Tax receipt" item
129 (file "~/Documents/belastingen/FY24-25.org")
131 ("a" "Appointment" entry
132 (file+olp+datetree "~/Nextcloud/notes/calendar-nextcloud.org")
133 "* %?\n :PROPERTIES:\n :location: %^{Location}\n :END:\n%(fv/org-capture-appointment-timestamp)\n\n"
138 ("p" "Permanent note" plain
139 (file denote-last-path)
142 :immediate-finish nil
145 ("t" "New task" entry
146 (file+headline org-default-notes-file "Tasks")
148 ("e" "Email follow-up" entry (file+headline org-default-notes-file "Tasks")
149 "* TODO %:fromname: %a %?\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+2d\") t)")))
151 (org-agenda-custom-commands
152 '(("P" "Expired calendar events" ((tags "TIMESTAMP<=\"<now>\"")))
153 ("n" "Agenda and all TODOs" ((agenda "") (alltodo "")))))
156 (defun my/opened-buffer-files ()
157 "Return the list of org files currently opened in emacs"
160 (if (and (buffer-file-name x)
161 (string-match "\\.org$"
162 (buffer-file-name x)))
163 (buffer-file-name x)))
165 (setq org-refile-targets `((my/opened-buffer-files :maxlevel . 9)
166 (,(file-expand-wildcards "~/Nextcloud/notes/*.org") :maxlevel . 1)))
167 (setq org-agenda-skip-scheduled-if-done t)
168 (setq org-agenda-skip-deadline-if-done t)
169 (setq org-agenda-start-on-weekday nil)
170 (setq org-log-done 'time)
171 ;; Automatically flow lines based on window width and use
172 ;; variable width fonts in org-mode.
173 (add-hook 'org-mode-hook 'visual-line-mode)
174 (add-hook 'org-mode-hook 'variable-pitch-mode)
175 ;; org-mode support for R and LaTeX
176 (org-babel-do-load-languages
177 'org-babel-load-languages
181 (defun fv/org-capture-appointment-timestamp (&optional duration)
182 "Get an Org timestamp for an appointment.
183 Prompt for a start time, calculate the end time by adding DURATION (default 30
184 minutes), and return a formatted Org timestamp with start and end times."
185 (let* ((duration (or duration 30))
186 (start-time (org-read-date t t nil "From:"))
187 (end-time (time-add start-time (seconds-to-time (* duration 60)))))
188 (concat (format-time-string (org-time-stamp-format t) start-time)
190 (format-time-string (org-time-stamp-format t) end-time))))
192 (use-package org-caldav
195 (setq org-caldav-url "https://owncloud.vanrenterghem.biz/remote.php/dav/calendars/frederik")
196 (setq org-caldav-calendar-id "default%20calendar")
197 ;; Org filename where new entries from calendar stored
198 (setq org-caldav-inbox '(file+olp+datetree "~/Nextcloud/notes/calendar-nextcloud.org"))
199 ;; Additional Org files to check for calendar events
200 (setq org-caldav-files nil)
201 ;; Usually a good idea to set the timezone manually
202 (setq org-icalendar-timezone "Australia/Perth")
203 (setq org-caldav-delete-calendar-entries 'ask))
205 (use-package org-protocol)
210 (setq TeX-auto-save t
212 TeX-view-program-selection
213 '(((output-dvi has-no-display-manager)
215 ((output-dvi style-pstricks)
218 (output-pdf "PDF Tools")
219 (output-html "xdg-open"))))
220 ;; (load "preview-latex.el" nil t t)
223 ;; Automatically switch to various modes
224 (setq auto-mode-alist
225 '(("\\.mdwn\\'" . markdown-mode)
226 ("\\.md\\'" . markdown-mode)
227 ("\\.yarn\\'" . markdown-mode)
228 ("\\.cpp\\'" . c++-mode)
229 ("\\.js\\'" . js-mode)
230 ("\\.json\\'" . js-mode)
231 ("Makefile" . makefile-mode)
232 ("README" . markdown-mode)
233 ("NEWS" . markdown-mode)
234 ("COMMIT_EDITMSG\\'" . text-mode)
235 ("\\.html\\'" . html-mode)
236 ("\\.css\\'" . css-mode)
237 ("\\.yaml\\'" . yaml-mode)
238 ("\\.yml\\'" . yaml-mode)
239 ("\\.ick\\'" . yaml-mode)
240 ("\\.py\\'" . python-mode)
242 ("\\.org\\'" . org-mode)
243 ("\\.tex\\'" . latex-mode)
244 ("\\.sh\\'" . shell-script-mode)
245 ("\\.hs\\'" . haskell-mode)
246 ("\\.el\\'" . emacs-lisp-mode)))
248 ;; Send mail using SMTP via mail.vanrenterghem.io.
249 (setq send-mail-function 'smtpmail-send-it)
250 (setq smtpmail-smtp-server "mail.vanrenterghem.io"
251 smtpmail-smtp-service 587
252 smtpmail-stream-type 'starttls)
253 (setq user-full-name "Frederik Vanrenterghem"
254 smtpmail-local-domain "vanrenterghem.io"
255 user-mail-address (concat "frederik@" smtpmail-local-domain))
256 ;; Ignored in mu4e as it sets user-agent
257 (setq mail-default-headers
258 (concat "X-Mailer: GNU Emacs " (symbol-value 'emacs-version)))
259 (setq w3m-pop-up-frames t)
261 (setq gnus-select-method '(nntp "news.eternal-september.org"
262 (nntp-open-connection-function nntp-open-tls-stream)
263 (nntp-port-number 563)
264 (nntp-authinfo-user "frederikv")
265 (nntp-authinfo-force t)))
267 (global-set-key [remap list-buffers] 'ibuffer)
269 ;;; use pass (~/.password-store)
270 ;;; (see The Unix password store)
274 (auth-source-pass-enable)
275 (setq pass-username-field "Username"))
277 ;; Elfeed news reader from Nextcloud
281 (setq elfeed-use-curl nil)
282 (elfeed-set-timeout 36000)
283 (define-key elfeed-search-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-search-toggle-all '(star))))
284 (define-key elfeed-show-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-show-tag '(star))))
285 (add-hook 'elfeed-show-mode 'variable-pitch-mode))
287 (use-package elfeed-protocol
291 (setq elfeed-protocol-feeds '(
292 ("owncloud+https://frederik@owncloud.vanrenterghem.biz" :use-authinfo t)
294 (elfeed-protocol-enable))
297 ;; Read and write email using mu4e
300 ;; :ensure-system-package mu ;; Install from aur
302 (setq mail-user-agent 'mu4e-user-agent)
303 ;; Also use mu4e when called from gnus-dired-attach
304 (setq gnus-dired-mail-mode 'mu4e-user-agent
305 mu4e-get-mail-command "mbsync io"
306 mu4e-update-interval 600
307 mu4e-use-fancy-chars t
308 mu4e-view-show-images t
309 mu4e-sent-folder "/Sent"
310 mu4e-drafts-folder "/Drafts"
311 mu4e-trash-folder "/Trash"
312 message-kill-buffer-on-exit t
313 ;;Fixing duplicate UID errors when using mbsync and mu4e
314 mu4e-change-filenames-when-moving t)
315 ;; attach files to mu4e messages by marking the file(s) in dired and pressing C-c RET C-a
316 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
317 ;; Define all bookmarks starting with favourite query used in mailcount modeline
319 '(( :name "Last 24h's messages"
322 :query "date:24h..now AND NOT flag:trashed")
323 ( :name "Unread messages"
324 :query "flag:unread AND NOT flag:trashed"
326 ( :name "Today's messages"
327 :query "date:today..now AND NOT flag:trashed"
329 ( :name "Last 7 days"
330 :query "date:7d..now AND NOT flag:trashed"
333 ( :name "Messages with images"
334 :query "mime:image/* AND NOT flag:trashed"
336 ;; Create custom spam status header and show in message view
337 (add-to-list 'mu4e-header-info-custom
339 ( :name "Spam-Status" ;; long name, as seen in the message-view
340 :shortname "Spam" ;; short name, as seen in the headers view
341 :help "The Spam status" ;; tooltip
342 ;; uses mu4e-fetch-field which is rel. slow, so only appropriate
343 ;; for mu4e-view-fields, and _not_ mu4e-headers-fields
344 :function (lambda (msg)
345 (or (string-join (seq-take (split-string (or (mu4e-fetch-field msg "X-Spam-Status") "") " ") 2) " ") "")))))
346 (add-to-list 'mu4e-view-fields :spam-status)
347 ;; Resize image attachments when sending email
348 (defvar mu4e-resize-image-types '("jpg" "png" "svg" "jpeg")
349 "List of attached image types to resize.")
350 (defvar mu4e-inhibit-resize nil)
351 (defun mu4e-resize-image-attachments ()
352 (unless mu4e-inhibit-resize
355 (mapconcat #'identity mu4e-resize-image-types "\\|")))
357 (message-goto-body-1)
358 (while (re-search-forward
359 (format "<#part.+\\(filename=\"\\)\\(.+\\(\\.%s\\)\\)\""
362 (let* ((infile (match-string-no-properties 2))
363 (outfile (concat (temporary-file-directory)
364 (file-name-nondirectory infile))))
365 (push (format "magick convert %s -resize 1200x1200\\> %s"
366 (shell-quote-argument infile)
367 (shell-quote-argument outfile))
369 (replace-match outfile t t nil 2)))
370 (mapcar #'shell-command cmds)))))
371 (add-hook 'message-send-hook 'mu4e-resize-image-attachments)
372 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode) ;; Attach files to messages using dired C-c RET C-a
373 (defun mu4e-inhibit-resize()
375 (set (make-local-variable 'mu4e-inhibit-resize) t)))
377 ;; Load configuration for website
378 ;(load "mustache-html")
383 :hook (dired-mode . denote-dired-mode)
385 (("C-c n n" . denote)
386 ("C-c n r" . denote-rename-file)
387 ("C-c n l" . denote-link)
388 ("C-c n b" . denote-backlinks))
390 (setq denote-directory "/home/frederik/Nextcloud/notes/")
391 (denote-rename-buffer-mode 1))
393 (use-package nerd-icons
395 ;; The Nerd Font you want to use in GUI
396 ;; "Symbols Nerd Font Mono" is the default and is recommended
397 ;; but you can use any other Nerd Font if you want
398 ;; (nerd-icons-font-family "Symbols Nerd Font Mono")
401 ;; Dired configuration
402 (with-eval-after-load 'dired
404 ;; Set dired-x global variables here. For example:
405 ;; (setq dired-x-hands-off-my-keys nil)
407 (add-hook 'dired-mode-hook
409 ;; Set dired-x buffer-local variables here.
411 (dired-hide-details-mode 1)
412 (nerd-icons-dired-mode 1)
414 (setq delete-by-moving-to-trash t)
415 (setq dired-guess-shell-alist-user
416 '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open")
417 ("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open")
420 ;; Use `vertico' package to get a vertical view of the minibuffer.
424 (setq vertico-resize nil)
427 ;; Persist history over Emacs restarts. Vertico sorts by history position.
428 (use-package savehist
432 ;; Use `marginalia' package. This will display useful
433 ;; annotations next to entries in the minibuffer. For example, when
434 ;; using M-x it will show a brief description of the command as well
435 ;; as the keybinding associated with it (if any).
436 (use-package marginalia
441 ;; Use 'winner' mode to undo and redo windows changes
442 ;; using C-c <left> and C-c <right>.
448 ;; Use a different spell checker, always
452 (keymap-global-set "M-$" #'jinx-correct)
453 :hook (emacs-startup . global-jinx-mode))
455 (use-package powerthesaurus
459 (transient-define-prefix my/transient-spelling ()
463 ("y" "Synonyms" powerthesaurus-lookup-synonyms-dwim)
464 ("a" "Antonyms" powerthesaurus-lookup-antonyms-dwim)]
466 ("x" "Jinx" jinx-mode)
467 ("c" "Jinx correct" jinx-correct)]
469 ("d" "Lookup" dictionary-lookup-definition)]
471 ("q" "Quit" transient-quit-one)]])
473 ("C-c s" . my/transient-spelling))
479 (keymap-global-set "C-." #'embark-act)
480 (keymap-global-set "C-;" #'embark-dwim))
485 ;; Change default bindings to consult- ones
487 (;; C-x bindings in `ctl-x-map'
488 ("C-x b" . consult-buffer) ;; orig. switch-to-buffer
489 ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
490 ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
491 ;; Other custom bindings
492 ("M-y" . consult-yank-pop))) ;; orig. yank-pop
494 (use-package consult-mu
495 :ensure nil ;; cloned in
496 :load-path "~/.emacs.d/lisp/consult-mu"
497 :after (consult mu4e)
499 ;;maximum number of results shown in minibuffer
500 (consult-mu-maxnum 200)
501 ;;show preview when pressing any keys
502 (consult-mu-preview-key 'any)
503 ;;do not mark email as read when previewed
504 (consult-mu-mark-previewed-as-read nil)
505 ;;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.
506 (consult-mu-mark-viewed-as-read nil)
507 ;; open the message in mu4e-view-buffer when selected.
508 (consult-mu-action #'consult-mu--view-action)
511 (use-package consult-denote
514 ;; Configure `world-clock'
518 (setq zoneinfo-style-world-list '(("Europe/Brussels" "Leuven")))
519 (add-to-list 'zoneinfo-style-world-list '("Australia/Perth" "Perth")))
522 ;; View PDFs in Emacs
523 (pdf-loader-install) ; On demand loading, leads to faster startup time
524 (setq pdf-misc-print-programm "/usr/bin/lpr")
532 ;; For `eat-eshell-mode'.
533 (add-hook 'eshell-load-hook #'eat-eshell-mode)
534 (setq eshell-visual-commands '()))
540 (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
542 (add-hook 'nov-mode-hook #'variable-pitch-mode))
544 ;; Set some preset fonts
545 (use-package fontaine
548 (setq fontaine-presets
550 :default-family "Iosevka Nerd Font"
552 :variable-pitch-family "Linux Biolinum O"
553 :variable-pitch-weight normal
554 :variable-pitch-height 1.1
555 :italic-family "Iosevka Etoile"
558 :default-family "Iosevka Nerd Font"
560 :variable-pitch-family "Literata"
561 :variable-pitch-weight normal
562 :variable-pitch-height 1.0
565 :default-family "Fira Mono Nerd Font"
567 :variable-pitch-family "Fira Sans Book"
568 :variable-pitch-weight normal
569 :variable-pitch-height 1.0
572 :default-family "Fira Mono Nerd Font"
574 :variable-pitch-family "Fira Sans Book"
575 :variable-pitch-weight normal
576 :variable-pitch-height 1.0
579 :variable-pitch-family "Libre Baskerville"
580 :variable-pitch-weight normal
581 :variable-pitch-height 1.0
584 :variable-pitch-family "Noto Serif"
585 :variable-pitch-weight normal
586 :variable-pitch-height 1.0
589 :variable-pitch-family "ETBembo"
590 :variable-pitch-weight normal
591 :variable-pitch-height 1.1
594 :variable-pitch-family "Literata"
595 :variable-pitch-weight normal
596 :variable-pitch-height 1.0
602 ("C-h D" . devdocs-lookup))
607 (require 'emms-setup)
608 (require 'emms-player-mpd)
609 (emms-all) ; don't change this to values you see on stackoverflow questions if you expect emms to work
610 (setq emms-player-list '(emms-player-mpd))
611 (add-to-list 'emms-info-functions 'emms-info-mpd)
612 (add-to-list 'emms-player-list 'emms-player-mpd)
614 ;; Socket is not supported
615 (setq emms-player-mpd-server-name "mea-hookani-pila")
616 (setq emms-player-mpd-server-port "6600")
617 (emms-player-mpd-connect))
621 ;; Might want to run this automatically
622 ;; using variable after-focus-change-function
623 (defun my/adjust-font-size-based-on-display ()
624 "Change size of fonts based on monitor."
626 (let* ((display-name (cdr (assq 'name (frame-monitor-attributes))))
627 (font-height (cond ((string-equal display-name "eDP-1") 140)
630 (set-face-attribute 'default (selected-frame) :height font-height)))