emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/nano-modeline 77c0ccdc01 1/2: Better mode-line for mu4e


From: ELPA Syncer
Subject: [elpa] externals/nano-modeline 77c0ccdc01 1/2: Better mode-line for mu4e message view
Date: Sat, 20 Jan 2024 06:58:30 -0500 (EST)

branch: externals/nano-modeline
commit 77c0ccdc01b57ea3c24ff533633a6661cddb1292
Author: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Commit: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>

    Better mode-line for mu4e message view
---
 nano-modeline.el | 60 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 53 insertions(+), 7 deletions(-)

diff --git a/nano-modeline.el b/nano-modeline.el
index c8614f2c08..6988a1e9c6 100644
--- a/nano-modeline.el
+++ b/nano-modeline.el
@@ -121,6 +121,7 @@
 ;;
 
 ;;; Code:
+(require 'cl-lib)
 
 (defgroup nano nil
   "N Λ N O"
@@ -624,6 +625,15 @@ delay needs to be set to 0."
         (propertize (format "(%s%s, %s)" (or symbol " ") branch state)
                     'face (nano-modeline-face 'primary)))))
 
+(defun nano-modeline-primary-info (text)
+  "Information using primary face"
+  
+  (propertize text 'face (nano-modeline-face 'primary)))
+
+(defun nano-modeline-secondary-info (text)
+  "Information using primary face"
+  
+  (propertize text 'face (nano-modeline-face 'secondary)))
 
 (defun nano-modeline-mu4e-search-filter ()
   "Mu4e current search"
@@ -645,13 +655,47 @@ delay needs to be set to 0."
          (name (if context (mu4e-context-name context) "NONE")))
     (upcase name)))
 
+(defun nano-modeline-mu4e-message-to ()
+  "Return the recipients of a message, separating me from others"
+  
+  (with-current-buffer "*mu4e-headers*"
+    (let* ((msg (mu4e-message-at-point))
+           (list (memq 'list (plist-get msg :flags)))
+           (cc (mapcar (lambda (item)
+                         (downcase (plist-get item :email)))
+                       (plist-get msg :cc)))
+           (to (mapcar (lambda (item)
+                         (downcase (plist-get item :email)))
+                       (plist-get msg :to)))
+           (to-names (mapcar (lambda (item)
+                               (capitalize (downcase (plist-get item :name))))
+                             (plist-get msg :to)))
+           (all (cl-union to cc))  
+           (me (mapcar #'downcase (mu4e-personal-addresses)))
+           (me (cl-intersection all me :test #'string-equal))
+           (others (cl-set-difference all me :test #'string-equal)))
+      (cond (list
+             (concat "to " (car to-names)))
+            ((= (length others) 0)
+             "to me")
+            ((and (> (length others) 0) (< (length others) (length all)))
+             (format "to me (+%d recipients)" (length others)))
+            ((and (= (length others) 1))
+             (format "to %s" (car to-names)))
+            (t
+             (format "to %s (+%d recipients)" (car to-names) (1- (length 
others))))))))
+
 (defun nano-modeline-mu4e-message-from ()
-  "Mu4e current message sender"
+  "Return the sender of the message that can be me or a name"
   
   (with-current-buffer "*mu4e-headers*"
-    (let ((msg (mu4e-message-at-point)))
-      (mu4e~headers-contact-str (mu4e-message-field msg :from)))))
-                         
+    (let* ((msg (mu4e-message-at-point))
+           (from (mu4e-message-field msg :from))
+           (from-name (capitalize (downcase (plist-get (car from) :name))))
+           (from-email (plist-get (car from) :email))
+           (me (mapcar #'downcase (mu4e-personal-addresses))))
+      (if (member from-email me) "Me"from-name))))
+
 (defun nano-modeline-mu4e-view-in-xwidget ()
   (interactive)
   (with-current-buffer "*mu4e-headers*"
@@ -684,7 +728,7 @@ delay needs to be set to 0."
   
   (let* ((msg (mu4e-message-at-point))
          (date (mu4e-message-field msg :date)))
-    (propertize (format-time-string " %d/%m " date)
+    (propertize (format-time-string "%d %b %Y at %H:%M" date)
                 'face (nano-modeline-face 'secondary))))
  
 (defun nano-modeline-pdf-page ()
@@ -915,8 +959,10 @@ common action"
                    ("forward:bootstrap". (mu4e-compose-forward . "Forward 
message")))))
     (funcall nano-modeline-position
              `((nano-modeline-buffer-status "FROM") " "
-               (nano-modeline-buffer-name ,(nano-modeline-mu4e-message-from)))
-             `((nano-modeline-buttons ,buttons t) " "
+               (nano-modeline-buffer-name ,(nano-modeline-mu4e-message-from)) 
" "
+               (nano-modeline-primary-info ,(nano-modeline-mu4e-message-to)))
+             `((nano-modeline-mu4e-message-date) " "
+               ;; (nano-modeline-buttons ,buttons t) " "
                (nano-modeline-window-dedicated)))))
 
 (defun nano-modeline-mu4e-compose-mode ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]