From 5e338da1587a89fe26946096855c9dcbb3191bb5 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Mon, 14 Sep 2020 11:48:08 +0200 Subject: [PATCH] Checpoint. Org agenda does not start on today --- .gitignore | 5 ++ config.el | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++ custom.el | 66 +++++++++++++++++++++ init.el | 10 ++-- packages.el | 2 + 5 files changed, 243 insertions(+), 5 deletions(-) create mode 100644 .gitignore create mode 100644 custom.el diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cb11a0b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +.idea +*.log +tmp/ +mu4e-accounts.el diff --git a/config.el b/config.el index dd2892e..ca7a90e 100644 --- a/config.el +++ b/config.el @@ -54,3 +54,168 @@ ;; 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) diff --git a/custom.el b/custom.el new file mode 100644 index 0000000..20e189f --- /dev/null +++ b/custom.el @@ -0,0 +1,66 @@ +(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. + '(org-agenda-custom-commands + '(("n" "Agenda and all TODOs" + ((agenda "" nil) + (alltodo "" nil)) + nil) + ("p" . "Personal context") + ("pa" "Agenda + todo" + ((agenda "" + ((org-agenda-span 'day) + (org-agenda-category-filter-preset 'nil))) + (alltodo "" nil)) + ((org-agenda-category-filter-preset + '("-work"))) + nil) + ("h" "Tasks on hold" todo "HOLD" nil) + ("w" . "Work context") + ("wa" "Agenda + todo" + ((agenda "" + ((org-agenda-span 'day))) + (alltodo "" nil)) + nil nil) + ("x" "Describe command here" alltodo "" + ((org-agenda-files + '("~/org/praca.org")))))) + '(org-agenda-files '("~/org/main.org")) + '(org-agenda-span 1) + '(org-agenda-todo-ignore-scheduled 'future) + '(org-capture-templates + '(("t" "Inbox item" entry + (file "~/org/inbox.org") + "* TODO %? +CREATED: %U") + ("T" "Inbox item with Capture Target" entry + (file "~/org/inbox.org") + "* TODO %? (link) +%a") + ("s" "test" entry + (file "~/org/inbox.org") + "* TODO %a %?")) t) + '(org-fontify-done-headline nil) + '(org-fontify-quote-and-verse-blocks t) + '(org-fontify-whole-heading-line t) + '(org-modules '(org-bbdb org-docview org-gnus org-habit org-info)) + '(org-priority-lowest 70) + '(org-refile-targets + '(("/home/kuba/org/ideas.org" :maxlevel . 2) + ("/home/kuba/org/main.org" :level . 2) + ("/home/kuba/org/entertainment.org" :level . 1))) + '(org-todo-keywords '((sequence "TODO" "DONE(!)" "HOLD")))) +(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. + '(mu4e-header-face ((t (:inherit 'font-lock-keyword-face :weight normal)))) + '(mu4e-header-highlight-face ((t (:inherit 'hl-line :underline t :extend t)))) + '(mu4e-header-marks-face ((t (:inherit 'font-lock-preprocessor-face)))) + '(mu4e-ok-face ((t (:inherit font-lock-comment-face :foreground "black" :slant normal :weight bold)))) + '(mu4e-replied-face ((t (:inherit 'mu4e-header-face :slant italic)))) + '(mu4e-unread-face ((t (:inherit 'font-lock-keyword-face)))) + '(org-headline-done ((t (:inherit org-headline-todo))))) diff --git a/init.el b/init.el index bc11c33..97a22a3 100644 --- a/init.el +++ b/init.el @@ -78,7 +78,7 @@ ;;vterm ; the best terminal emulation in Emacs :checkers - syntax ; tasing you for every semicolon you forget + syntax ; tasing you for every semicolon you forget spell ; tasing you for misspelling mispelling grammar ; tasing grammar mistake every you make @@ -112,7 +112,7 @@ ;;agda ; types of types of types of types... ;;cc ; C/C++/Obj-C madness ;;clojure ; java with a lisp - ;;common-lisp ; if you've seen one lisp, you've seen them all + common-lisp ; if you've seen one lisp, you've seen them all ;;coq ; proofs-as-programs ;;crystal ; ruby at the speed of c ;;csharp ; unity, .NET, and mono shenanigans @@ -145,7 +145,7 @@ ;;nim ; python + lisp at the speed of c ;;nix ; I hereby declare "nix geht mehr!" ;;ocaml ; an objective camel - org ; organize your plain life in plain text + (org +dragndrop ) ; organize your plain life in plain text php ; perl's insecure younger brother ;;plantuml ; diagrams for confusing people more ;;purescript ; javascript, but functional @@ -164,11 +164,11 @@ ;;solidity ; do you need a blockchain? No. ;;swift ; who asked for emoji variables? ;;terra ; Earth and Moon in alignment for performance. - web ; the tubes + ;; web ; the tubes yaml ; JSON, but readable :email - (mu4e +gmail) + mu4e ;;notmuch ;;(wanderlust +gmail) diff --git a/packages.el b/packages.el index b80e9cc..3a44204 100644 --- a/packages.el +++ b/packages.el @@ -48,3 +48,5 @@ ;(unpin! pinned-package another-pinned-package) ;; ...Or *all* packages (NOT RECOMMENDED; will likely break things) ;(unpin! t) + +(package! prettier-js)