config/emacs: terrible
This commit is contained in:
parent
d235c7f66c
commit
6a2a914ec4
1 changed files with 120 additions and 24 deletions
|
@ -1153,41 +1153,137 @@ its over the machines took over guys can i get my likes now
|
|||
** mu4e
|
||||
GNU patch review metho dor sometihng idk
|
||||
#+begin_src emacs-lisp
|
||||
(use-package mu4e
|
||||
:config
|
||||
(use-package mu4e
|
||||
:config
|
||||
|
||||
;; mu4e syncing issue with isync
|
||||
(setq mu4e-change-filenames-when-moving t)
|
||||
;; mu4e syncing issue with isync
|
||||
(setq mu4e-change-filenames-when-moving t)
|
||||
|
||||
;; sending mail
|
||||
(setq message-send-mail-function 'smtpmail-send-it)
|
||||
;; sending mail
|
||||
(setq message-send-mail-function 'smtpmail-send-it)
|
||||
|
||||
(setq mu4e-update-interval (* 10 60))
|
||||
(setq mu4e-get-mail-command "offlineimap")
|
||||
(setq mu4e-maildir "~/Mail")
|
||||
|
||||
(setq outlook-mail-address
|
||||
;; refresh token for stmpmail
|
||||
(cl-defmethod smtpmail-try-auth-method
|
||||
(process (_mech (eql xoauth2)) user password)
|
||||
(cond
|
||||
((or (equal user ,outlook-mail-address ))
|
||||
;; from https://github.com/UvA-FNWI/M365-IMAP/issues/3
|
||||
(let ((token (gethash "access_token"
|
||||
(let ((url-request-method "POST")
|
||||
(url-request-extra-headers `(("Content-Type" . "application/x-www-form-urlencoded")))
|
||||
(url-request-data (concat "client_id=" "9e5f94bc-e8a4-4e73-b8be-63364c29d753")
|
||||
"&client_secret="
|
||||
"&refresh_token=" (password-store-get-field "Microsoft" "client_refresh_token")
|
||||
"&grant_type=refresh_token")))
|
||||
(with-temp-buffer (url-insert-file-contents
|
||||
"https://login.microsoftonline.com/common/oauth2/v2.0/token")
|
||||
(json-parse-buffer :object-type 'hash-table)))
|
||||
)))
|
||||
(smtpmail-command-or-throw
|
||||
process
|
||||
(concat "AUTH XOAUTH2 "
|
||||
(base64-encode-string
|
||||
(concat "user=" user "\1auth=Bearer " token "\1\1") t)))))
|
||||
((equal user ,gmail-1-mail-address)
|
||||
(let ((token (gethash "access_token"
|
||||
(let ((url-request-method "POST")
|
||||
(url-request-extra-headers `(("Content-Type" . "application/x-www-form-urlencoded")))
|
||||
(url-request-data (concat "client_id=" (password-store-get-field "email/oauth/gmail" "client_id")
|
||||
"&client_secret=" (password-store-get-field "email/oauth/gmail" "client_secret")
|
||||
"&refresh_token=" (password-store-get-field "accounts.google.com/one" "client_refresh_token")
|
||||
"&grant_type=refresh_token")))
|
||||
(with-temp-buffer (url-insert-file-contents
|
||||
"https://oauth2.googleapis.com/token")
|
||||
(json-parse-buffer :object-type 'hash-table)))
|
||||
)))
|
||||
(smtpmail-command-or-throw
|
||||
process
|
||||
(concat "AUTH XOAUTH2 "
|
||||
(base64-encode-string
|
||||
(concat "user=" user "\1auth=Bearer " token "\1\1") t)))))
|
||||
((equal user ,gmail-2-mail-address)
|
||||
(let ((token (gethash "access_token"
|
||||
(let ((url-request-method "POST")
|
||||
(url-request-extra-headers `(("Content-Type" . "application/x-www-form-urlencoded")))
|
||||
(url-request-data (concat "client_id=" (password-store-get-field "email/oauth/gmail" "client_id")
|
||||
"&client_secret=" (password-store-get-field "email/oauth/gmail" "client_secret")
|
||||
"&refresh_token=" (password-store-get-field "accounts.google.com/two" "client_refresh_token")
|
||||
"&grant_type=refresh_token")))
|
||||
(with-temp-buffer (url-insert-file-contents
|
||||
"https://oauth2.googleapis.com/token")
|
||||
(json-parse-buffer :object-type 'hash-table)))
|
||||
)))
|
||||
(smtpmail-command-or-throw
|
||||
process
|
||||
(concat "AUTH XOAUTH2 "
|
||||
(base64-encode-string
|
||||
(concat "user=" user "\1auth=Bearer " token "\1\1") t)))))
|
||||
((equal user ,gmail-1-mail-address)
|
||||
(let ((token (gethash "access_token"
|
||||
(let ((url-request-method "POST")
|
||||
(url-request-extra-headers `(("Content-Type" . "application/x-www-form-urlencoded")))
|
||||
(url-request-data (concat "client_id=" (password-store-get-field "email/oauth/gmail" "client_id")
|
||||
"&client_secret=" (password-store-get-field "email/oauth/gmail" "client_secret")
|
||||
"&refresh_token=" (password-store-get-field "accounts.google.com/two" "client_refresh_token")
|
||||
"&grant_type=refresh_token")))
|
||||
(with-temp-buffer (url-insert-file-contents
|
||||
"https://oauth2.googleapis.com/token")
|
||||
(json-parse-buffer :object-type 'hash-table)))
|
||||
)))
|
||||
(smtpmail-command-or-throw
|
||||
process
|
||||
(concat "AUTH XOAUTH2 "
|
||||
(base64-encode-string
|
||||
(concat "user=" user "\1auth=Bearer " token "\1\1") t)))))
|
||||
((equal user ,gmail-2-mail-address)
|
||||
(let ((token (gethash "access_token"
|
||||
(let ((url-request-method "POST")
|
||||
(url-request-extra-headers `(("Content-Type" . "application/x-www-form-urlencoded")))
|
||||
(url-request-data (concat "client_id=" (password-store-get-field "email/oauth/gmail" "client_id")
|
||||
"&client_secret=" (password-store-get-field "email/oauth/gmail" "client_secret")
|
||||
"&refresh_token=" (password-store-get-field "accounts.google.com/one" "client_refresh_token")
|
||||
"&grant_type=refresh_token")))
|
||||
(with-temp-buffer (url-insert-file-contents
|
||||
"https://oauth2.googleapis.com/token")
|
||||
(json-parse-buffer :object-type 'hash-table)))
|
||||
)))
|
||||
(smtpmail-command-or-throw
|
||||
process
|
||||
(concat "AUTH XOAUTH2 "
|
||||
(base64-encode-string
|
||||
(concat "user=" user "\1auth=Bearer " token "\1\1") t)))))
|
||||
(t nil)))
|
||||
|
||||
|
||||
|
||||
|
||||
(setq mu4e-update-interval (* 10 60))
|
||||
(setq mu4e-get-mail-command "offlineimap")
|
||||
(setq mu4e-maildir "~/Mail")
|
||||
|
||||
(setq outlook-mail-address
|
||||
(string-trim (shell-command-to-string "pass Microsoft | awk 'BEGIN {ORS=\"\"} FNR == 2{gsub(\"login: \", \"\"); gsub(/ /, \"\"); print}'")))
|
||||
|
||||
(defvar proton-mail-address nil)
|
||||
(defvar proton-mail-address nil)
|
||||
|
||||
(defun get-proton-mail-address-from-pass (command)
|
||||
"Execute COMMAND, concatenate its output with 'hello', and store it in my-greeting."
|
||||
(let ((output (shell-command-to-string command)))
|
||||
(setq output (string-trim output))
|
||||
(setq proton-mail-address (concat "@proton.me" output))))
|
||||
(defun get-proton-mail-address-from-pass (command)
|
||||
"Execute COMMAND, concatenate its output with 'hello', and store it in my-greeting."
|
||||
(let ((output (shell-command-to-string command)))
|
||||
(setq output (string-trim output))
|
||||
(setq proton-mail-address (concat "@proton.me" output))))
|
||||
|
||||
(get-proton-mail-address-from-pass "pass Proton Account | awk 'BEGIN {ORS=\"\"} FNR == 2{gsub(\"login: \", \"\"); gsub(/ /, \"\"); print}'")
|
||||
(get-proton-mail-address-from-pass "pass 'Proton Account' | awk 'BEGIN {ORS=\"\"} FNR == 2{gsub(\"login: \", \"\"); gsub(/ /, \"\"); print}'")
|
||||
|
||||
(setq gmail-1-mail-address
|
||||
(setq gmail-1-mail-address
|
||||
(string-trim (shell-command-to-string "pass accounts.google.com/one | awk 'BEGIN {ORS=\"\"} FNR == 2{gsub(\"login: \", \"\"); gsub(/ /, \"\"); print}'")))
|
||||
|
||||
(setq gmail-2-mail-address
|
||||
(setq gmail-2-mail-address
|
||||
(string-trim (shell-command-to-string "pass accounts.google.com/two | awk 'BEGIN {ORS=\"\"} FNR == 2{gsub(\"login: \", \"\"); gsub(/ /, \"\"); print}'")))
|
||||
|
||||
(setq mu4e-context-policy 'pick-first)
|
||||
(setq mu4e-compose-context-policy 'always-ask)
|
||||
(setq mu4e-contexts
|
||||
(setq mu4e-context-policy 'pick-first)
|
||||
(setq mu4e-compose-context-policy 'always-ask)
|
||||
(setq mu4e-contexts
|
||||
(list
|
||||
;; outlook
|
||||
(make-mu4e-context
|
||||
|
@ -1203,7 +1299,7 @@ GNU patch review metho dor sometihng idk
|
|||
(mu4e-refile-folder . "/Outlook/Inbox")
|
||||
(mu4e-trash-folder . "/Outlook/Deleted")
|
||||
;; todo stmpmail and compose signatures
|
||||
))
|
||||
))
|
||||
(make-mu4e-context
|
||||
:name "Proton"
|
||||
:match-func
|
||||
|
@ -1247,7 +1343,7 @@ GNU patch review metho dor sometihng idk
|
|||
))
|
||||
|
||||
))
|
||||
)
|
||||
)
|
||||
#+end_src
|
||||
* Org
|
||||
#+begin_src emacs-lisp
|
||||
|
|
Loading…
Reference in a new issue