Skip to content

Commit

Permalink
Add last constants, including qk-mail
Browse files Browse the repository at this point in the history
This is great, as commented on previous commits' comments, there is now
only two possible moving points to qk-emacs:

- `init.el` file if the user wants to add more modules for their own
configuration.
- `modules/qk-constants`, where the user will set up all their constants
to use with the modules that they have loaded.
  • Loading branch information
Qkessler committed Dec 23, 2022
1 parent 0ab1e5a commit 8215390
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 164 deletions.
15 changes: 15 additions & 0 deletions modules/core-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,21 @@ testing advice (when combined with `rotate-text').
;;

;; Personal lib.
(cl-defstruct mu4e-context
name
(enter-func nil)
(leave-func nil)
(match-func nil)
vars)

(defsubst mu4e-message-field (msg field)
(let ((val (mu4e-message-field-raw msg field)))
(cond (val val) ;; non-nil -> just return it
((member field '(:subject :message-id :path :maildir :in-reply-to)) "") ;; string fields except body-txt, body-html: nil -> ""
((member field '(:body-html :body-txt)) val)
((member field '(:docid :size)) 0) ;; numeric type: nil -> 0
(t val))))

(defun qk-real-insert (char)
(cl-flet ((do-insert
() (progn
Expand Down
127 changes: 127 additions & 0 deletions modules/qk-constants.el
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,133 @@ See `denote-prompts'.")
See `git-commit-summary-max-length'.")
(defvar qk-git-commit-fill-column 72
"Default: set fill column to this number if on `git-commit-mode'.")
(defvar qk-tab-bar-show nil
"Default: hide tab-bar, though use it in the shadows. See `tab-bar-show'.")
(defvar qk-python-shell-interpreter "python3"
"Default: command to use when running python. See `python-shell-interpreter'.")
(defvar qk-markdown-command "pandoc -t html5"
"Default: command to use when compiling markdown to html.
See `markdown-command'.")
(defvar qk-mu4e-load-path "/opt/homebrew/Cellar/mu/1.8.11/share/emacs/site-lisp/mu/mu4e/"
"Default: mu4e load path. See `mu4e-load-path'.")
(defvar qk-mu4e-maildir "~/.Mail"
"Default: mail directory that mu4e will use to pull emails from.
See `mu4e-maildir'.")
(defvar qk-mu4e-attachment-dir "/tmp"
"Default: temp directory for attaching and saving attachments. See `mu4e-attachment-dir'.")
(defvar qk-mu4e-get-mail-command "mbsync amazon"
"Default: the mbsync command that you want to run on pull.
See `mu4e-get-mail-command'.")
(defvar qk-mu4e-compose-signature "Enrique Kessler Martínez\n"
"Default: default signature to use when composing. See `mu4e-compose-signature'.")
(defvar qk-mu4e-update-interval (* 5 60)
"Default: interval on which update mail. See `mu4e-update-interval'.")

(defvar qk-notificator-team-mu-query "to:[email protected]")
(defvar qk-manager-mu-query "(from:[email protected] OR from:[email protected])")
(defvar qk-to-me-mu-query "(to:[email protected] OR to:[email protected])")
(defvar qk-unread-mu-query " AND g:unread AND NOT g:trashed")
(defvar qk-mu4e-maildir-shortcuts
'((:maildir "/amazon/CRs" :key ?c)
(:maildir "/amazon/Issues" :key ?i)
(:maildir "/amazon/Pipelines" :key ?P)
(:maildir "/Gmail/Work/Inbox" :key ?p)
(:maildir "/amazon/Quip" :key ?q)
(:maildir "/amazon/Asana" :key ?a))
"Default: shorcuts for different maildirs. See `mu4e-maildir-shortcuts'.")
(defvar qk-mu4e-bookmarks
`((:name "All Unread" :query "g:unread" :key ?u)
(:name "Today's messages" :query "d:today..now" :key ?t)
(:name "Direct to Me" :query ,(concat qk-to-me-mu-query qk-unread-mu-query) :key ?m)
(:name "josli@" :query ,(concat qk-manager-mu-query qk-unread-mu-query) :key ?j)
(:name "CRs" :query ,(concat "maildir:/amazon/CRs" qk-unread-mu-query) :key ?c)
(:name "kindle-notifications-dev"
:query ,(concat qk-notificator-team-mu-query qk-unread-mu-query)
:key ?d)

(:name "qkessler" :query ,(concat "maildir:/Gmail/Personal/Inbox" qk-unread-mu-query) :key ?q)
(:name "enrique.kesslerm" :query ,(concat "maildir:/Gmail/Work/Inbox" qk-unread-mu-query) :key ?e))
"Default: my own bookmarks for consuming email. See `mu4e-bookmarks'.")
(defvar qk-mu4e-contexts
(list
(make-mu4e-context
:name "Amazon"
:match-func
(lambda (msg)
(when msg
(string-prefix-p "/amazon" (mu4e-message-field msg :maildir))))
:vars '((user-mail-address . "[email protected]")
(user-full-name . "Quique Kessler Martínez")
(mu4e-drafts-folder . "/amazon/Drafts")
(mu4e-sent-folder . "/amazon/Sent Items")
(mu4e-refile-folder . "/amazon/Archive")
(mu4e-trash-folder . "/amazon/Deleted Items")
(smtpmail-smtp-user . "enrikes")
(smtpmail-default-smtp-server . "exch-eu.amazon.com")
(smtpmail-smtp-server . "exch-eu.amazon.com")
(smtpmail-smtp-service . 1587)))
(make-mu4e-context
:name "Personal"
:match-func
(lambda (msg)
(when msg
(string-prefix-p "/Gmail/Personal" (mu4e-message-field msg :maildir))))
:vars '((user-mail-address . "[email protected]")
(user-full-name . "Enrique Kessler Martínez")
(mu4e-drafts-folder . "/Gmail/Personal/[Gmail]/Drafts")
(mu4e-sent-folder . "/Gmail/Personal/[Gmail]/Sent Mail")
(mu4e-refile-folder . "/Gmail/Personal/[Gmail]/All Mail")
(mu4e-trash-folder . "/Gmail/Personal/[Gmail]/Trash")
(smtpmail-smtp-user . "[email protected]")
(smtpmail-default-smtp-server . "smtp.gmail.com")
(smtpmail-smtp-server . "smtp.gmail.com")
(smtpmail-smtp-service . 587)))
(make-mu4e-context
:name "Work"
:match-func
(lambda (msg)
(when msg
(string-prefix-p "/Gmail/Work" (mu4e-message-field msg :maildir))))
:vars '((user-mail-address . "[email protected]")
(user-full-name . "Enrique Kessler Martínez")
(mu4e-drafts-folder . "/Gmail/Work/[Gmail]/Drafts")
(mu4e-sent-folder . "/Gmail/Work/[Gmail]/Sent Mail")
(mu4e-refile-folder . "/Gmail/Work/[Gmail]/All Mail")
(mu4e-trash-folder . "/Gmail/Work/[Gmail]/Trash")
(smtpmail-default-smtp-server . "smtp.gmail.com")
(smtpmail-smtp-user . "[email protected]")
(smtpmail-smtp-server . "smtp.gmail.com")
(smtpmail-smtp-service . 587))))
"Default: my contexts when working with email. See `mu4e-contexts'.")
(defvar qk-sendmail-program "/opt/homebrew/bin/msmtp"
"Default: use `msmtp' for queuing and sending email. See `sendmail-program'.")
(defvar qk-mu4e-alert-interesting-mail-query
(concat "((to:[email protected] OR to:[email protected]) " qk-unread-mu-query ")"
" OR "
"((from:[email protected] OR from:[email protected]) " qk-unread-mu-query ")")
"Default: mu search of email that could be interesting, that we want to count
for modeline highlighting. See `mu4e-alert-interesting-mail-query'.")
(defvar qk-vterm-max-scrollback 10000
"Default: number of lines to have as scrollback. See `vterm-max-scrollback'.")
(defvar qk-vterm-timer-delay nil
"Default: tweak this to your liking, to have vterm snappy but not too
resource intensive. See `vterm-timer-delay'.")
(defvar qk-ledger-reports
'(("bal" "%(binary) -f %(ledger-file) bal --real")
("reg" "%(binary) -f %(ledger-file) reg")
("reg this month" "%(binary) -f %(ledger-file) reg -p \"this month\"")
("reg last month" "%(binary) -f %(ledger-file) reg -p \"last month\"")
("payee" "%(binary) -f %(ledger-file) reg @%(payee)")
("account" "%(binary) -f %(ledger-file) reg %(account)")
("expenses this month" "%(binary) -p \"this month\" -f %(ledger-file) bal Expenses and not \
\\(Expenses:Rebalancing or Expenses:Refundable or Expenses:Lent money\\)")
("expenses last month" "%(binary) -p \"last month\" -f %(ledger-file) bal Expenses and not \
\\(Expenses:Rebalancing or Expenses:Refundable or Expenses:Lent money\\)")
("budget" "%(binary) -f %(ledger-file) -E bal ^Budget and not Budget:Checking")
("income last month" "%(binary) -f %(ledger-file) -p \"last month\" bal ^Income"))
"Default: reports available when running `ledger-report'.")
(defvar qk-chatgpt-repo-path "~/.emacs.d/elpaca/repos/ChatGPT/"
"Default: repo using the `elpaca' package manager. See `chatgpt-repo-path'.")

(provide 'qk-constants)
;; qk-constants.el ends here.
17 changes: 2 additions & 15 deletions modules/qk-extra.el
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,7 @@
:init
(setq
ledger-clear-whole-transactions t
ledger-reports '(("bal" "%(binary) -f %(ledger-file) bal --real")
("reg" "%(binary) -f %(ledger-file) reg")
("reg this month" "%(binary) -f %(ledger-file) reg -p \"this month\"")
("reg last month" "%(binary) -f %(ledger-file) reg -p \"last month\"")
("payee" "%(binary) -f %(ledger-file) reg @%(payee)")
("account" "%(binary) -f %(ledger-file) reg %(account)")
("expenses this month" "%(binary) -p \"this month\" -f %(ledger-file) bal Expenses and not \
\\(Expenses:Rebalancing or Expenses:Refundable or Expenses:Lent money\\)")
("expenses last month" "%(binary) -p \"last month\" -f %(ledger-file) bal Expenses and not \
\\(Expenses:Rebalancing or Expenses:Refundable or Expenses:Lent money\\)")
("budget" "%(binary) -f %(ledger-file) -E bal ^Budget and not Budget:Checking")
("income last month" "%(binary) -f %(ledger-file) -p \"last month\" bal ^Income")))
ledger-reports qk-ledger-reports)
:general
(major-mode-definer
:major-modes '(ledger-mode)
Expand All @@ -94,9 +83,7 @@
:repo "joshcho/ChatGPT.el"
:files ("dist" "*.el"))
:init
(setq
chatgpt-repo-path "~/.emacs.d/straight/repos/ChatGPT.el/"
python-interpreter "python3")
(setq chatgpt-repo-path qk-chatgpt-repo-path)
:general
(major-mode-definer
:major-modes '(prog-mode text-mode org-mode)
Expand Down
16 changes: 8 additions & 8 deletions modules/qk-lang.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
;; parsers, as it has been really accepted by the community and the Github's Atom
;; team has been working on implementing a ton of languages.
(elpaca-use-package tree-sitter
:hook
(doom-first-buffer . global-tree-sitter-mode)
(tree-sitter-after-on . tree-sitter-hl-mode))
:hook
(doom-first-buffer . global-tree-sitter-mode)
(tree-sitter-after-on . tree-sitter-hl-mode))

(elpaca-use-package tree-sitter-langs
:after tree-sitter
Expand Down Expand Up @@ -54,12 +54,12 @@

(use-package c++-mode
:mode ("\\.cpp\\'" "\\.c\\'")
:init (setq c-basic-offset 4))
:init (setq c-basic-offset qk-tab-width))

(use-package python
:init
(setq
python-shell-interpreter "python3"
python-shell-interpreter qk-python-shell-interpreter
compilation-ask-about-save nil
python-indent-guess-indent-offset-verbose nil
compilation-scroll-output t))
Expand Down Expand Up @@ -104,7 +104,7 @@
:mode ("\\.js\\'" "\\.tsx\\'" "\\.ts\\'"))

(elpaca-use-package json-mode
:mode "\\.json\\'")
:mode "\\.json\\'")

(elpaca-use-package yaml-mode
:mode "\\.yml\\'")
Expand All @@ -115,7 +115,7 @@
;; some cargo commands implemented is nice. The lsp configuration is
;; also seamless, pretty good package.
(elpaca-use-package rustic
:mode ("\\.rs\\'" . rustic-mode)
:mode ("\\.rs\\'" . rustic-mode)
:init
(setq
rustic-format-on-save nil
Expand Down Expand Up @@ -152,7 +152,7 @@
(elpaca-use-package markdown-mode
:mode ("\\.md\\'" . gfm-mode)
:hook (markdown-mode . visual-line-mode)
:init (setq markdown-command "pandoc -t html5")
:init (setq markdown-command qk-markdown-command)
:general
(major-mode-definer
:keymaps '(markdown-mode-map)
Expand Down
Loading

0 comments on commit 8215390

Please sign in to comment.