(set-face-attribute 'default nil :height 150) (set-frame-font "Iosevka SS13 Extended" nil t) (menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1) (display-battery-mode t) (pixel-scroll-precision-mode) (tab-bar-mode) (delete-selection-mode 1) (fset 'yes-or-no-p 'y-or-n-p) (setq inhibit-startup-screen t line-spacing 0.2 display-time-format "%a, %d/%m/%Y %H:%M" undo-limit 10000000 undo-outer-limit 20000000 completion-cycle-threshold 5 ;; X integration x-select-enable-clipboard t x-select-enable-primary t ring-bell-function 'ignore) (display-time-mode) (line-number-mode) (column-number-mode) (setq-default fill-column 80) (setq-default frame-title-format '("%b")) ;; Put Emacs auto-save and backup files to /tmp (defconst emacs-tmp-dir (expand-file-name (format "emacs%d" (user-uid)) temporary-file-directory)) (setq backup-by-copying t ; Avoid symlinks delete-old-versions t kept-new-versions 6 kept-old-versions 2 version-control t auto-save-list-file-prefix emacs-tmp-dir auto-save-file-name-transforms `((".*" ,emacs-tmp-dir t)) ; Change autosave dir to tmp backup-directory-alist `((".*" . ,emacs-tmp-dir))) ;; Packages (setq package-list '( magit nix-mode go-mode devdocs rec-mode almost-mono-themes markdown-mode yasnippet avy yasnippet-snippets tldr elfeed yasnippet-snippets mastodon lem expand-region)) (require 'package) ;; list the repositories containing them (setq package-archives '(("elpa" . "https://elpa.gnu.org") ("gnu" . "http://elpa.gnu.org/packages/") ("melpa" . "https://melpa.org/packages/") ("melpa-stable" . "https://stable.melpa.org/packages/"))) ;; activate all thpe packages (in particular autoloads) (package-initialize) ;; fetch the list of packages available (unless package-archive-contents (package-refresh-contents)) ;; install the missing packages (dolist (package package-list) (unless (package-installed-p package) (package-install package))) ;; Avy (use-package avy :ensure t :config (global-set-key (kbd "C-o") 'avy-goto-char-timer) (setf (alist-get ? avy-dispatch-alist) 'avy-action-mark-to-char) (define-key isearch-mode-map (kbd "M-o") 'avy-isearch) (defun avy-action-kill-whole-line (pt) (save-excursion (goto-char pt) (kill-whole-line)) (select-window (cdr (ring-ref avy-ring 0))) t) (setf (alist-get ?k avy-dispatch-alist) 'avy-action-kill-stay (alist-get ?K avy-dispatch-alist) 'avy-action-kill-whole-line) (defun avy-action-copy-whole-line (pt) (save-excursion (goto-char pt) (cl-destructuring-bind (start . end) (bounds-of-thing-at-point 'line) (copy-region-as-kill start end))) (select-window (cdr (ring-ref avy-ring 0))) t) (defun avy-action-yank-whole-line (pt) (avy-action-copy-whole-line pt) (save-excursion (yank)) t) (setf (alist-get ?y avy-dispatch-alist) 'avy-action-yank (alist-get ?w avy-dispatch-alist) 'avy-action-copy (alist-get ?W avy-dispatch-alist) 'avy-action-copy-whole-line (alist-get ?Y avy-dispatch-alist) 'avy-action-yank-whole-line) (defun avy-action-copy-whole-line (pt) (save-excursion (goto-char pt) (cl-destructuring-bind (start . end) (bounds-of-thing-at-point 'line) (copy-region-as-kill start end))) (select-window (cdr (ring-ref avy-ring 0))) t) (defun avy-action-yank-whole-line (pt) (avy-action-copy-whole-line pt) (save-excursion (yank)) t) (setf (alist-get ?y avy-dispatch-alist) 'avy-action-yank (alist-get ?w avy-dispatch-alist) 'avy-action-copy (alist-get ?W avy-dispatch-alist) 'avy-action-copy-whole-line (alist-get ?Y avy-dispatch-alist) 'avy-action-yank-whole-line) (defun avy-action-teleport-whole-line (pt) (avy-action-kill-whole-line pt) (save-excursion (yank)) t) (setf (alist-get ?t avy-dispatch-alist) 'avy-action-teleport (alist-get ?T avy-dispatch-alist) 'avy-action-teleport-whole-line) (defun avy-action-mark-to-char (pt) (activate-mark) (goto-char pt)) (setf (alist-get ? avy-dispatch-alist) 'avy-action-mark-to-char)) ;; Expand Region (use-package expand-region :ensure t :init (global-set-key (kbd "C-.") 'er/expand-region) (global-set-key (kbd "C-,") 'er/contract-region)) (use-package devdocs :ensure t :init (global-set-key (kbd "C-h D") 'devdocs-lookup)) ;; Html (add-to-list 'auto-mode-alist '("\\.njk\\'" . html-mode)) ;; Markdown (use-package markdown-mode :ensure t :config (set-face-attribute 'markdown-code-face nil :inherit 'fixed-pitch) :hook ((markdown-mode . variable-pitch-mode) (markdown-mode . markdown-toggle-url-hiding) (markdown-mode . markdown-toggle-markup-hiding) (markdown-mode . visual-line-mode))) ;; Pairs (electric-pair-mode 1) (global-set-key (kbd "M-{") 'insert-pair) (global-set-key (kbd "M-\"") 'insert-pair) (global-set-key (kbd "M-\'") 'insert-pair) (global-set-key (kbd "M-<") 'insert-pair) (global-set-key (kbd "M-[") 'insert-pair) ;; IDO (ido-mode t) ;; Eglot (use-package nix-mode :ensure t :hook ((before-save . nix-format-buffer) (nix-mode . nix-prettify-mode))) (use-package eglot :config ;; Ensure `nil` is in your PATH. (add-to-list 'eglot-server-programs '(nix-mode . ("nil"))) (define-key eglot-mode-map (kbd "C-c r") 'eglot-rename) (define-key eglot-mode-map (kbd "C-c o") 'eglot-code-actions) (define-key eglot-mode-map (kbd "C-c h") 'eldoc) (set 'eldoc-print-after-edit t) (global-eldoc-mode t) (setq eldoc-echo-area-prefer-doc-buffer t) :hook (nix-mode . eglot-ensure) (go-mode . eglot-ensure)) (setq make-backup-files nil) (use-package go-mode :ensure t :hook ((before-save . eglot-format-buffer))) ;; HTML (add-hook 'html-mode-hook (lambda() (setq sgml-basic-offset 8) (setq indent-tabs-mode t))) (add-to-list 'load-path "~/.emacs.d/elisp") (add-to-list 'custom-theme-load-path "~/.emacs.d/themes") (setq-default grep-template (string-join '("ugrep" "--color=never" "--ignore-binary" "--ignore-case" "--include=" "--line-number" "--null" "--recursive" "--regexp=") " ")) (require 'secrets) (require 'auth-source-pass (auth-source-pass-enable)) (global-set-key "\C-cef" (lambda () (interactive) (erc :server "irc.libera.chat" :port "6667" :nick "mccd" :password (shell-command-to-string "pass show libera.chat")))) (setq shr-max-image-proportion 0.3 mastodon-active-user "marcc" mastodon-instance-url "https://fosstodon.org") ;; Org (use-package org :ensure t :init (global-set-key (kbd "C-c l") #'org-store-link) (global-set-key (kbd "C-c a") #'org-agenda) (global-set-key (kbd "C-c c") #'org-capture) (global-set-key (kbd "C-c s") #'project-find-regexp) (setq org-agenda-files '("~/personal-db/notes") org-refile-targets '((nil :maxlevel . 2) (org-agenda-files :maxlevel . 2)) org-default-notes-file "~/personal-db/todo.org" org-hide-emphasis-markers t org-agenda-inhibit-startup t ;; Add /New Heading at the end for use org-refile-allow-creating-parent-nodes 'confirm org-outline-path-complete-in-steps nil org-refile-use-outline-path 'file ;; Otherwise looks weird in variable-pitch-mode org-tags-column 0 org-log-done 'time) (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) (org-babel-do-load-languages 'org-babel-load-languages '((shell . t))) (setq org-capture-templates '( ("t" "Todo" entry (file+headline "~/personal-db/todo.org" "Todo") "* TODO %?\n%i\n%a\n%T\n " :empty-lines 1) ("l" "Log" entry (file+datetree "~/personal-db/notes/log.org") "* %?\n%T\n" :empty-lines 1) ("n" "Inbox" entry (file+headline "~/personal-db/notes/inbox.org" "Notes") "** %?\n%T" :empty-lines 1))) :config (set-face-attribute 'org-block nil :inherit 'fixed-pitch) (set-face-attribute 'org-code nil :inherit 'fixed-pitch) (set-face-attribute 'org-table nil :inherit 'fixed-pitch) :hook ((org-mode . auto-save-mode)) (org-mode . org-indent-mode) (org-mode . visual-line-mode) (org-mode . variable-pitch-mode) (org-agenda-mode . (lambda () (add-hook 'auto-save-hook 'org-save-all-org-buffers nil t) (auto-save-mode)))) ;; Magit (use-package magit :ensure t :init (global-set-key (kbd "C-c g") 'magit)) (use-package magit-extras) ;; Yasnippet (use-package yasnippet :ensure t :init (yas-global-mode 1)) ;; Mu4e (defun marc/set-msmtp-account () (if (message-mail-p) (save-excursion (let* ((from (save-restriction (message-narrow-to-headers) (message-fetch-field "from"))) (account (cond ((string-match "marcc@fastmail.fr" from) "home") ((string-match "marc.coquand@sustainably.app" from) "work") ((string-match "marc@mccd.space" from) "home")))) (setq message-sendmail-extra-arguments (list '"-a" account)))))) (add-hook 'message-send-mail-hook 'marc/set-msmtp-account) (use-package mu4e :ensure nil :load-path "/usr/share/emacs/site-lisp/mu4e/" :config ;; This is set to 't' to avoid mail syncing issues when using mbsync (setq mu4e-change-filenames-when-moving t) ;; don't keep message compose buffers around after sending: (setq message-kill-buffer-on-exit t) ;; send function: (setq send-mail-function 'sendmail-send-it message-send-mail-function 'sendmail-send-it) ;; send program: ;; this is exeranal. remember we installed it before. (setq sendmail-program (executable-find "msmtp")) ;; select the right sender email from the context. (setq message-sendmail-envelope-from 'header) ;; Refresh mail using isync every 10 minutes (setq mu4e-update-interval (* 10 60) mu4e-get-mail-command "mbsync -a" mu4e-view-show-images t mu4e-view-show-addresses t mu4e-attachment-dir "~/Downloads" mu4e-view-prefer-html t mu4e-maildir "~/mail") (setq mu4e-contexts (list ;; Home (make-mu4e-context :name "home" :enter-func (lambda () (mu4e-message "Entering personal context")) :leave-func (lambda () (mu4e-message "Leaving personal context")) :match-func (lambda (msg) (when msg (string-prefix-p "/home" (mu4e-message-field msg :maildir)))) :vars '((user-mail-address . "marc@mccd.space") (user-full-name . "Marc Coquand") (mu4e-drafts-folder . "/home/Drafts") (mu4e-sent-folder . "/home/Sent") (mu4e-refile-folder . "/home/Archive") (mu4e-trash-folder . "/home/Trash") (mu4e-sent-messages-behavior . sent) (mu4e-maildir-shortcuts . (("/home/INBOX" . ?i) ("/home/Archive/Done" . ?d) ("/home/Archive" . ?a) ("/home/Archive/Todo" . ?t))))) ;; Work account (make-mu4e-context :name "work" :enter-func (lambda () (mu4e-message "Entering work context")) :leave-func (lambda () (mu4e-message "Leaving work context")) :match-func (lambda (msg) (when msg (string-prefix-p "/work" (mu4e-message-field msg :maildir)))) :vars '((user-mail-address . "marc.coquand@sustainably.app") (user-full-name . "Marc Coquand") (mu4e-drafts-folder . "/work/[Gmail]/Drafts") (mu4e-sent-folder . "/work/[Gmail]/Sent Mail") (mu4e-refile-folder . "/work/[Gmail]/All Mail") (mu4e-sent-messages-behavior . delete) (mu4e-trash-folder . "/work/[Gmail]/Trash") (mu4e-maildir-shortcuts . (("/work/[Gmail]/All Mail" . ?a) ("/work/INBOX" . ?i)))))))) ;; Lem (setq lem-instance-url "https://lemmy.sdf.org") ;; Elfeed (require 'elfeed) ;; curl recommend (setq elfeed-use-curl t) (elfeed-set-timeout 36000) (setq elfeed-curl-extra-arguments '("--insecure")) ;necessary for https without a trust certificate ;; setup feeds (setq elfeed-protocol-fever-update-unread-only t) (setq elfeed-protocol-fever-fetch-category-as-tag t) (setq elfeed-protocol-feeds '(("fever+https://freshrss@rss.mccd.space" :api-url "https://rss.mccd.space/api/fever.php" :password (shell-command-to-string "pass show mccd/freshrss")))) ;; enable elfeed-protocol (setq elfeed-protocol-enabled-protocols '(fever)) (elfeed-protocol-enable) (global-set-key (kbd "C-x w") 'elfeed) ;; Eww (setq browse-url-browser-function 'eww-browse-url ; Use eww as the default browser shr-width 70 ; Fold text to 70 columns ) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(eglot-highlight-symbol-face ((t (:weight bold)))) '(eglot-mode-line ((t (:weight regular)))) '(erc-timestamp-face ((t (:foreground "blue" :weight bold)))) '(eww-valid-certificate ((t (:foreground "black" :weight bold)))) '(fixed-pitch ((t (:family "Iosevka SS13 Extended")))) '(font-lock-builtin-face ((t (:weight regular)))) '(font-lock-comment-face ((t (:foreground "#0000FF" :slant normal)))) '(font-lock-constant-face ((t (:slant italic :weight regular)))) '(font-lock-function-name-face ((t (:weight regular)))) '(font-lock-keyword-face ((t (:weight regular)))) '(font-lock-string-face ((t (:foreground "black" :slant italic)))) '(font-lock-type-face ((t (:foreground "black")))) '(font-lock-variable-name-face ((t (:foreground "black")))) '(fringe ((t (:background "white")))) '(header-line ((t (:inherit nil :background "white" :foreground "grey20" :box (:line-width (8 . 8) :color "white") :underline (:color "gray80" :style line :position 0))))) '(highlight ((t (:background "azure2")))) '(info-header-xref ((t (:inherit info-xref :underline (:color "RoyalBlue3" :style line :position t))))) '(info-node ((t (:foreground "brown" :box (:line-width (4 . 4) :color "white") :slant italic :weight bold)))) '(markdown-inline-code-face ((t (:inherit markdown-code-face)))) '(markdown-pre-face ((t (:inherit markdown-code-face)))) '(mastodon-display-name-face ((t (:inherit nil :weight bold)))) '(mode-line ((t (:inherit variable-pitch :background "white" :foreground "black" :box (:line-width (8 . 8) :style flat-button) :overline "gray80")))) '(mode-line-inactive ((t (:inherit mode-line :background "grey95" :foreground "grey20" :underline (:color "grey80" :style line :position 0) :weight light)))) '(mu4e-header-highlight-face ((t (:inherit hl-line :extend t :weight bold)))) '(mu4e-highlight-face ((t (:inherit highlight)))) '(org-level-1 ((t (:inherit outline-1 :extend nil :weight regular)))) '(org-time-grid ((t (:foreground "gray")))) '(outline-4 ((t (:inherit outline-2)))) '(tab-bar ((t (:inherit variable-pitch :background "white" :box (:line-width (8 . 8) :color "white" :style flat-button) :weight light)))) '(tldr-code-block ((t (:background "cornsilk" :foreground "black")))) '(tldr-command-argument ((t (:background "cornsilk" :foreground "black")))) '(tldr-command-itself ((t (:background "khaki" :foreground "black" :weight bold)))) '(tldr-introduction ((t (:foreground "black" :slant italic)))) '(tldr-title ((t (:inherit variable-pitch :foreground "black" :weight bold :height 1.2)))) '(variable-pitch ((t (:family "Iosevka Aile"))))) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(custom-safe-themes '("cbd85ab34afb47003fa7f814a462c24affb1de81ebf172b78cb4e65186ba59d2" default)) '(markdown-list-item-bullets '("-")) '(mastodon-tl--enable-proportional-fonts t) '(mastodon-use-emojify t) '(mode-line-compact 'long) '(mode-line-format '("%e" mode-line-front-space (:propertize ("" mode-line-modified " " mode-line-position)) mode-line-buffer-identification)) '(mode-line-percent-position nil) '(mode-line-position-line-format '(" ")) '(mu4e-bookmarks '((:name "Last 7 days" :query "date:7d..now" :hide-unread t :key 119) (:name "Messages with images" :query "mime:image/*" :key 112))) '(org-agenda-files '("~/personal-db/notes/carving-my-own-road.org" "/home/mccd/personal-db/notes/emacs-teaches.org" "/home/mccd/personal-db/notes/agency-and-tech.org" "/home/mccd/personal-db/notes/log.org" "/home/mccd/builds/sustainably/piva.org" "/home/mccd/builds/comma.directory/comma.org" "/home/mccd/personal-db/notes/frugal.org" "/home/mccd/personal-db/notes/inbox.org" "/home/mccd/personal-db/notes/emacs.org" "/home/mccd/personal-db/todo.org")) '(org-fold-core-style 'overlays) '(package-selected-packages '(nix-mode nix-ts-mode avy pdf-tools elfeed-protocol lem yasnippet-snippets elfeed yasnippet smartparens markdown-mode mastodon tldr almost-mono-themes rec-mode magit go-mode expand-region devdocs)) '(tab-bar-format '(tab-bar-separator tab-bar-format-align-right tab-bar-format-global)) '(yank-from-kill-ring-rotate t)) (put 'secrets-mode 'disabled nil)