diff --git a/TODO b/TODO index 32b976fa..1d2be7ae 100644 --- a/TODO +++ b/TODO @@ -12,8 +12,6 @@ threads when searching - refactor fill_database function in test cases - handling of command line options / help - - fix 'mu find maildir:/' - - check for valid flags (i.e.., flag:foobar should raise an error) - handle exception 'The revision being read has been discarded - you should call Xapian::Database::reopen() and retry the operation' @@ -52,9 +50,11 @@ - open links to mails through headers-mode somehow (i.e.., mu4e-view-message-with-msgid) - improve mouse interaction (i.e., cursor vs point) + - add example 'run shellscript on message' ** Done (0.9.9) + - make contacts in the view clickable (toggle long/short display, compose message) - opening urls is too eager (now use M-RET for opening url at point, not just RET, which conflicted with using RET for scrolling) - document quoting of queries diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index 0fd8c10d..852a099a 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -273,6 +273,11 @@ flag set)." "Face for showing URLs and attachments in the message view." :group 'mu4e-faces) +(defface mu4e-view-contact-face + '((t :inherit font-lock-variable-name-face)) + "Face for showing URLs and attachments in the message view." + :group 'mu4e-faces) + (defface mu4e-highlight-face '((t :inherit font-lock-pseudo-keyword-face :bold t)) "Face for highlighting things." diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index 978c8e86..69b01421 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -59,10 +59,11 @@ complete list of available headers, see `mu4e-header-info'." :type 'string :group 'mu4e-view) -(defcustom mu4e-view-show-addresses t - "Whether to show e-mail addresses for contacts in address-fields, - if names are available as well (note that the e-mail addresses - are still available as a tooltip." +(defcustom mu4e-view-show-addresses nil + "Whether to initially show full e-mail addresses for contacts in +address fields, rather than only their names. Note that you can +toggle between long/short display by klicking / M-RET on the +contact." :type 'boolean :group 'mu4e-view) @@ -263,21 +264,64 @@ add text-properties to VAL." (buffer-string)) ""))) +(defun mu4e~view-toggle-contact (&optional point) + "Toggle between the long and short versions of long/short string +at POINT, or if nil, at (point)." + (interactive) + (unless (get-text-property (or point (point)) 'long) + (error "point is not toggleable")) + (let* ((point (or point (point))) + ;; find the first pos part of the button + (start (previous-property-change point)) + (start (if start (next-property-change start) (point-min))) + ;; find the first pos not part of the button (possibly nil) + (end (next-property-change point)) + (end (or end (1+ (point-max)))) ;; one beyond + (longtext (get-text-property point 'long)) + (shorttext (get-text-property point 'short)) + (inhibit-read-only t)) + (if (string= (get-text-property point 'display) longtext) + (add-text-properties start end `(display ,shorttext)) + (add-text-properties start end `(display ,longtext))))) + +(defun mu4e~view-compose-contact (&optional point) + "Compose a message for the address at point." + (interactive) + (unless (get-text-property (or point (point)) 'email) + (error "No address at point")) + (mu4e~compose-mail (get-text-property (or point (point)) 'email))) + (defun mu4e~view-construct-contacts-header (msg field) "Add a header for a contact field (ie., :to, :from, :cc, :bcc)." (mu4e~view-construct-header field (mapconcat (lambda(c) - (let ((name (car c)) (email (cdr c))) + (let* ((name (car c)) + (email (cdr c)) + (short (or name email)) ;; name may be nil + (long (if name (format "%s <%s>" name email) email)) + (map (make-sparse-keymap))) + (define-key map [mouse-1] 'mu4e~view-toggle-contact) + (define-key map [?\M-\r] 'mu4e~view-toggle-contact) + (define-key map [mouse-2] 'mu4e~view-compose-contact) + (define-key map "C" 'mu4e~view-compose-contact) (propertize - (if name - (if mu4e-view-show-addresses - (format "%s <%s>" name email) - (format "%s" name)) - (format "%s" email)) - 'help-echo email))) - (plist-get msg field) ", "))) - + (if mu4e-view-show-addresses long short) + 'long long + 'short short + 'email email + 'display (if mu4e-view-show-addresses long short) + 'keymap map + 'face 'mu4e-view-contact-face + 'mouse-face 'highlight + 'help-echo + (format (concat + "<" email ">\n" + "[mouse-1] or [M-RET] to toggle long/short display\n" + "[mouse-2] or C to compose a mail for this recipient"))))) + (plist-get msg field) ", ") t)) + + (defun mu4e~view-open-save-attach-func (msg attachnum is-open) "Return a function that offers to save attachment NUM. If IS-OPEN is nil, and otherwise open it." diff --git a/mu4e/mu4e.texi b/mu4e/mu4e.texi index b9c585e7..deb15be8 100644 --- a/mu4e/mu4e.texi +++ b/mu4e/mu4e.texi @@ -743,10 +743,12 @@ variable @code{mu4e-view-fields}. @item You can customize the date format by setting the variable @code{mu4e-date-format-long}, using the same format that @code{format-time-string} uses. -@item If you only want to see the name and not the e-mail address of the -contacts in address fields, you can set @option{mu4e-view-show-addresses} to -@t{nil}. This will hide the addresses for contacts that also have a name. The -e-mail address is still available as a tool-tip. +@item By default, @t{mu4e} shows only the names of contacts in address fields, +and not the e-mail addresses. You can see the e-mail addresses by clicking on +the name, or pressing @key{M-RET}. Furthermore, you can compose a message for +the contact at point by either @key{[mouse-2]} or pressing @key{C}. If you +always want to see the addresses, you can set +@option{mu4e-view-show-addresses} to @t{t}. @item The body text can be line-wrapped (toggle between wrapped/not-wrapped with @key{w}) and/or cited parts can be hidden (toggle between hidden/not-hidden with @key{h}. If you want to do this by default when viewing messages, you can