Closed nickanderson closed 3 years ago
~+++++
is only some random characters to fill the dashboard. When in dashboard mode, if you click them, they should be replaced with the actual count. The number of random characters should match the format string. %5d
means you need 5 chracters. I did that to make sure to insert the count at the right place.~
Read too fast. If the count is bigger than your format, the dashboard will repalce with +++. In your example, the format is %3d
and this means that any count > 999 will be displayed as +++
. This is to avoid to mess up the underlying org file and to exactly overwrite (no insert).
Thank you for the reply, I had suspected as much, but altering the format didn't result in what I expected.
mu sees 20075 emails from my address:
╰─➤ mu find "from:nick@cmdln.org" | wc -l
20075
I altered the format to use seven digits.
Note that one the link is mu:mu
(which I saw elsewhere), but it's the same result with just mu:
But, it shows +++++++
:
Damn! Is it only with this specific search or does it happen everywhere ?
It's not everywhere. It seems to work for the date based examples.
But, flag:unread
seems to be affected.
And its not all from
searches either. A search with 2 results works :).
flag:attach
, flag:flagged
, flag:encrypted
all seem to work.
Can you try with a file containing only Test: [[mu:flag:unread|%5d][-----]]
and start dashboard mode, then click on -----
?
Oh wait, why do you have mu:mu
?
Why mu:mu
? Because I saw it somewhere so figured I would give it a try.
I created test-dashboard.org
, containing only Test: [[mu:flag:unread|%5d][-----]]
. I ran mu4e-dashboard-mode
, the dashes turned into pluses. When I try to click on the pluses I get wrong type arguiment stringp nil
. I thought perhaps this is because of a missing * Information
section, so I added it, resulting in this complete file:
Test: [[mu:flag:unread|%5d][-----]]
* Information
*Database* : ~/.mu/xapian
*Maildir* : ~/Maildir
*Addresses* : [[mailto:nick@cmdln.org][<nick@cmdln.org>]] /(cmdln.org)/
Again, I ran mu4e-dashboard-mode
the -
turned into +
. Clicking on the link still results in Wrong type argument: stringp nil
.
I also tried inserting a link for a count of emails from a new colleague, being quite new, I have received < 10 emails from them.
Can you try to add a (message "%s %s" command output)
just after https://github.com/rougier/mu4e-dashboard/blob/main/mu4e-dashboard.el#L152
In the messages buffer, I see things like:
Error during redisplay: (eval (spaceline-ml-main)) signaled (wrong-type-argument symbolp (fci-mode " ⓕ" " f")) [18 times]
You mean nothing from the dashboard ? Did you re-eavaluate the function after inserting the message
command ? This line should print the command that was sent + the result. It's strange that you see nothing.
Yes, nothing different in the dashboard. Yes, I did re-evaluate the funciton, it's sitting in an elisp src block in that buffer for ease.
When I run mu4e-dashboard-mode it simply replaces the -
with +
. When I click the +
I get Wrong type argument: stringp nil
#+title: Mu4e Test Dashboard
Test: [[mu:flag:unread|%5d][+++++]]
#+begin_src emacs-lisp :tangle yes
(defun mu4e-dashboard-update-link (link)
"Update content of a formatted mu4e LINK.
A formatted link is a link of the form
[[mu4e:query|limit|fmt][(---------)]] where fmt is a non nil
string describing the format. When a link is cleared, the
description is replaced by a string for the form \"(---)\" and
have the same size as the current description. If the given
format is too big for the current description, description is
replaced with + signs."
(let* ((path (org-element-property :path link))
(query (string-trim (nth 0 (split-string path "|"))))
(fmt (nth 1 (split-string path "|")))
(beg (org-element-property :contents-begin link))
(end (org-element-property :contents-end link))
(size (- end beg)))
(if (and fmt (> (length fmt) 0))
(let* ((command (format "%s find %s 2> /dev/null | wc -l" mu4e-dashboard-mu-program query))
(output (string-to-number (shell-command-to-string command)))
(output (format fmt output)))
(let ((modified (buffer-modified-p))
(inhibit-read-only t))
(save-excursion
(message "%s %s" command output)
(delete-region beg end)
(goto-char beg)
(insert (if (<= (length output) size) output
(make-string size ?+))))
(set-buffer-modified-p modified))))))
#+end_src
#+RESULTS:
: mu4e-dashboard-update-link
* Information
*Database* : ~/.mu/xapian
*Maildir* : ~/Maildir
*Addresses* : [[mailto:nick@cmdln.org][<nick@cmdln.org>]] /(cmdln.org)/
And nothing in the *Messages*
buffer?
Nope. Maybe I am doing something wrong though.
¯\_(ツ)_/¯
I updated my spaemacs from the develop branch. I altered the test dashboard to replace + with -, I increased from 5 to 10 and re-enabled the dashboard mode. It rendered this time.
Test: [[mu:flag:unread|%10d][ 303329]]
OH! I think I figured out what the problem was in my dashboard links.
[[mu:from:nick.anderson@northern.tech][Nick Anderson]] / [[mu:from:nick.anderson@northern.tech|(%5d)][(17289)]]
!=
[[mu:from:nick.anderson@northern.tech|][Nick Anderson]] / [[mu:from:nick.anderson@northern.tech|(%5d)][(17289)]]
Notice, the missing |
in the link target from the first one. When that is the case, the second link renders as +
.
Oh, I see now. We need to change the parsing because the first version shoudl be ok. "Parsing" is done here. Maybe just replacing "|"
by "|]"
could work.
https://github.com/rougier/mu4e-dashboard/pull/23
It worked for me.
Cool. Thanks for the PR.
Your most welcome, thanks for the help troubleshooting, and the effort to make this.
I did a simple search and replace on the example for Richard Stallman but my counts show
+
instead of the count.Results in
It does seem to work for some addresses that have very few results for.
\_(ツ)_/
Have I made some simple mistake that I can't see?