You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
7.1 KiB
EmacsLisp

4 years ago
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets.
(setq user-full-name "Kuba Orlik"
user-mail-address "kontakt@kuba-orlik.name")
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
;; are the three important ones:
;;
;; + `doom-font'
;; + `doom-variable-pitch-font'
;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;;
;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
;; font string. You generally only need these two:
;; (setq doom-font (font-spec :family "monospace" :size 12 :weight 'semi-light)
;; doom-variable-pitch-font (font-spec :family "sans" :size 13))
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-solarized-light)
;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/org/")
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type t)
;; Here are some additional functions/macros that could help you configure Doom:
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.
(setq +mu4e-backend 'offlineimap)
(defun kuba/generate-mu4-context (key_ category_ name_ addresses_ fullname_ smtp-server_ smtp-port_ smtp-user_ smtp-stream-type_ inbox-prefix_)
"NAME is the name in offlineimap directory"
(let (
(key key_)
(category category_)
(name name_)
(addresses addresses_)
(fullname fullname_)
(smtp-server smtp-server_)
(smtp-port smtp-port_)
(smtp-user smtp-user_)
(smtp-stream-type smtp-stream-type_)
(inbox-prefix inbox-prefix_)
)
(message "!!! addresses %S" addresses)
(make-mu4e-context
:name (concat key "-" name)
:enter-func (lambda () (mu4e-message (concat "Entering " name " context")))
:leave-func (lambda () (setq mu4e-maildir-list nil) (mu4e-message (concat "Leaving " name " context")))
:match-func (lambda (msg)
(when msg (some
(lambda (any) any)
(mapcar (lambda (addr) (or (mu4e-message-contact-field-matches msg :to addr) (mu4e-message-contact-field-matches msg :cc addr))) addresses))))
:vars (list
`(user-mail-address . ,(car addresses))
`(user-full-name . ,fullname)
`(mu4e-compose-signature . ,fullname)
`(mu4e-drafts-folder . ,(concat "/" name "/" inbox-prefix "Drafts"))
`(mu4e-sent-folder . ,(concat "/" name "/" inbox-prefix "Sent"))
`(mu4e-trash-folder . ,(concat "/" name "/" inbox-prefix "Trash"))
`(mu4e-refile-folder . ,(lambda (msg)
(or
(some
'identity
(mapcar (lambda (addr)
(cond
((mu4e-message-contact-field-matches msg :to addr) (concat "/" name "/" inbox-prefix "Archives"))
((mu4e-message-contact-field-matches msg :from addr) (concat "/" name "/" inbox-prefix "Sent"))
(t nil)
)
)
addresses
)
)
(concat "/" name "/" inbox-prefix "Archives")
)
))
`(smtpmail-smtp-server . ,smtp-server)
`(smtpmail-smtp-service . ,smtp-port)
`(smtpmail-smtp-user . ,smtp-user)
`(smtpmail-stream-type . ,smtp-stream-type)
)
)
)
)
(defun kuba/setup-mu4e-accounts (deflist)
(setq mu4e-contexts (mapcar (lambda (def) (apply 'kuba/generate-mu4-context def)) deflist))
(setq mu4e-user-mail-address-list (apply 'append (mapcar (lambda (def) (nth 3 def)) deflist)))
(push (list (mapconcat 'identity (mapcar (lambda (def) (concat "maildir:/" (nth 2 def) "/INBOX")) deflist) " OR ") "Merged inbox" 109) mu4e-bookmarks)
(-each
(seq-group-by (lambda (def) (nth 1 def)) deflist)
(lambda (defgroup) (push (list (mapconcat 'identity (mapcar (lambda (def) (concat "maildir:/" (nth 2 def) "/INBOX")) (-slice defgroup 1)) " OR ") (nth 0 defgroup) (aref (nth 0 defgroup) 0)) mu4e-bookmarks))
)
)
(load "~/.doom.d/mu4e-accounts")
(defun mu4e-compose-new-ask-context ()
(interactive)
(mu4e-context-switch)
(mu4e-compose)
)
(custom-set-faces!
'(mu4e-header-face :inherit 'font-lock-keyword-face :weight normal)
'(mu4e-replied-face :inherit 'mu4e-header-face :slant italic)
'(mu4e-replied-face :inherit 'mu4e-header-face :slant italic)
'(mu4e-unread-face :inherit 'font-lock-keyword-face)
'(mu4e-header-marks-face :inherit 'font-lock-preprocessor-face)
'(mu4e-header-highlight-face :inherit 'hl-line :underline t :extend t)
'(org-headline-done :inherit 'org-headline-todo :foreground "#268BD2")
)
;; to fix the highlight in mu4e disappearing (https://github.com/hlissner/emacs-doom-themes/issues/504):
(after! hl-line
(setq hl-line-sticky-flag t
global-hl-line-sticky-flag t)
)
;;;;;;;;;;;;; ORG
(defun sync-org ()
(interactive)
(org-save-all-org-buffers)
(message "downloading inbox...")
;; (org-mobile-pull)
(shell-command "/home/kuba/scripts/inbox-download.sh")
;; (org-mobile-push)
(shell-command "notify-send \"org-sync finished\" --icon=ok")
(find-file "~/org/inbox.org")
(revert-buffer 1 1)
)
(map! :g "C-c m s" #'sync-org)
(defun kuba/open-org-main ()
(interactive)
(find-file "~/org/main.org")
)
(defun kuba/open-org-inbox ()
(interactive)
(find-file "~/org/inbox.org")
)
(defun kuba/open-notes ()
(interactive)
(find-file "~/Nextcloud/Notes")
)
(map! :g "M-1" #'kuba/open-org-main)
(map! :g "M-3" #'kuba/open-org-inbox)
(map! :g "M-4" #'kuba/open-notes)
(map! :g "M-c" #'org-capture)
;;;;;;;;;;;;;;; spell-fu
(after! spell-fu
(global-spell-fu-mode 0)
(add-hook 'org-mode-hook
(lambda ()
(setq spell-fu-faces-exclude '(org-meta-line org-link org-code))
(spell-fu-mode 0)))
)
;;;; popup
;;disable hiding modeline in popups
(plist-put +popup-defaults :modeline t)
;;;;;;;;;;;;;;; prettier
(after! prettier-js
(add-hook 'js2-mode-hook 'prettier-js-mode)
(add-hook 'web-mode-hook 'prettier-js-mode)
)
;;;; file editing shortcuts
(map! :g "C-a" #'move-beginning-of-line)