3 Commits 74cb38582e ... 8d1542f0a9

Author SHA1 Message Date
  Distopico Vegan 8d1542f0a9 Keep org-mode trigger property unless match with remove list 1 year ago
  Distopico Vegan 1092129824 Migrate to mu4e contexts 1 year ago
  Distopico Vegan 64cd701e53 Get flymake-guile from nongnu elpa 1 year ago
4 changed files with 45 additions and 70 deletions
  1. 2 1
      core/packages.el
  2. 0 4
      core/setup-elget.el
  3. 24 47
      modes/conf-mu4e.el
  4. 19 18
      modes/conf-org.el

+ 2 - 1
core/packages.el

@@ -37,7 +37,6 @@
     popwin
     browse-kill-ring
     diminish
-    flymake-elisp-config
     highlight-escape-sequences
     highlight-indent-guides
     highlight-symbol
@@ -93,6 +92,8 @@
     simple-httpd
     tern ;; I should try eglot
     xref-js2
+    flymake-elisp-config
+    flymake-guile
 
     ;; Debug
     nodejs-repl

+ 0 - 4
core/setup-elget.el

@@ -44,10 +44,6 @@
                :description "Work in emacs with Gradle build automation tool"
                :type git
                :url "https://github.com/vhallac/gradle-el.git")
-	(:name "flymake-guile"
-	       :description "Flymake backend for Guile"
-	       :type git
-	       :url "https://framagit.org/flymake-backends/flymake-guile.git")
         ;; Productive
         (:name "org-reveal"
                :description "reveal.js stuff for orgmode"

+ 24 - 47
modes/conf-mu4e.el

@@ -54,7 +54,7 @@ launch the no-attachment warning message defined in
   "String to display in the mode line.")
 (defvar distopico:mu4e-update-timer nil
   "Interval timer object.")
-(defvar distopico:mu4e-mail-address-list)
+(defvar distopico:mu4e-contexts)
 (defvar distopico:mu4e-account-alist)
 
 ;; General mu4e config
@@ -64,12 +64,14 @@ launch the no-attachment warning message defined in
       mu4e-compose-keep-self-cc nil
       mu4e-compose-complete-addresses t
       mu4e-compose-dont-reply-to-self t
+      ;; mu4e-change-filenames-when-moving - enable after migrate to mbsync
       mu4e-hide-index-messages t
       mu4e-headers-auto-update t
       mu4e-notification-support t
       mu4e-use-fancy-chars t
       mu4e-split-view 'horizontal
       mu4e-update-interval 300
+      mu4e-context-policy 'pick-first
       mu4e-headers-visible-lines 20
       mu4e-headers-leave-behavior 'ask
       mu4e-headers-fields '((:human-date    .   12)
@@ -165,11 +167,8 @@ launch the no-attachment warning message defined in
 ;; Default Account
 (setq mu4e-sent-folder "/1-Distopico/Sent"
       mu4e-drafts-folder "/1-Distopico/Drafts"
-      mu4e-trash-folder "/1-Distopico/Trash")
-
-;; mu4e email list
-;; TODO: migrate to mu4e contexts
-(setq mu4e-user-mail-address-list distopico:mu4e-mail-address-list)
+      mu4e-trash-folder "/1-Distopico/Trash"
+      mu4e-refile-folder "/1-Distopico/Archive")
 
 ;; Sign/Encrypt
 (setq mml-secure-openpgp-encrypt-to-self t
@@ -194,27 +193,22 @@ launch the no-attachment warning message defined in
 ;;------------------
 ;; Functions
 ;;------------------
-;; Set Account
-(defun distopico:mu4e-set-account ()
-  "Set the account for composing a message."
-  (let* ((account
-          (if mu4e-compose-parent-message
-              (let ((maildir (mu4e-message-field mu4e-compose-parent-message :maildir)))
-                (string-match "/\\(.*?\\)/" maildir)
-                (match-string 1 maildir))
-            (completing-read (format "Compose with account: (%s) "
-                                     (mapconcat #'(lambda (var) (car var))
-                                                distopico:mu4e-account-alist "/"))
-                             (mapcar #'(lambda (var) (car var)) distopico:mu4e-account-alist)
-                             nil t nil nil (caar distopico:mu4e-account-alist))))
-         (account-vars (cdr (assoc account distopico:mu4e-account-alist))))
-    (if account-vars
-        (mapc #'(lambda (var)
-                  (set (car var) (cadr var)))
-              account-vars)
-      (error "No email account found"))))
-
-;; Starting the whole mu4e in its own frame
+(defun distopico:mu4e--default-folders (acc-path settings)
+  "Get default folders based in `ACC-PATH' and merge it with `SETTINGS'."
+  (append `((mu4e-sent-folder . ,(format "/%s/Sent" acc-path))
+	    (mu4e-drafts-folder . ,(format "/%s/Drafts" acc-path))
+	    (mu4e-trash-folder . ,(format "/%s/Trash" acc-path))
+	    (mu4e-refile-folder . ,(format "/%s/Archive" acc-path)))
+	  settings))
+
+(defun distopico:mu4e--maildir-matches-p (maildir-rx)
+  "Determine if the `maildir' match with `MAILDIR-RX' regexp."
+  (apply-partially
+   (lambda (maildir-rx msg)
+      (when msg
+	(string-match-p maildir-rx (mu4e-message-field msg :maildir))))
+   maildir-rx))
+
 (defun mu4e-in-new-frame ()
   "Start mu4e in new frame."
   (interactive)
@@ -264,15 +258,13 @@ launch the no-attachment warning message defined in
           (delete-other-windows))
       (kill-buffer (current-buffer)))))
 
-;; Toggle related
 (defun distopico:mu4e-toggle-headers-include-related ()
-  "Toggle `mu4e-headers-include-related' and refresh."
+  "Toggle related `mu4e-headers-include-related' and refresh."
   (interactive)
   (setq mu4e-search-include-related
         (not mu4e-search-include-related))
   (mu4e-search-rerun))
 
-;; Custom add contact
 (defun distopico:mu4e-action-add-org-contact (msg)
   "Add an org-contact entry based address.
 From: address of the \
@@ -306,19 +298,6 @@ store your org-contacts."
     (when (fboundp 'org-capture)
       (org-capture nil key))))
 
-(defun distopico:mu4e-unread-mail-query ()
-  "The query to look for unread messages in all account INBOXes."
-  (mapconcat
-   (lambda (acct)
-     (let ((name (car acct)))
-       (format "%s"
-               (mapconcat (lambda (fmt)
-                            (format fmt name))
-                          '("flag:unread AND maildir:'/%s/INBOX'")
-                          " "))))
-   distopico:mu4e-account-alist
-   " OR "))
-
 (defun distopico:mu4e-new-mail-p ()
   "Predicate for if there is new mail or not in Boolean."
   (not (eq 0 (string-to-number
@@ -331,7 +310,7 @@ store your org-contacts."
    (shell-command-to-string
     (concat "echo -n $( " mu4e-mu-binary " find "
             "--muhome " mu4e-mu-home " "
-            (distopico:mu4e-unread-mail-query)
+            "flag:unread AND maildir:'/\/*\/INBOX*/'"
             " 2>/dev/null | wc -l )"))))
 
 (defun distopico:mu4e-inbox-update ()
@@ -358,8 +337,6 @@ store your org-contacts."
   (interactive)
   (mu4e-message "Updating index & cache...")
   (mu4e-update-index)
-  ;;(mu4e-maildirs-extension-force-update '(16))
-  ;;(mu4e-maildirs-extension-index-updated-handler)
   (distopico:mu4e-inbox-update))
 
 (defun distopico:message-attachment-present-p ()
@@ -410,6 +387,7 @@ from: http://mbork.pl/2016-02-06_An_attachment_reminder_in_mu4e"
 
 (defun distopico:mu4e-init-load-hook ()
   "Run mu4e in startup."
+  (setq-default mu4e-contexts (eval distopico:mu4e-contexts))
   (mu4e t)
   (distopico:mu4e-mode-line t))
 
@@ -429,7 +407,6 @@ from: http://mbork.pl/2016-02-06_An_attachment_reminder_in_mu4e"
 ;;-------------------
 ;; Hooks
 ;;-------------------
-(add-hook 'mu4e-compose-pre-hook #'distopico:mu4e-set-account)
 (add-hook 'mu4e-index-updated-hook #'distopico:mu4e-index-updated-hook)
 (add-hook 'mu4e-view-mode-hook #'distopico:mu4e-view-mode-hook)
 (add-hook 'mu4e-compose-mode-hook #'distopico:mu4e-compose-mode-hook)

+ 19 - 18
modes/conf-org.el

@@ -22,12 +22,13 @@
   (require 'ox-hugo))
 
 ;; Vars
-(defvar distopico:org-directory (expand-file-name "~/Documents/org/"))
-(defvar distopico:org-agenda-files '("daily.org" "calendar.org" "notes.org" "life.org" "todo.org" "contacts.org"))
-(defvar distopico:special-categories '("Holiday" "Birthday" "Vacation"))
-(defvar distopico:icon-org-mode (in-emacs-d "themes/icons/"))
-(defvar distopico:org-clock-default-effort "1:00")
-(defvar distopico:org-appt-current nil)
+(defvar-local distopico:org--directory (expand-file-name "~/Documents/org/"))
+(defvar-local distopico:org--agenda-files '("daily.org" "calendar.org" "notes.org" "life.org" "todo.org" "contacts.org"))
+(defvar-local distopico:org--special-categories '("Holiday" "Birthday" "Vacation"))
+(defvar-local distopico:org--icons (in-emacs-d "themes/icons/"))
+(defvar-local distopico:org--clock-default-effort "1:00")
+(defvar-local distopico::org--state-remove-trigger '("TODO" "HOLD"))
+(defvar distopico:org--appt-current nil)
 
 ;; Configuration
 (setq org-modules
@@ -45,7 +46,7 @@
 		org-projectile)))
 
 ;; General settings
-(setq org-directory distopico:org-directory
+(setq org-directory distopico:org--directory
       org-startup-folded t
       org-log-done 'time
       org-log-into-drawer t
@@ -199,7 +200,7 @@
 	 "* NEXT Respond to %:fromaddress on %:subject\nSCHEDULED: %t\n CAPTURED: %U\n%a\n")))
 
 ;; Agenda
-(setq org-agenda-files (mapcar (lambda (x) (expand-file-name x org-directory)) distopico:org-agenda-files)
+(setq org-agenda-files (mapcar (lambda (x) (expand-file-name x org-directory)) distopico:org--agenda-files)
       org-agenda-window-setup 'only-window
       org-agenda-restore-windows-after-quit t
       org-agenda-skip-deadline-prewarning-if-scheduled t
@@ -363,12 +364,12 @@ TODO: make this generic to replace `distopico:org-appt-disp-window-function'."
 	   :severity 'normal
 	   :style 'notifications
 	   :category 'emacs
-	   :icon (concat distopico:icon-org-mode "org-mode.png"))))
+	   :icon (concat distopico:org--icons "org-mode.png"))))
 
 (defun distopico:org-appt-disp-window-function (left time message)
   "Show notification on appointments based on `LEFT' `TIME' `MESSAGE'."
   (progn
-    (add-to-list 'distopico:org-appt-current message)
+    (add-to-list 'distopico:org--appt-current message)
     (alert message
 	   :title (concat "Appointment "
 			  (cond ((equal left "0") "now!")
@@ -378,13 +379,13 @@ TODO: make this generic to replace `distopico:org-appt-disp-window-function'."
 	   :severity 'moderate
 	   :style 'notifications
 	   :category 'emacs
-	   :icon (concat distopico:icon-org-mode "org-mode.png"))))
+	   :icon (concat distopico:org--icons "org-mode.png"))))
 
 (defun distopico:org-appt-delete-window-function ()
   "Delete appointment after show it."
-  (if distopico:org-appt-current
-      (setq distopico:org-appt-current
-	    (delete (nth 0 distopico:org-appt-current) distopico:org-appt-current))))
+  (if distopico:org--appt-current
+      (setq distopico:org--appt-current
+	    (delete (nth 0 distopico:org--appt-current) distopico:org--appt-current))))
 
 (defun distopico:org-remove-redundant-tags ()
   "Remove redundant tags of headlines in current buffer.
@@ -498,13 +499,13 @@ from: http://pages.sachachua.com/.emacs.d/Sacha.html"
   (cond ((equal org-state "NEXT")
 	 (unless org-depend-doing-chain-find-next
 	   (org-set-property "TRIGGER" "chain-find-next(NEXT,from-current,priority-up,effort-down)")))
-	((not (member org-state org-done-keywords))
+	((member org-state distopico::org--state-remove-trigger)
 	 (save-excursion
 	   (org-show-entry)
 	   (org-delete-property "TRIGGER")))))
 
 (defun distopico:org-toggle-next-tag ()
-  "Org possibly toggle next tag based on todo kewyord."
+  "Org possibly toggle next tag based on todo keyword."
   (save-excursion
     (org-back-to-heading)
     (let ((todo-is-next (equal (org-get-todo-state) "NEXT"))
@@ -528,7 +529,7 @@ from: http://pages.sachachua.com/.emacs.d/Sacha.html"
 (defun distopico:org-add-default-effort ()
   "Add a default effort estimation."
   (unless (org-entry-get (point) "Effort")
-    (org-set-property "Effort" distopico:org-clock-default-effort)))
+    (org-set-property "Effort" distopico:org--clock-default-effort)))
 
 
 (defun distopico:org-agenda-redo-in-other-window ()
@@ -592,7 +593,7 @@ this with to-do items than with projects or headings."
 				 (insert entry)
 				 (org-get-category (point-min)))))
 		 (when (string-match
-			(mapconcat 'downcase distopico:special-categories "\\|")
+			(mapconcat 'downcase distopico:org--special-categories "\\|")
 			category)
 		   (cl-return '(:foreground "PaleGreen")))))))
 	(when face (cl-return face))))))