]> git.vanrenterghem.biz Git - Dotty.git/blob - emacs/.emacs.d/init.el
Voeg Zathura Emacs keybindings toe.
[Dotty.git] / emacs / .emacs.d / init.el
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.
5 (package-initialize)
7 (add-to-list 'load-path "~/.emacs.d/lisp/")
9 ;; Use a dark theme now
10 ;(load-theme 'wheatgrass)
12 ;; Use light theme
13 ;;(load-theme 'leuven t)
14 (require 'modus-themes)
15 (load-theme 'modus-operandi t)
16 (setq modus-themes-mixed-fonts t)
18 ;; ESS - for working in R
19 (autoload 'R-mode "ess-site.el" "Major mode for editing R source." t)
20 (setq load-path (cons "/usr/share/emacs/site-lisp/ess" load-path))
21 (load "/usr/share/emacs/site-lisp/ess/lisp/ess-site")
22 (setq inferior-julia-program-name "/usr/bin/julia")
24 ;; enable autocomplete
25 (add-hook 'after-init-hook 'global-company-mode)
27 (require 'org)
29 ;; Automatically flow lines based on window width and use
30 ;; variable width fonts in org-mode.
31 (add-hook 'org-mode-hook 'visual-line-mode)
32 (add-hook 'org-mode-hook 'variable-pitch-mode)
34 ;; Auctex
35 (load "auctex.el" nil t t)
36 (load "preview-latex.el" nil t t)
38 ;; org-mode support for R and LaTeX
39 (org-babel-do-load-languages
40  'org-babel-load-languages
41  '((R . t)
42    (latex . t)))
43 ;; Security risk - This is somewhat ill-advised it appears
44 (setq org-confirm-babel-evaluate nil)
46 ;; Automatically switch to various modes
47 (setq auto-mode-alist
48     '(("\\.mdwn\\'" . markdown-mode)
49       ("\\.md\\'" . markdown-mode)
50       ("\\.yarn\\'" . markdown-mode)
51       ("\\.js\\'" . js-mode)
52       ("\\.json\\'" . js-mode)
53       ("Makefile" . makefile-mode)
54       ("README" . markdown-mode)
55       ("NEWS" . markdown-mode)
56       ("COMMIT_EDITMSG\\'" . text-mode)
57       ("\\.html\\'" . html-mode)
58       ("\\.css\\'" . css-mode)
59       ("\\.yaml\\'" . yaml-mode)
60       ("\\.yml\\'" . yaml-mode)
61       ("\\.ick\\'" . yaml-mode)
62       ("\\.py\\'" . python-mode)
63       ("\\.R\\'" . R-mode)
64       ("\\.org\\'" . org-mode)
65       ("\\.sh\\'" . shell-script-mode)
66       ("\\.hs\\'" . haskell-mode)
67       ("\\.el\\'" . emacs-lisp-mode)))
69 ;; Enable the melpa archive for packages
70 (require 'package)
71 (setq package-enable-at-startup nil)
72 (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
73 (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
74 (add-to-list 'package-archives
75              '("elpy" . "http://jorgenschaefer.github.io/packages/"))
77 (custom-set-variables
78  ;; custom-set-variables was added by Custom.
79  ;; If you edit it by hand, you could mess it up, so be careful.
80  ;; Your init file should contain only one such instance.
81  ;; If there is more than one, they won't work right.
82  '(browse-url-browser-function 'browse-url-firefox)
83  '(custom-safe-themes
84    '("0cf95236abcf59e05b1ea69b4edd53d293a5baec4fe4c3484543fee99bfd2204" "80b00f3bf7cdbdca6c80aadfbbb03145f3d0aacf6bf2a559301e61109954e30a" default))
85  '(denote-directory "/home/frederik/Nextcloud/notes/" t)
86  '(org-export-backends '(ascii html icalendar latex md odt))
87  '(package-selected-packages
88    '(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)))
89 (custom-set-faces
90  ;; custom-set-faces was added by Custom.
91  ;; If you edit it by hand, you could mess it up, so be careful.
92  ;; Your init file should contain only one such instance.
93  ;; If there is more than one, they won't work right.
94  '(default ((t (:family "Source Code Pro" :foundry "ADBO" :slant normal :weight normal :height 143 :width normal)))))
97 ;; Send mail using SMTP via mail.vanrenterghem.io.
98 (setq send-mail-function    'smtpmail-send-it)
99 (setq smtpmail-smtp-server "mail.vanrenterghem.io"
100       smtpmail-smtp-service 587
101       smtpmail-stream-type 'starttls)
102 (setq user-full-name "Frederik Vanrenterghem"
103       smtpmail-local-domain "vanrenterghem.io"
104       user-mail-address (concat "frederik@" smtpmail-local-domain))
105 (setq mail-default-headers
106       (concat "X-Mailer: GNU Emacs " (symbol-value 'emacs-version))) 
107 (setq w3m-pop-up-frames t)
109 (global-set-key [remap list-buffers] 'ibuffer)
111 ;;; use pass (~/.password-store)
112 ;;; (see The Unix password store)
113 (auth-source-pass-enable)
115 ;; Elfeed news reader from Nextcloud
116 (require 'elfeed)
117 (require 'elfeed-protocol)
119 (setq elfeed-use-curl nil)
120 (elfeed-set-timeout 36000)
121 (setq elfeed-protocol-feeds '(
122             ("owncloud+https://frederik@owncloud.vanrenterghem.biz" :use-authinfo t)
123         ))
124 (elfeed-protocol-enable)
125 (define-key elfeed-search-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-search-toggle-all '(star))))
126 (define-key elfeed-show-mode-map (kbd "*") (lambda () (interactive) (apply 'elfeed-show-tag '(star))))
128 ;; Read email using mu4e
129 (require 'mu4e)
130 (setq mail-user-agent 'mu4e-user-agent)
131 (setq mu4e-get-mail-command "mbsync io")
132 (setq mu4e-update-interval 600)
133 (setq mu4e-use-fancy-chars t)
134 (setq mu4e-view-show-images t)
135 (setq mu4e-sent-folder   "/Sent"
136       mu4e-drafts-folder "/Drafts"
137       mu4e-trash-folder  "/Trash")
138 ;; Create custom spam status header and show in message view
139 (add-to-list 'mu4e-header-info-custom
140  '(:spam-status .
141      ( :name "Spam-Status"     ;; long name, as seen in the message-view
142        :shortname "Spam"      ;; short name, as seen in the headers view
143        :help "The Spam status" ;; tooltip
144        ;; uses mu4e-fetch-field which is rel. slow, so only appropriate
145        ;; for mu4e-view-fields, and _not_ mu4e-headers-fields
146        :function (lambda (msg)
147                    (or (string-join (seq-take (split-string (or (mu4e-fetch-field msg "X-Spam-Status") "") " ") 2) " ") "")))))
148 (add-to-list 'mu4e-view-fields :spam-status)
150 ;; Resize image attachments when sending email
151 (defvar mu4e-resize-image-types '("jpg" "png" "svg" "jpeg")
152   "List of attached image types to resize.")
154 (defvar mu4e-inhibit-resize nil)
156 (defun mu4e-resize-image-attachments ()
157   (unless mu4e-inhibit-resize
158     (let (cmds
159       (image-types
160        (mapconcat #'identity mu4e-resize-image-types "\\|")))
161       (save-excursion
162     (message-goto-body-1)
163     (while (re-search-forward 
164         (format "<#part.+\\(filename=\"\\)\\(.+\\(\\.%s\\)\\)\""
165             image-types)
166         nil t)
167       (let* ((infile (match-string-no-properties 2))
168          (outfile (concat (temporary-file-directory)
169                   (file-name-nondirectory infile))))
170         (push (format "convert %s -resize 1200x1200\\> %s"
171               (shell-quote-argument infile)
172               (shell-quote-argument outfile))
173           cmds)
174         (replace-match outfile t t nil 2)))
175     (mapcar #'shell-command cmds)))))
177 (add-hook 'message-send-hook 'mu4e-resize-image-attachments)
179 (defun mu4e-inhibit-resize()
180   (interactive)
181   (set (make-local-variable 'mu4e-inhibit-resize) t))
183 ;; Load configuration for website
184 ;(load "mustache-html")
186 ;; Denote config
187 (setq denote-directory "/home/frederik/Nextcloud/notes/")
189 ;; Dired configuration
190 (with-eval-after-load 'dired
191   (require 'dired-x)
192   ;; Set dired-x global variables here.  For example:
193   ;; (setq dired-x-hands-off-my-keys nil)
194   )
195 (add-hook 'dired-mode-hook
196           (lambda ()
197             ;; Set dired-x buffer-local variables here.
198             (dired-omit-mode 1)
199             (dired-hide-details-mode 1)
200             (nerd-icons-dired-mode 1)
201             ))
202 (setq delete-by-moving-to-trash t)
203 (setq dired-guess-shell-alist-user
204       '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open")
205         ("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open")
206                 (".*" "xdg-open")))
208 ;; Use `vertico' package to get a vertical view of the minibuffer.
209 (setq vertico-resize nil)
210 (vertico-mode 1)
212 ;; Use `marginalia' package.  This will display useful
213 ;; annotations next to entries in the minibuffer.  For example, when
214 ;; using M-x it will show a brief description of the command as well
215 ;; as the keybinding associated with it (if any).
216 (marginalia-mode 1)
218 ;; Use 'winner' mode to undo and redo windows changes
219 ;; using C-c <left> and C-c <right>.
220 (winner-mode 1)