config/emacs: terrible

This commit is contained in:
Sakooooo 2024-09-25 11:49:55 +04:00
parent d235c7f66c
commit 6a2a914ec4
Signed by: sako
GPG key ID: 3FD715D87D7725E0

View file

@ -1153,41 +1153,137 @@ its over the machines took over guys can i get my likes now
** mu4e ** mu4e
GNU patch review metho dor sometihng idk GNU patch review metho dor sometihng idk
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package mu4e (use-package mu4e
:config :config
;; mu4e syncing issue with isync ;; mu4e syncing issue with isync
(setq mu4e-change-filenames-when-moving t) (setq mu4e-change-filenames-when-moving t)
;; sending mail ;; sending mail
(setq message-send-mail-function 'smtpmail-send-it) (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}'"))) (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) (defun get-proton-mail-address-from-pass (command)
"Execute COMMAND, concatenate its output with 'hello', and store it in my-greeting." "Execute COMMAND, concatenate its output with 'hello', and store it in my-greeting."
(let ((output (shell-command-to-string command))) (let ((output (shell-command-to-string command)))
(setq output (string-trim output)) (setq output (string-trim output))
(setq proton-mail-address (concat "@proton.me" 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}'"))) (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}'"))) (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-context-policy 'pick-first)
(setq mu4e-compose-context-policy 'always-ask) (setq mu4e-compose-context-policy 'always-ask)
(setq mu4e-contexts (setq mu4e-contexts
(list (list
;; outlook ;; outlook
(make-mu4e-context (make-mu4e-context
@ -1203,7 +1299,7 @@ GNU patch review metho dor sometihng idk
(mu4e-refile-folder . "/Outlook/Inbox") (mu4e-refile-folder . "/Outlook/Inbox")
(mu4e-trash-folder . "/Outlook/Deleted") (mu4e-trash-folder . "/Outlook/Deleted")
;; todo stmpmail and compose signatures ;; todo stmpmail and compose signatures
)) ))
(make-mu4e-context (make-mu4e-context
:name "Proton" :name "Proton"
:match-func :match-func
@ -1247,7 +1343,7 @@ GNU patch review metho dor sometihng idk
)) ))
)) ))
) )
#+end_src #+end_src
* Org * Org
#+begin_src emacs-lisp #+begin_src emacs-lisp