Re: Help in Emacs config
Atanas Janackovski writes: > I have justed strated using `notmuch' in Emacs (doom configuration), and I > love > it! However, there are a couple of things I'd like help with. > > 1. I have a number of accounts that I use. How do I configure my config to > save >draft messages based on the "From" header? There currently isn't any automated filing rules in the way that notmuch-fcc-dirs works. It could be done, if there was sufficient interest (and somebody did it!), > 2. From time to time, I want to view `html' content in my browser. Does anyone >have any tips on how I would do this? I have tried the below but this did > not Not sure if this is what you are after, but you can choose ". o" and give the name of a browser. ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: Help in Emacs config
On Tue, Mar 07 2023, Atanas Janackovski wrote: > I have justed strated using `notmuch' in Emacs (doom configuration), > and I love it! Great! I'm glad it's useful for you. > 1. I have a number of accounts that I use. How do I configure my > config to save draft messages based on the "From" header? I'm not sure what you're looking for here. Do you want drafts saved in different locations? At some level, a draft message is just another message, so you can search for drafts based on the "From" header just like any other message. > 2. From time to time, I want to view `html' content in my > browser. Does anyone have any tips on how I would do this? I have > tried the below but this did not seem to work: This seems to work out of the box for me. >From looking at the contents of my mailcap-mime-data variable, what sticks out to me is that "text" and then "html" are at different levels in the structure such as: ("text" ("html" (viewer . "/usr/bin/firefox '%s'") (type . "text/html") ("nametemplate" . "%s.html") (test . t) ("description" . "HTML Text") (source . user))) Have fun with notmuch! -Carl ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Help in Emacs config
Hi, I have justed strated using `notmuch' in Emacs (doom configuration), and I love it! However, there are a couple of things I'd like help with. 1. I have a number of accounts that I use. How do I configure my config to save draft messages based on the "From" header? 2. From time to time, I want to view `html' content in my browser. Does anyone have any tips on how I would do this? I have tried the below but this did not seem to work: , | (add-to-list 'mailcap-mime-data | '("text/html" (viewer . "open -a /Applications/Firefox.app") |(type . ,(purecopy "text/html")) |(test . ,(purecopy "/usr/bin/file -i -L -b %s | grep -q '^.*: *text/html;'" ` Any help is greatly appreciated, and please let me know if you need more information about my request. Thanks in advance. Kind Regards, -- *Atanas* ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH 1/2] CLI: simplify help command
David Bremner writes: > This will allow "notmuch help" to work for arbitrary external commands > and for any added non-command topics (such as notmuch-sexp-queries). series applied to master ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: Help with sending mail from notmuch-emacs
HGV writes: > When I use a utf-8 character (e.g., Süßwasser), both the Content-Type > and Content-Transfer-Encoding were correctly set. Glad you got it working. Debugging encoding issues in Emacs is not very fun in my experience. d ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: Help with sending mail from notmuch-emacs
Thanks, David, for your continued help. I believe I have sorted this out and just wanted to note what I found here for posterity in case others looking at the archives have my same question. Once I determined that indeed my issues with Content-Transfer-Encoding and Content-Type headers happened with message-mode outside of notmuch, I read more about how message-mode, MIME, and the rest of the sending chain all work together. The problem seems to be that I was sending simple test emails to myself that had only ASCII characters. Despite my own utf-8 encoding, message-mode recognized that the files only had ASCII characters and set the Content-Type header as just "text/plain" or "text/plain; charset=ascii" (still not sure about the charset aspect). And with only one ASCII-only plain-text part, Content-Transfer-Encoding was not necessary and therefore not set. When I use a utf-8 character (e.g., Süßwasser), both the Content-Type and Content-Transfer-Encoding were correctly set. Thanks again for the tremendous software and help. Yours kindly, HGV ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 2/2] CLI: mention sexp-queries in help topics, alphabetize
There does not seem to be an easy way to automate maintaining this list, but new topics are not added very often. --- notmuch.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/notmuch.c b/notmuch.c index c39fcfb2..68a785e2 100644 --- a/notmuch.c +++ b/notmuch.c @@ -211,12 +211,14 @@ typedef struct help_topic { } help_topic_t; static const help_topic_t help_topics[] = { -{ "search-terms", - "Common search term syntax." }, { "hooks", "Hooks that will be run before or after certain commands." }, { "properties", "Message property conventions and documentation." }, +{ "search-terms", + "Common infix search term syntax." }, +{ "sexp-queries", + "Common s-expression search term syntax." }, }; static const command_t * -- 2.35.2 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 1/2] CLI: simplify help command
This will allow "notmuch help" to work for arbitrary external commands and for any added non-command topics (such as notmuch-sexp-queries). --- notmuch.c | 22 +++--- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/notmuch.c b/notmuch.c index ac25ae18..c39fcfb2 100644 --- a/notmuch.c +++ b/notmuch.c @@ -329,9 +329,7 @@ exec_man (const char *page) static int _help_for (const char *topic_name) { -const command_t *command; -const help_topic_t *topic; -unsigned int i; +char *page; if (! topic_name) { printf ("The notmuch mail system.\n\n"); @@ -348,23 +346,9 @@ _help_for (const char *topic_name) return EXIT_SUCCESS; } -command = find_command (topic_name); -if (command) { - char *page = talloc_asprintf (NULL, "notmuch-%s", command->name); - exec_man (page); -} - -for (i = 0; i < ARRAY_SIZE (help_topics); i++) { - topic = &help_topics[i]; - if (strcmp (topic_name, topic->name) == 0) { - char *page = talloc_asprintf (NULL, "notmuch-%s", topic->name); - exec_man (page); - } -} +page = talloc_asprintf (NULL, "notmuch-%s", topic_name); +exec_man (page); -fprintf (stderr, -"\nSorry, %s is not a known command. There's not much I can do to help.\n\n", -topic_name); return EXIT_FAILURE; } -- 2.35.2 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
help
___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: Help with sending mail from notmuch-emacs
hgv writes: > > I'm still struggling with the Content-Transfer-Encoding header and the > "charset=utf-8" half of the Content-Type header, both of which I > cannot get set in my emails, if anyone has any thoughts! My only (not so helpful) thought is that this almost certainly an issue outside notmuch in message-mode. If you can duplicate it there (M-x message-mail) you can get help from the wider community of message-mode users. ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: Help with sending mail from notmuch-emacs
Quoting David Bremner (2022-05-12 17:47:23) > hgv writes: > > Did you try setting a break on notmuch-maildir-fcc-with-notmuch-insert? > I'm guessing that it doesn't get called because the output of msmtpq is > misinterpreted as an error. I think this is a bug in msmtpq (or at least > a way in which it differs from a traditional sendmail). For me (using > nullmailer) "/usr/lib/sendmail -oi -f da...@tethera.net -t < foo.eml" > generates no output on success. If you can change / replace the msmtpq > script, you could try commenting out the log line [1] that is printing > "send was successful". > > Another test (which would be worthwhile for your second issue as well), > is to test with M-x message-mail (however one calls a command in doom). > This will eliminate the possibility of some setting of notmuch confusing > things. Of course it still won't insert into the notmuch database, but > if it is working you should not see a message about "Sending...failed" > > David > > [1] Maybe line 503? > Thank you, David, for the continued help. You were right to focus on the msmtpq script! And I'm sorry I didn't look there before. There is a simple option to set the script to quiet, which solves the issue. I'm still struggling with the Content-Transfer-Encoding header and the "charset=utf-8" half of the Content-Type header, both of which I cannot get set in my emails, if anyone has any thoughts! ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: Help with sending mail from notmuch-emacs
hgv writes: > 1. Mail gets sent but doesn't save in the correct directory via FCC. I > use msmtpq as my sending program. Upon sending, I receive this > message: "message-send-mail-with-sendmail: Sending...failed to mail > for [ -oi -f h...@fastmail.com -t ] : send was successful;" The mail is > sent but is not saved in the fcc dir nor entered into the notmuch > database. I have enabled emacs debugger (on entry with different > functions related to sending) and stepped through the process but > didn't see any pertinent information in the messages. My fcc line > reads `(setq notmuch-fcc-dirs "fastmail/Sent +sent +inbox +sent-new")` > (fuller notmuch-emacs config below). Any guidance on fixing or further > troubleshooting (what should I look for on debugger) is appreciated. Did you try setting a break on notmuch-maildir-fcc-with-notmuch-insert? I'm guessing that it doesn't get called because the output of msmtpq is misinterpreted as an error. I think this is a bug in msmtpq (or at least a way in which it differs from a traditional sendmail). For me (using nullmailer) "/usr/lib/sendmail -oi -f da...@tethera.net -t < foo.eml" generates no output on success. If you can change / replace the msmtpq script, you could try commenting out the log line [1] that is printing "send was successful". Another test (which would be worthwhile for your second issue as well), is to test with M-x message-mail (however one calls a command in doom). This will eliminate the possibility of some setting of notmuch confusing things. Of course it still won't insert into the notmuch database, but if it is working you should not see a message about "Sending...failed" David [1] Maybe line 503? ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: Help with sending mail from notmuch-emacs
Quoting David Bremner (2022-05-09 18: 13:31) > What is your setting for the variable > > notmuch-maildir-use-notmuch-insert > > It should be t (the default) for that style of notmuch-fcc-dirs setting. > It is set to the default value (t). AFAIK, everything notmuch in my emacs is default except for the values in my config. Doom emacs (https://github.com/doomemacs/doomemacs/blob/master/modules/email/notmuch/config.el) sets some variables; but I have overwritten the pertinent ones (namely, notmuch-fcc-dirs). ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: Help with sending mail from notmuch-emacs
hgv writes: > 1. Mail gets sent but doesn't save in the correct directory via FCC. I > use msmtpq as my sending program. Upon sending, I receive this > message: "message-send-mail-with-sendmail: Sending...failed to mail > for [ -oi -f h...@fastmail.com -t ] : send was successful;" The mail is > sent but is not saved in the fcc dir nor entered into the notmuch > database. I have enabled emacs debugger (on entry with different > functions related to sending) and stepped through the process but > didn't see any pertinent information in the messages. My fcc line > reads `(setq notmuch-fcc-dirs "fastmail/Sent +sent +inbox +sent-new")` > (fuller notmuch-emacs config below). Any guidance on fixing or further > troubleshooting (what should I look for on debugger) is appreciated. What is your setting for the variable notmuch-maildir-use-notmuch-insert It should be t (the default) for that style of notmuch-fcc-dirs setting. ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Help with sending mail from notmuch-emacs
Dear Notmuch list, I have used notmuch (very happily) for a number of years with alot as my client. I'm now trying out the emacs client (with doom emacs), which is very cool so far. But I am struggling with two particular points around sending emails and cannot solve them on my own. I am also new to emacs, so please forgive my struggles that stem from being a newbie there. 1. Mail gets sent but doesn't save in the correct directory via FCC. I use msmtpq as my sending program. Upon sending, I receive this message: "message-send-mail-with-sendmail: Sending...failed to mail for [ -oi -f h...@fastmail.com -t ] : send was successful;" The mail is sent but is not saved in the fcc dir nor entered into the notmuch database. I have enabled emacs debugger (on entry with different functions related to sending) and stepped through the process but didn't see any pertinent information in the messages. My fcc line reads `(setq notmuch-fcc-dirs "fastmail/Sent +sent +inbox +sent-new")` (fuller notmuch-emacs config below). Any guidance on fixing or further troubleshooting (what should I look for on debugger) is appreciated. 2. I have my emacs setup to prefer utf-8 encoding in basically all situations. Emails I send with emacs seem to be correctly encoded. But the Content-Type header is set only to "text/plain" rather than "text/plain; charset=utf-8" (as it is in alot and as it should be). Further, there is no Content-Transfer-Encoding header set. Based on my reading of the emacs message mode docs, Content-Transfer-Encoding should be set on the fly depending on the Content-Type and other factors (to either "quoted-printable" or "base64" for "text/plain"). Perhaps I should not worry about these headers; but it seems like they affect whether mail gets delivered at certain providers and certainly how it displays. Any advice on getting both Content-Type and Content-Transfer-Encoding to set correctly? (Without my settings that prefer utf-8, my emails are ascii encoded and the Content-Type is set as "text/plain; charset=us-ascii" but still no Content-Transfer-Encoding.) I'm on macos 10.15.7, with notmuch .35 (via homebrew), and GNU emacs 28.1 (from https://github.com/d12frosted/homebrew-emacs-plus via homebrew). Thank you for your help and for the tremendous software! hgv ``` ;;; $DOOMDIR/config.el -*- lexical-binding: t; -*- ---snip--- ;; mainly force utf-8 (prefer-coding-system 'utf-8) (set-default-coding-systems 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (set-file-name-coding-system 'utf-8) (set-clipboard-coding-system 'utf-8) (set-buffer-file-coding-system 'utf-8) ---snip--- ;; gnus-alias (autoload 'gnus-alias-determine-identity "gnus-alias" "" t) (add-hook 'message-setup-hook 'gnus-alias-determine-identity) (setq gnus-alias-identity-alist '(("fastmail" ---snip--- )) ;; Use "fastmail" identity by default (setq gnus-alias-default-identity "fastmail") ;; Define rules to match work identity (setq gnus-alias-identity-rules ---snip--- )) ;; sorting out regex and replying (setq gnus-alias-override-user-mail-address t) (setq gnus-alias-unknown-identity-rule 'default) ;; auto save (setq message-auto-save-directory "~/.config/emacs/.local/cache/notmuch/unsaved-drafts") ;; supposedly outdated ;; now sourced from language (setq message-default-charset "utf-8") (setq mm-coding-system-priorities '(utf-8)) ;; notmuch (after! notmuch (setq +notmuch-sync-backend "notmuch new" +notmuch-delete-tags '("+ztrash") +notmuch-spam-tags '("+spam") notmuch-draft-tags '("+draft" "-new") notmuch-archive-tags '("-inbox" "-unread")) (setq notmuch-mua-compose-in 'new-window) (setq notmuch-mua-user-agent-function 'notmuch-mua-user-agent-notmuch) (setq message-kill-buffer-on-exit t) (setq message-send-mail-function 'message-send-mail-with-sendmail) (setq sendmail-program "msmtpq" mail-specify-envelope-from t message-sendmail-f-is-evil nil mail-envelope-from 'header message-sendmail-envelope-from 'header) (setq notmuch-address-save-filename "~/.config/emacs/.local/notmuch/address-cache") (setq notmuch-draft-folder "fastmail/Drafts") ;; overwritten from ~/.config/emacs/.local/straight/repos/notmuch/emacs/notmuch-draft.el (defun notmuch-draft--mark-deleted () (when notmuch-draft-id (notmuch-tag notmuch-draft-id '("+ztrash" (setq notmuch-fcc-dirs "fastmail/Sent +sent +inbox +sent-new") (setq notmuch-identities ---snip--- (setq notmuch-mua-send-hook '(notmuch-mua-attachment-check)) (setq notmuch-show-empty-saved-searches nil) (setq notmuch-multipart/alternative-discouraged '("text/plain" "text/html")) (setq notmuch-saved-searches ---snip--- ))) ``` ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [BUG] Bad quote in help
On Wed, Feb 16 2022, Rudolf Adamkovič wrote: > Repro steps: > > 1. C-h v > 2. notmuch-search-result-format > 3. RET > > See: > > For example: > (setq notmuch-search-result-format > ’(("authors" . "%-40s") > ("subject" . "%s"))) > > The quote ’ needs changed to ', otherwise the example does not work. The code in question in notmuch.el is: (setq notmuch-search-result-format '((\"authors\" . \"%-40s\") (\"subject\" . \"%s\"))) In this particular case it is unfortunate emacs modifies the output. Tried to chage that to \'((\"autho... did not help (also renamed the defcustom to make a new definition so that the content would be evaluated when doing c-x c-e in buffer...) In rstdoc.el we have (text-quoting-style 'grave) to not do such docstring modifications for display, but that is not applicable in this context... Tomi > > Rudy > -- > "Thinking is a momentary dismissal of irrelevancies." > -- Richard Buckminster Fuller, 1969 > > Rudolf Adamkovič [he/him] > Studenohorská 25 > 84103 Bratislava > Slovakia ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: help with :search-type 'tree' in Emacs/notmuch config?
Hi David and David, Thanks for your help with this! I took everything out of my config and started from scratch via customize. I believe I found my own configuration error this way - two of the saved searches may have had the same shortcut key of “I”. When I made them unique, naturally I was able to get both results, not just the first choice that didn’t have tree set. Oof. Thank you for the great program and for helping me blunder thru this debugging. On Fri, Jan 8, 2021 at 08:58 David Bremner wrote: > Jonathan Wilner writes: > > > Great idea. I tried it and got the same result - not opening in Tree > mode. :-( > > > > Another possibly obvious point, are you sure it's not tree mode? It only > opens the thread window by default (so no split pane until you hit > return on a message)a. It does display a tree view of the threads, but > that might not be totally obvious if e.g. most threads have a single > message. The buffer name should start with "*notmuch-tree-" though, if > it really is in tree mode. > > d > ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: help with :search-type 'tree' in Emacs/notmuch config?
Jonathan Wilner writes: > Great idea. I tried it and got the same result - not opening in Tree mode. :-( > Another possibly obvious point, are you sure it's not tree mode? It only opens the thread window by default (so no split pane until you hit return on a message)a. It does display a tree view of the threads, but that might not be totally obvious if e.g. most threads have a single message. The buffer name should start with "*notmuch-tree-" though, if it really is in tree mode. d ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: help with :search-type 'tree' in Emacs/notmuch config?
On Friday, 2021-01-08 at 07:44:45 -08, Jonathan Wilner wrote: > Great idea. I tried it and got the same result - not opening in Tree mode. :-( Please show us the (complete) value of your notmuch-saved-searches variable. You can get it by going to the *scratch* buffer and typing notmuch-saved-searches, followed by control-j (sorry if that's obvious, just wanted to be sure). dme. -- Oliver darling, call Mister Haney, I think our speakers are blown. ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: help with :search-type 'tree' in Emacs/notmuch config?
Great idea. I tried it and got the same result - not opening in Tree mode. :-( David Bremner writes: Jonathan Wilner writes: Hi David, I tried that as well when it hit the problem. I got the same result. :-( Did you try using M-x customize-variable to make the change? d ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: help with :search-type 'tree' in Emacs/notmuch config?
Jonathan Wilner writes: > Hi David, > > I tried that as well when it hit the problem. I got the same result. :-( > Did you try using M-x customize-variable to make the change? d ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: help with :search-type 'tree' in Emacs/notmuch config?
Hi David, I tried that as well when it hit the problem. I got the same result. :-( On Thu, Jan 7, 2021 at 11:36 David Bremner wrote: > jonat...@teamwilner.com writes: > > > Hi all, > > > > Sorry in advance for what's likely a basic configuration question on the > Emacs/notmuch side of things. I'd like to have a shortcut that goes into > notmuch-tree from notmuch-hello. Following the docs & other configurations, > it appears that :search-type 'tree' should work. An example from my > configuration is below: > > > > (:name "inbox tree" :query "tag:inbox date:2021" :search-type 'tree > :key "i") > > > > This also appears to register properly with Emacs. Checking via the > customization settings, the option of "tree" is properly ticked. However, > no matter what I do, the results always open in the standard configuration, > not the tree. > > > > I'm guessing this is a simple error of my own doing. Any help would be > greatly appreciated. > > Try without the ' in front of tree. At least if I use > customize-variable, I get :search-type tree, no quote. > > d > ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: help with :search-type 'tree' in Emacs/notmuch config?
jonat...@teamwilner.com writes: > Hi all, > > Sorry in advance for what's likely a basic configuration question on the > Emacs/notmuch side of things. I'd like to have a shortcut that goes into > notmuch-tree from notmuch-hello. Following the docs & other configurations, > it appears that :search-type 'tree' should work. An example from my > configuration is below: > > (:name "inbox tree" :query "tag:inbox date:2021" :search-type 'tree :key "i") > > This also appears to register properly with Emacs. Checking via the > customization settings, the option of "tree" is properly ticked. However, no > matter what I do, the results always open in the standard configuration, not > the tree. > > I'm guessing this is a simple error of my own doing. Any help would be > greatly appreciated. Try without the ' in front of tree. At least if I use customize-variable, I get :search-type tree, no quote. d ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: Looking for help re: inbox/thread/tree slowdown; misconfiguration?
Thanks, David! I'm giving this a try now. So far, so good! Best, Jonathan David Bremner writes: David Bremner writes: jonat...@teamwilner.com writes: I've got about 52K items with the tag "inbox". Should be "notmuch" right? :-) Here's the problem - if I want to view that in tree view, it can take multiple minutes for notmuch to return a result. In general there should be some results right away, with the rest of the buffer being filled asynchronously. Unfortunately notmuch-emacs only handles the one asynchronous query, so if there is already a long running query, you will indeed have to wait for the whole tree/list of headers to be read into emacs. I think I see what is probably going on for you. You are probably first opening the query with notmuch-search-mode, then switching to notmuch-tree mode, This leads to the original query running in the background, blocking your second (tree-mode) query from running. I suggest trying M-x notmuch-tree directly (say in a fresh Emacs instance) and see if it has the same delay. If it works better, you can set the default mode to open a saved search by customizing notmuch-saved-searches. It's been a while since I looked at the async code, maybe David E or Mark have some ideas about how hard it would be to improve the current behaviour of one async query blocking all others. d ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: Looking for help re: inbox/thread/tree slowdown; misconfiguration?
David Bremner writes: > jonat...@teamwilner.com writes: > >> I've got about 52K items with the tag "inbox". Should be "notmuch" >> right? :-) Here's the problem - if I want to view that in tree view, >> it can take multiple minutes for notmuch to return a result. > > In general there should be some results right away, with the rest of the > buffer being filled asynchronously. Unfortunately notmuch-emacs only > handles the one asynchronous query, so if there is already a long > running query, you will indeed have to wait for the whole tree/list of > headers to be read into emacs. > I think I see what is probably going on for you. You are probably first opening the query with notmuch-search-mode, then switching to notmuch-tree mode, This leads to the original query running in the background, blocking your second (tree-mode) query from running. I suggest trying M-x notmuch-tree directly (say in a fresh Emacs instance) and see if it has the same delay. If it works better, you can set the default mode to open a saved search by customizing notmuch-saved-searches. It's been a while since I looked at the async code, maybe David E or Mark have some ideas about how hard it would be to improve the current behaviour of one async query blocking all others. d ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: Looking for help re: inbox/thread/tree slowdown; misconfiguration?
jonat...@teamwilner.com writes: > I've got about 52K items with the tag "inbox". Should be "notmuch" > right? :-) Here's the problem - if I want to view that in tree view, > it can take multiple minutes for notmuch to return a result. In general there should be some results right away, with the rest of the buffer being filled asynchronously. Unfortunately notmuch-emacs only handles the one asynchronous query, so if there is already a long running query, you will indeed have to wait for the whole tree/list of headers to be read into emacs. > More critically, if I choose an item in the inbox that has even two > messages in a thread-selecting it and wanting to see it in a tree > appears to wind up with all messages getting re-indexed. I can't see > the two messages for a good 2-4 minutes, unless I kill the notmuch > process that's running in the background. The process indicates that > notmuch is running through the whole inbox. Hmm. I can't completely follow this. Are you talking about using Z from notmuch-show-mode, or something else? ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Looking for help re: inbox/thread/tree slowdown; misconfiguration?
Hi all, I'm recently returning to notmuch after a few years of using mu4e. I'm thrilled to be back - the tag based workflow is fantastic! However, I'm hitting a problem with tree-mode/threading that I can't seem to solve. I am hoping the folks on this list might have some suggestions. I've got about 52K items with the tag "inbox". Should be "notmuch" right? :-) Here's the problem - if I want to view that in tree view, it can take multiple minutes for notmuch to return a result. More critically, if I choose an item in the inbox that has even two messages in a thread-selecting it and wanting to see it in a tree appears to wind up with all messages getting re-indexed. I can't see the two messages for a good 2-4 minutes, unless I kill the notmuch process that's running in the background. The process indicates that notmuch is running through the whole inbox. I accept that I am not doing a great job describing the bug (if it is one!) - but I am hoping someone on this list can minimally point me in right area to either provide more debug info or how to optimize my config. Thanks! ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: test/T010-help-test.sh fails after ./configure --without-docs
On Sun 2019-04-21 09:49:50 -0300, David Bremner wrote: > Daniel Kahn Gillmor writes: > >> On a system where man and notmuch are both already installed, i tried to >> ./configure --without-docs to avoid the delays during development >> associated with id:87r29wwgq2@fifthhorseman.net. >> >> The configuration succeeds, but now these tests fail: >> >> 0 dkg@alice:~/src/notmuch/notmuch$ make check >> NOTMUCH_TESTS=T010-help-test.sh V=1 >> Missing sphinx or makeinfo, not building info pages >> INFO: using 2 minute timeout for tests >> >> T010-help-test: Testing online help >> PASS notmuch --help >> PASS notmuch help >> PASS notmuch --version >> FAIL notmuch --help tag (man pages not available) >> test_must_fail notmuch --help tag >/dev/null >> FAIL notmuch help tag (man pages not available) >> test_must_fail notmuch help tag >/dev/null > > Are you sure you ran "make clean" after reconfiguring? I had the same > result as you because doc/_build/man was lying around from a previous > build. Thanks, Bremner! Turns out that was exactly what i was running into. "make clean" and then rebuilding does indeed solve the problem for me. this was a bug in my workflow, not a bug in notmuch itself. --dkg signature.asc Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: test/T010-help-test.sh fails after ./configure --without-docs
Daniel Kahn Gillmor writes: > On a system where man and notmuch are both already installed, i tried to > ./configure --without-docs to avoid the delays during development > associated with id:87r29wwgq2@fifthhorseman.net. > > The configuration succeeds, but now these tests fail: > > 0 dkg@alice:~/src/notmuch/notmuch$ make check NOTMUCH_TESTS=T010-help-test.sh > V=1 > Missing sphinx or makeinfo, not building info pages > INFO: using 2 minute timeout for tests > > T010-help-test: Testing online help > PASS notmuch --help > PASS notmuch help > PASS notmuch --version > FAIL notmuch --help tag (man pages not available) > test_must_fail notmuch --help tag >/dev/null > FAIL notmuch help tag (man pages not available) > test_must_fail notmuch help tag >/dev/null > Are you sure you ran "make clean" after reconfiguring? I had the same result as you because doc/_build/man was lying around from a previous build. d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
test/T010-help-test.sh fails after ./configure --without-docs
On a system where man and notmuch are both already installed, i tried to ./configure --without-docs to avoid the delays during development associated with id:87r29wwgq2@fifthhorseman.net. The configuration succeeds, but now these tests fail: 0 dkg@alice:~/src/notmuch/notmuch$ make check NOTMUCH_TESTS=T010-help-test.sh V=1 Missing sphinx or makeinfo, not building info pages INFO: using 2 minute timeout for tests T010-help-test: Testing online help PASS notmuch --help PASS notmuch help PASS notmuch --version FAIL notmuch --help tag (man pages not available) test_must_fail notmuch --help tag >/dev/null FAIL notmuch help tag (man pages not available) test_must_fail notmuch help tag >/dev/null Notmuch test suite complete. 3/5 tests passed. 2 tests failed. make: *** [test/Makefile.local:75: test] Error 1 [1]+ Donegitk --all 2 dkg@alice:~/src/notmuch/notmuch$ It seems likely that they're "failing to fail" because the main system i'm building on has both notmuch and man installed -- so maybe the locally-built notmuch is successfully opening the manual pages from the system instead of the development manpages. I did a bit of digging to try to understand the issue, and noticed that the comments about test_must_fail in test/test-lib.sh seem out of date (they assume two arguments instead of one, and they refer to their earlier provenance in git, rather than notmuch). But i think the problem isn't with test_must_fail itself, even though the function's documentation appears to be out of date. --dkg signature.asc Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] cli/help, completion: added pointers to notmuch-properties(7)
Daniel Kahn Gillmor writes: > --- > completion/notmuch-completion.bash | 2 +- > notmuch.c | 2 ++ pushed to master d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v2] cli/help: give a hint about notmuch-emacs-mua
Daniel Kahn Gillmor writes: > "notmuch help" doesn't mention "notmuch-emacs-mua" even though we > support it through the try_external_command() mechanism. > > In addition, "notmuch help emacs-mua" doesn't work, even though we > ship the appropriate manpage. > > This changeset fixes both of these problems. pushed, d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH v2] cli/help: give a hint about notmuch-emacs-mua
On Mon, Dec 04 2017, Daniel Kahn Gillmor wrote: > "notmuch help" doesn't mention "notmuch-emacs-mua" even though we > support it through the try_external_command() mechanism. > > In addition, "notmuch help emacs-mua" doesn't work, even though we > ship the appropriate manpage. > > This changeset fixes both of these problems. +1 Tomi > --- > configure | 1 + > notmuch.c | 7 ++- > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/configure b/configure > index bd034f91..f1974520 100755 > --- a/configure > +++ b/configure > @@ -1185,6 +1185,7 @@ COMMON_CONFIGURE_CFLAGS = \\ > \$(GMIME_CFLAGS) \$(TALLOC_CFLAGS) \$(ZLIB_CFLAGS) \\ > -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \$(VALGRIND_CFLAGS) \\ > -DHAVE_GETLINE=\$(HAVE_GETLINE) \\ > + -DWITH_EMACS=\$(WITH_EMACS) \\ > -DHAVE_CANONICALIZE_FILE_NAME=\$(HAVE_CANONICALIZE_FILE_NAME) \\ > -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\ > -DHAVE_STRSEP=\$(HAVE_STRSEP) \\ > diff --git a/notmuch.c b/notmuch.c > index d5bf7902..2d193aa8 100644 > --- a/notmuch.c > +++ b/notmuch.c > @@ -172,6 +172,10 @@ static command_t commands[] = { >"Re-index all messages matching the search terms." }, > { "config", notmuch_config_command, NOTMUCH_CONFIG_OPEN, >"Get or set settings in the notmuch configuration file." }, > +#if WITH_EMACS > +{ "emacs-mua", NULL, 0, > + "send mail with notmuch and emacs." }, > +#endif > { "help", notmuch_help_command, NOTMUCH_CONFIG_CREATE, /* create but > don't save config */ >"This message, or more detailed help for the named command." } > }; > @@ -487,7 +491,8 @@ main (int argc, char *argv[]) > notmuch_process_shared_options (command_name); > > command = find_command (command_name); > -if (!command) { > +/* if command->function is NULL, try external command */ > +if (!command || !command->function) { > /* This won't return if the external command is found. */ > if (try_external_command(argv + opt_index)) > fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch > help\")\n", > -- > 2.15.0 > > ___ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] cli/help: give a hint about notmuch-emacs-mua
On Mon 2017-12-04 10:44:40 -0500, Daniel Kahn Gillmor wrote: > But maybe you'll find my revised version > (id:20171204154333.27505-1-...@fifthhorseman.net) mitigates the error > you're pointing out? sorry, that should be id:20171204184310.17125-1-...@fifthhorseman.net -- the previous message-id was never sent. --dkg ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2] cli/help: give a hint about notmuch-emacs-mua
"notmuch help" doesn't mention "notmuch-emacs-mua" even though we support it through the try_external_command() mechanism. In addition, "notmuch help emacs-mua" doesn't work, even though we ship the appropriate manpage. This changeset fixes both of these problems. --- configure | 1 + notmuch.c | 7 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/configure b/configure index bd034f91..f1974520 100755 --- a/configure +++ b/configure @@ -1185,6 +1185,7 @@ COMMON_CONFIGURE_CFLAGS = \\ \$(GMIME_CFLAGS) \$(TALLOC_CFLAGS) \$(ZLIB_CFLAGS) \\ -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \$(VALGRIND_CFLAGS) \\ -DHAVE_GETLINE=\$(HAVE_GETLINE) \\ + -DWITH_EMACS=\$(WITH_EMACS) \\ -DHAVE_CANONICALIZE_FILE_NAME=\$(HAVE_CANONICALIZE_FILE_NAME) \\ -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\ -DHAVE_STRSEP=\$(HAVE_STRSEP) \\ diff --git a/notmuch.c b/notmuch.c index d5bf7902..2d193aa8 100644 --- a/notmuch.c +++ b/notmuch.c @@ -172,6 +172,10 @@ static command_t commands[] = { "Re-index all messages matching the search terms." }, { "config", notmuch_config_command, NOTMUCH_CONFIG_OPEN, "Get or set settings in the notmuch configuration file." }, +#if WITH_EMACS +{ "emacs-mua", NULL, 0, + "send mail with notmuch and emacs." }, +#endif { "help", notmuch_help_command, NOTMUCH_CONFIG_CREATE, /* create but don't save config */ "This message, or more detailed help for the named command." } }; @@ -487,7 +491,8 @@ main (int argc, char *argv[]) notmuch_process_shared_options (command_name); command = find_command (command_name); -if (!command) { +/* if command->function is NULL, try external command */ +if (!command || !command->function) { /* This won't return if the external command is found. */ if (try_external_command(argv + opt_index)) fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n", -- 2.15.0 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] cli/help: give a hint about notmuch-emacs-mua
On Sun 2017-12-03 15:26:32 +0200, Tomi Ollila wrote: > My thought was that even though user may compile notmuch without emacs > support (and notmuch-emacs-mua not installed) we would be hinting > `notmuch emacs-mua` command to exist. Currently, if the user *does* compile with emacs support, and installs it, we are hinting that "notmuch emacs-mua" *doesn't* exist. Given that "notmuch emacs-mua" does exist somewhere (even if it's not in the local installation), i prefer the error in the direction of inclusion. But maybe you'll find my revised version (id:20171204154333.27505-1-...@fifthhorseman.net) mitigates the error you're pointing out? --dkg ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] cli/help: give a hint about notmuch-emacs-mua
On Thu, Nov 30 2017, Daniel Kahn Gillmor wrote: > On Thu 2017-11-30 11:08:05 +0200, Tomi Ollila wrote: >> On Thu, Nov 30 2017, Daniel Kahn Gillmor wrote: >> >>> On Thu 2017-10-26 18:27:51 -0400, Daniel Kahn Gillmor wrote: >>>> "notmuch help" doesn't mention "notmuch-emacs-mua" even though we >>>> support it through the try_external_command() mechanism. >>>> >>>> In addition, "notmuch help emacs-mua" doesn't work, even though we >>>> ship the appropriate manpage. >>>> >>>> This changeset fixes both of these problems. >>> >>> Ping! i don't think this patch is complex or objectionable. Can it be >>> merged? >> >> it may (*) look like we don't have #if WITH_EMACS (**) cpp macros defined ??? >> >> Tomi >> >> (*) did not check... >> >> (**) this is emacs-specific stull, less generic that other hints (if that >> matters) ... >> >> Sorry to cause confusion... > > confusion is right! i don't understand what you're saying, sorry. are > you suggesting a different change somehow? Want to propose a different > patch? My thought was that even though user may compile notmuch without emacs support (and notmuch-emacs-mua not installed) we would be hinting `notmuch emacs-mua` command to exist. Tomi > >--dkg ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] cli/help: give a hint about notmuch-emacs-mua
On Thu 2017-11-30 11:08:05 +0200, Tomi Ollila wrote: > On Thu, Nov 30 2017, Daniel Kahn Gillmor wrote: > >> On Thu 2017-10-26 18:27:51 -0400, Daniel Kahn Gillmor wrote: >>> "notmuch help" doesn't mention "notmuch-emacs-mua" even though we >>> support it through the try_external_command() mechanism. >>> >>> In addition, "notmuch help emacs-mua" doesn't work, even though we >>> ship the appropriate manpage. >>> >>> This changeset fixes both of these problems. >> >> Ping! i don't think this patch is complex or objectionable. Can it be >> merged? > > it may (*) look like we don't have #if WITH_EMACS (**) cpp macros defined ??? > > Tomi > > (*) did not check... > > (**) this is emacs-specific stull, less generic that other hints (if that > matters) ... > > Sorry to cause confusion... confusion is right! i don't understand what you're saying, sorry. are you suggesting a different change somehow? Want to propose a different patch? --dkg ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] cli/help: give a hint about notmuch-emacs-mua
On Thu, Nov 30 2017, Daniel Kahn Gillmor wrote: > On Thu 2017-10-26 18:27:51 -0400, Daniel Kahn Gillmor wrote: >> "notmuch help" doesn't mention "notmuch-emacs-mua" even though we >> support it through the try_external_command() mechanism. >> >> In addition, "notmuch help emacs-mua" doesn't work, even though we >> ship the appropriate manpage. >> >> This changeset fixes both of these problems. > > Ping! i don't think this patch is complex or objectionable. Can it be > merged? it may (*) look like we don't have #if WITH_EMACS (**) cpp macros defined ??? Tomi (*) did not check... (**) this is emacs-specific stull, less generic that other hints (if that matters) ... Sorry to cause confusion... > > --dkg ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] cli/help: give a hint about notmuch-emacs-mua
On Thu 2017-10-26 18:27:51 -0400, Daniel Kahn Gillmor wrote: > "notmuch help" doesn't mention "notmuch-emacs-mua" even though we > support it through the try_external_command() mechanism. > > In addition, "notmuch help emacs-mua" doesn't work, even though we > ship the appropriate manpage. > > This changeset fixes both of these problems. Ping! i don't think this patch is complex or objectionable. Can it be merged? --dkg ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] cli/help, completion: added pointers to notmuch-properties(7)
On Thu 2017-10-26 18:28:12 -0400, Daniel Kahn Gillmor wrote: > --- > completion/notmuch-completion.bash | 2 +- > notmuch.c | 2 ++ > 2 files changed, 3 insertions(+), 1 deletion(-) Ping on this patch as well. I think this should be safe and simple to merge. --dkg ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] cli/help: give a hint about notmuch-emacs-mua
"notmuch help" doesn't mention "notmuch-emacs-mua" even though we support it through the try_external_command() mechanism. In addition, "notmuch help emacs-mua" doesn't work, even though we ship the appropriate manpage. This changeset fixes both of these problems. --- notmuch.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/notmuch.c b/notmuch.c index efbe32ff..8eab561b 100644 --- a/notmuch.c +++ b/notmuch.c @@ -172,6 +172,8 @@ static command_t commands[] = { "Re-index all messages matching the search terms." }, { "config", notmuch_config_command, NOTMUCH_CONFIG_OPEN, "Get or set settings in the notmuch configuration file." }, +{ "emacs-mua", NULL, 0, + "send mail with notmuch and emacs." }, { "help", notmuch_help_command, NOTMUCH_CONFIG_CREATE, /* create but don't save config */ "This message, or more detailed help for the named command." } }; @@ -487,7 +489,8 @@ main (int argc, char *argv[]) notmuch_process_shared_options (command_name); command = find_command (command_name); -if (!command) { +/* if command->function is NULL, try external command */ +if (!command || !command->function) { /* This won't return if the external command is found. */ if (try_external_command(argv + opt_index)) fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n", -- 2.14.2 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] cli/help,completion: added pointers to notmuch-properties(7)
--- completion/notmuch-completion.bash | 2 +- notmuch.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash index a0c3ac17..895fc554 100644 --- a/completion/notmuch-completion.bash +++ b/completion/notmuch-completion.bash @@ -611,7 +611,7 @@ _notmuch() esac elif [ "${arg}" = "help" ]; then # handle help command specially due to _notmuch_commands usage - local help_topics="$_notmuch_commands hooks search-terms" + local help_topics="$_notmuch_commands hooks search-terms properties" COMPREPLY=( $(compgen -W "${help_topics}" -- ${cur}) ) else # complete using _notmuch_subcommand if one exist diff --git a/notmuch.c b/notmuch.c index 2f43ad28..efbe32ff 100644 --- a/notmuch.c +++ b/notmuch.c @@ -186,6 +186,8 @@ static help_topic_t help_topics[] = { "Common search term syntax." }, { "hooks", "Hooks that will be run before or after certain commands." }, +{ "properties", + "Message property conventions and documentation." }, }; static command_t * -- 2.14.2 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 1/2] cli/config: don't try to open config file for 'notmuch help'
Jani Nikula writes: > The help command does not really need to try to open the config > file. So don't. series pushed to master ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 1/2] cli/config: don't try to open config file for 'notmuch help'
On Sun, Feb 26 2017, Jani Nikula wrote: > The help command does not really need to try to open the config > file. So don't. > > --- This series looks good, tests pass, repost of my patch seems to be unmodified (the power of running 2 emacses w/ notmuch rules!) In addition to `make test` I ran the following 3 commands: 104 HOME=/tmp/xyxz ./notmuch help 105 HOME=/tmp/xyxz ./notmuch nre 106 HOME=/tmp/xyxz ./notmuch new 107 HOME=/tmp/xyxz ./notmuch setup and these worked as expected. Tomi > > This will allow better error reporting such as > id:1483570332-11820-1-git-send-email-tomi.oll...@iki.fi while still > ensuring 'notmuch help' succeeds in the absence of config files. > --- > notmuch-client.h | 7 ++- > notmuch-config.c | 12 > notmuch.c| 34 +- > 3 files changed, 31 insertions(+), 22 deletions(-) > > diff --git a/notmuch-client.h b/notmuch-client.h > index 21b087980a17..1099122426af 100644 > --- a/notmuch-client.h > +++ b/notmuch-client.h > @@ -263,10 +263,15 @@ json_quote_str (const void *ctx, const char *str); > > /* notmuch-config.c */ > > +typedef enum { > +NOTMUCH_CONFIG_OPEN = 1 << 0, > +NOTMUCH_CONFIG_CREATE = 1 << 1, > +} notmuch_config_mode_t; > + > notmuch_config_t * > notmuch_config_open (void *ctx, >const char *filename, > - notmuch_bool_t create_new); > + notmuch_config_mode_t config_mode); > > void > notmuch_config_close (notmuch_config_t *config); > diff --git a/notmuch-config.c b/notmuch-config.c > index b202bb1e2299..959410cce7b8 100644 > --- a/notmuch-config.c > +++ b/notmuch-config.c > @@ -322,7 +322,7 @@ out: > notmuch_config_t * > notmuch_config_open (void *ctx, >const char *filename, > - notmuch_bool_t create_new) > + notmuch_config_mode_t config_mode) > { > GError *error = NULL; > size_t tmp; > @@ -356,9 +356,13 @@ notmuch_config_open (void *ctx, > > config->key_file = g_key_file_new (); > > -if (! get_config_from_file (config, create_new)) { > - talloc_free (config); > - return NULL; > +if (config_mode & NOTMUCH_CONFIG_OPEN) { > + notmuch_bool_t create_new = (config_mode & NOTMUCH_CONFIG_CREATE) != 0; > + > + if (! get_config_from_file (config, create_new)) { > + talloc_free (config); > + return NULL; > + } > } > > /* Whenever we know of configuration sections that don't appear in > diff --git a/notmuch.c b/notmuch.c > index b9c320329dd5..8e332ce64410 100644 > --- a/notmuch.c > +++ b/notmuch.c > @@ -33,7 +33,7 @@ typedef int (*command_function_t) (notmuch_config_t > *config, int argc, char *arg > typedef struct command { > const char *name; > command_function_t function; > -notmuch_bool_t create_config; > +notmuch_config_mode_t config_mode; > const char *summary; > } command_t; > > @@ -97,35 +97,35 @@ int notmuch_minimal_options (const char *subcommand_name, > } > > static command_t commands[] = { > -{ NULL, notmuch_command, TRUE, > +{ NULL, notmuch_command, NOTMUCH_CONFIG_OPEN | NOTMUCH_CONFIG_CREATE, >"Notmuch main command." }, > -{ "setup", notmuch_setup_command, TRUE, > +{ "setup", notmuch_setup_command, NOTMUCH_CONFIG_OPEN | > NOTMUCH_CONFIG_CREATE, >"Interactively set up notmuch for first use." }, > -{ "new", notmuch_new_command, FALSE, > +{ "new", notmuch_new_command, NOTMUCH_CONFIG_OPEN, >"Find and import new messages to the notmuch database." }, > -{ "insert", notmuch_insert_command, FALSE, > +{ "insert", notmuch_insert_command, NOTMUCH_CONFIG_OPEN, >"Add a new message into the maildir and notmuch database." }, > -{ "search", notmuch_search_command, FALSE, > +{ "search", notmuch_search_command, NOTMUCH_CONFIG_OPEN, >"Search for messages matching the given search terms." }, > -{ "address", notmuch_address_command, FALSE, > +{ "address", notmuch_address_command, NOTMUCH_CONFIG_OPEN, >"Get addresses from messages matching the given search terms." }, > -{ "show", notmuch_show_command, FALSE, > +{ "show", notmuch_show_command, NOTMUCH_CONFIG_OPEN, >"Show all messages matching the search terms." }, > -{ "count", notmuch_count_command, FALSE, > +{ "count", notmuch_count_command,
Re: [PATCH 1/2] cli/config: don't try to open config file for 'notmuch help'
On Sun, Feb 26 2017, Jani Nikula wrote: > The help command does not really need to try to open the config > file. So don't. > > --- I've forgotten this ... added notmuch::0.24 to this series and will check carefully and test tomorrow... Tomi > > This will allow better error reporting such as > id:1483570332-11820-1-git-send-email-tomi.oll...@iki.fi while still > ensuring 'notmuch help' succeeds in the absence of config files. > --- > notmuch-client.h | 7 ++- > notmuch-config.c | 12 > notmuch.c| 34 +- > 3 files changed, 31 insertions(+), 22 deletions(-) > > diff --git a/notmuch-client.h b/notmuch-client.h > index 21b087980a17..1099122426af 100644 > --- a/notmuch-client.h > +++ b/notmuch-client.h > @@ -263,10 +263,15 @@ json_quote_str (const void *ctx, const char *str); > > /* notmuch-config.c */ > > +typedef enum { > +NOTMUCH_CONFIG_OPEN = 1 << 0, > +NOTMUCH_CONFIG_CREATE = 1 << 1, > +} notmuch_config_mode_t; > + > notmuch_config_t * > notmuch_config_open (void *ctx, >const char *filename, > - notmuch_bool_t create_new); > + notmuch_config_mode_t config_mode); > > void > notmuch_config_close (notmuch_config_t *config); > diff --git a/notmuch-config.c b/notmuch-config.c > index b202bb1e2299..959410cce7b8 100644 > --- a/notmuch-config.c > +++ b/notmuch-config.c > @@ -322,7 +322,7 @@ out: > notmuch_config_t * > notmuch_config_open (void *ctx, >const char *filename, > - notmuch_bool_t create_new) > + notmuch_config_mode_t config_mode) > { > GError *error = NULL; > size_t tmp; > @@ -356,9 +356,13 @@ notmuch_config_open (void *ctx, > > config->key_file = g_key_file_new (); > > -if (! get_config_from_file (config, create_new)) { > - talloc_free (config); > - return NULL; > +if (config_mode & NOTMUCH_CONFIG_OPEN) { > + notmuch_bool_t create_new = (config_mode & NOTMUCH_CONFIG_CREATE) != 0; > + > + if (! get_config_from_file (config, create_new)) { > + talloc_free (config); > + return NULL; > + } > } > > /* Whenever we know of configuration sections that don't appear in > diff --git a/notmuch.c b/notmuch.c > index b9c320329dd5..8e332ce64410 100644 > --- a/notmuch.c > +++ b/notmuch.c > @@ -33,7 +33,7 @@ typedef int (*command_function_t) (notmuch_config_t > *config, int argc, char *arg > typedef struct command { > const char *name; > command_function_t function; > -notmuch_bool_t create_config; > +notmuch_config_mode_t config_mode; > const char *summary; > } command_t; > > @@ -97,35 +97,35 @@ int notmuch_minimal_options (const char *subcommand_name, > } > > static command_t commands[] = { > -{ NULL, notmuch_command, TRUE, > +{ NULL, notmuch_command, NOTMUCH_CONFIG_OPEN | NOTMUCH_CONFIG_CREATE, >"Notmuch main command." }, > -{ "setup", notmuch_setup_command, TRUE, > +{ "setup", notmuch_setup_command, NOTMUCH_CONFIG_OPEN | > NOTMUCH_CONFIG_CREATE, >"Interactively set up notmuch for first use." }, > -{ "new", notmuch_new_command, FALSE, > +{ "new", notmuch_new_command, NOTMUCH_CONFIG_OPEN, >"Find and import new messages to the notmuch database." }, > -{ "insert", notmuch_insert_command, FALSE, > +{ "insert", notmuch_insert_command, NOTMUCH_CONFIG_OPEN, >"Add a new message into the maildir and notmuch database." }, > -{ "search", notmuch_search_command, FALSE, > +{ "search", notmuch_search_command, NOTMUCH_CONFIG_OPEN, >"Search for messages matching the given search terms." }, > -{ "address", notmuch_address_command, FALSE, > +{ "address", notmuch_address_command, NOTMUCH_CONFIG_OPEN, >"Get addresses from messages matching the given search terms." }, > -{ "show", notmuch_show_command, FALSE, > +{ "show", notmuch_show_command, NOTMUCH_CONFIG_OPEN, >"Show all messages matching the search terms." }, > -{ "count", notmuch_count_command, FALSE, > +{ "count", notmuch_count_command, NOTMUCH_CONFIG_OPEN, >"Count messages matching the search terms." }, > -{ "reply", notmuch_reply_command, FALSE, > +{ "reply", notmuch_reply_command, NOTMUCH_CONFIG_OPEN, >"Construct
[PATCH 1/2] cli/config: don't try to open config file for 'notmuch help'
The help command does not really need to try to open the config file. So don't. --- This will allow better error reporting such as id:1483570332-11820-1-git-send-email-tomi.oll...@iki.fi while still ensuring 'notmuch help' succeeds in the absence of config files. --- notmuch-client.h | 7 ++- notmuch-config.c | 12 notmuch.c| 34 +- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index 21b087980a17..1099122426af 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -263,10 +263,15 @@ json_quote_str (const void *ctx, const char *str); /* notmuch-config.c */ +typedef enum { +NOTMUCH_CONFIG_OPEN= 1 << 0, +NOTMUCH_CONFIG_CREATE = 1 << 1, +} notmuch_config_mode_t; + notmuch_config_t * notmuch_config_open (void *ctx, const char *filename, -notmuch_bool_t create_new); +notmuch_config_mode_t config_mode); void notmuch_config_close (notmuch_config_t *config); diff --git a/notmuch-config.c b/notmuch-config.c index b202bb1e2299..959410cce7b8 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -322,7 +322,7 @@ out: notmuch_config_t * notmuch_config_open (void *ctx, const char *filename, -notmuch_bool_t create_new) +notmuch_config_mode_t config_mode) { GError *error = NULL; size_t tmp; @@ -356,9 +356,13 @@ notmuch_config_open (void *ctx, config->key_file = g_key_file_new (); -if (! get_config_from_file (config, create_new)) { - talloc_free (config); - return NULL; +if (config_mode & NOTMUCH_CONFIG_OPEN) { + notmuch_bool_t create_new = (config_mode & NOTMUCH_CONFIG_CREATE) != 0; + + if (! get_config_from_file (config, create_new)) { + talloc_free (config); + return NULL; + } } /* Whenever we know of configuration sections that don't appear in diff --git a/notmuch.c b/notmuch.c index b9c320329dd5..8e332ce64410 100644 --- a/notmuch.c +++ b/notmuch.c @@ -33,7 +33,7 @@ typedef int (*command_function_t) (notmuch_config_t *config, int argc, char *arg typedef struct command { const char *name; command_function_t function; -notmuch_bool_t create_config; +notmuch_config_mode_t config_mode; const char *summary; } command_t; @@ -97,35 +97,35 @@ int notmuch_minimal_options (const char *subcommand_name, } static command_t commands[] = { -{ NULL, notmuch_command, TRUE, +{ NULL, notmuch_command, NOTMUCH_CONFIG_OPEN | NOTMUCH_CONFIG_CREATE, "Notmuch main command." }, -{ "setup", notmuch_setup_command, TRUE, +{ "setup", notmuch_setup_command, NOTMUCH_CONFIG_OPEN | NOTMUCH_CONFIG_CREATE, "Interactively set up notmuch for first use." }, -{ "new", notmuch_new_command, FALSE, +{ "new", notmuch_new_command, NOTMUCH_CONFIG_OPEN, "Find and import new messages to the notmuch database." }, -{ "insert", notmuch_insert_command, FALSE, +{ "insert", notmuch_insert_command, NOTMUCH_CONFIG_OPEN, "Add a new message into the maildir and notmuch database." }, -{ "search", notmuch_search_command, FALSE, +{ "search", notmuch_search_command, NOTMUCH_CONFIG_OPEN, "Search for messages matching the given search terms." }, -{ "address", notmuch_address_command, FALSE, +{ "address", notmuch_address_command, NOTMUCH_CONFIG_OPEN, "Get addresses from messages matching the given search terms." }, -{ "show", notmuch_show_command, FALSE, +{ "show", notmuch_show_command, NOTMUCH_CONFIG_OPEN, "Show all messages matching the search terms." }, -{ "count", notmuch_count_command, FALSE, +{ "count", notmuch_count_command, NOTMUCH_CONFIG_OPEN, "Count messages matching the search terms." }, -{ "reply", notmuch_reply_command, FALSE, +{ "reply", notmuch_reply_command, NOTMUCH_CONFIG_OPEN, "Construct a reply template for a set of messages." }, -{ "tag", notmuch_tag_command, FALSE, +{ "tag", notmuch_tag_command, NOTMUCH_CONFIG_OPEN, "Add/remove tags for all messages matching the search terms." }, -{ "dump", notmuch_dump_command, FALSE, +{ "dump", notmuch_dump_command, NOTMUCH_CONFIG_OPEN, "Create a plain-text dump of the tags for each message." }, -{ "restore", notmuch_restore_command, FALSE, +{ "restore", notmuch_restore_command, NOTMUCH_CONFIG_OPEN, "Restore the tags from the given dump file (see 'dump')." }, -{ "c
help wanted: "notmuch count property:foo" as distinct from "notmuch count property:foo=bar"
in lib/database.cc, we have this FIXME in a comment: * Mail document * - * A mail document is associated with a particular email message. It * is stored in one or more files on disk (though only one has its * content indexed) and is uniquely identified by its "id" field * (which is generally the message ID). It is indexed with the * following prefixed terms which the database uses to construct * threads, etc.: […] *Multiple terms of given prefix: * […] * property: Has a property with key=value * FIXME: if no = is present, should match on any value If we had it resolved, other improvments i'd like to make to notmuch would be significantly easier to test! I've been looking at trying to fix this FIXME by analogy with either our special nifty date: handler, or by analogy with the re: handlers introduced in id:20161114214651.19770-1-da...@tethera.net, but my xapian-fu doesn't appear to be up to the task at the moment. The date: handler appears to rely on some xapian magic to be able to handle both date:$DAY and date:$FIRSTDAY..$SECONDDAY (that is, deciding how to query based on the presence or absence of "..", as we'd want to do with "=" in the property: query) And the re: handlers allow different styles of searching a field, but they use a distinct prefix for their queries (it would be good to just keep it to "property:" in both cases). So, to be clear, searching for: * property:foo would give a hit on any message that had property "foo" set to anything. * property:foo=bar would tive a hit on any message that had property "foo" set to *exactly* "bar". * in particular, property:foo= would give a hit on anything that had property "foo" set to the empty string. Bremner was very helpful on #notmuch, pointed me to the above message, and suggested the basic outlines of a fix but his help still wasn't enough for me to figure out the right way to clear this FIXME. I'd welcome more help in resolving this. For someone who understands Xapian's query parser and how notmuch is using it, i'm imagining this wouldn't be a lot of work. I'm happy to test and review any patches. hopefully, --dkg signature.asc Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] doc/notmuch-emacs.rst: update notmuch-hello buffer help text
Tomi Ollila writes: > To look the same as commit b8a136187a3b changed it in emacs MUA code. Pushed to master. Maybe we should actually install this manual? d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] doc/notmuch-emacs.rst: update notmuch-hello buffer help text
To look the same as commit b8a136187a3b changed it in emacs MUA code. --- doc/notmuch-emacs.rst | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst index 6f2f61e..d68542d 100644 --- a/doc/notmuch-emacs.rst +++ b/doc/notmuch-emacs.rst @@ -42,11 +42,8 @@ a mouse or by positioning the cursor and pressing | | All tags: **[show]** | -| Type a search query and hit RET to view matching threads. -| Edit saved searches with the ``edit`` button. -| Hit RET or click on a saved search or tag name to view matching threads. -| ``=`` to refresh this screen. ``s`` to search messages. ``q`` to quit. -| **Customize** this page. +| Hit \`?' for context-sensitive help in any Notmuch screen. +|Customize Notmuch or this page. You can change the overall appearance of the notmuch-hello screen by customizing the variable :index:`notmuch-hello-sections`. -- 2.8.2 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs: hello: promote '?' as the universal help key
Jani Nikula writes: > Move the brief help text at the bottom of the hello screen to the > notmuch-hello-mode help, and promote '?' as the universal help key > across Notmuch. This unclutters the hello screen, and allows for a > more verbose description in the mode help. Hopefully, this change is > useful for both experienced and new users alike. > > While at it, improve the links to Notmuch and hello screen > customization. pushed. d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs: hello: promote '?' as the universal help key
On Sun, Mar 13 2016, Jani Nikula wrote: > [ text/plain ] > Move the brief help text at the bottom of the hello screen to the > notmuch-hello-mode help, and promote '?' as the universal help key > across Notmuch. This unclutters the hello screen, and allows for a > more verbose description in the mode help. Hopefully, this change is > useful for both experienced and new users alike. > > While at it, improve the links to Notmuch and hello screen > customization. looks good, works fine. +1 Tomi PS: kept [text/plain] just for users' annoyance ;) ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs: hello: promote '?' as the universal help key
Looks good, thanks for doing it. On Sun, Mar 13 2016, Jani Nikula wrote: > Move the brief help text at the bottom of the hello screen to the > notmuch-hello-mode help, and promote '?' as the universal help key > across Notmuch. This unclutters the hello screen, and allows for a > more verbose description in the mode help. Hopefully, this change is > useful for both experienced and new users alike. > > While at it, improve the links to Notmuch and hello screen > customization. > > --- > > This obsoletes > id:1450026221-23286-1-git-send-email-j...@nikula.org > --- > emacs/notmuch-hello.el | 44 > +- > test/emacs.expected-output/notmuch-hello | 7 +--- > .../emacs.expected-output/notmuch-hello-long-names | 7 +--- > .../notmuch-hello-no-saved-searches| 7 +--- > .../emacs.expected-output/notmuch-hello-with-empty | 7 +--- > 5 files changed, 42 insertions(+), 30 deletions(-) > > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el > index b42e0f24148a..8a31f9a1c52c 100644 > --- a/emacs/notmuch-hello.el > +++ b/emacs/notmuch-hello.el > @@ -672,6 +672,31 @@ with `notmuch-hello-query-counts'." > (defun notmuch-hello-mode () > "Major mode for convenient notmuch navigation. This is your entry portal > into notmuch. > > +Saved searches are \"bookmarks\" for arbitrary queries. Hit RET > +or click on a saved search to view matching threads. Edit saved > +searches with the `edit' button. Type `\\[notmuch-jump-search]' > +in any Notmuch screen for quick access to saved searches that > +have shortcut keys. > + > +Type new searches in the search box and hit RET to view matching > +threads. Hit RET in a recent search box to re-submit a previous > +search. Edit it first if you like. Save a recent search to saved > +searches with the `save' button. > + > +Hit `\\[notmuch-search]' or `\\[notmuch-tree]' in any Notmuch > +screen to search for messages and view matching threads or > +messages, respectively. Recent searches are available in the > +minibuffer history. > + > +Expand the all tags view with the `show' button (and collapse > +again with the `hide' button). Hit RET or click on a tag name to > +view matching threads. > + > +Hit `\\[notmuch-refresh-this-buffer]' to refresh the screen and > +`\\[notmuch-bury-or-kill-this-buffer]' to quit. > + > +The screen may be customized via `\\[customize]'. > + > Complete list of currently available key bindings: > > \\{notmuch-hello-mode-map}" > @@ -907,20 +932,19 @@ following: > (defun notmuch-hello-insert-footer () >"Insert the notmuch-hello footer." >(let ((start (point))) > -(widget-insert "Type a search query and hit RET to view matching > threads.\n") > -(when notmuch-search-history > - (widget-insert "Hit RET to re-submit a previous search. Edit it first > if you like.\n") > - (widget-insert "Save recent searches with the `save' button.\n")) > -(when notmuch-saved-searches > - (widget-insert "Edit saved searches with the `edit' button.\n")) > -(widget-insert "Hit RET or click on a saved search or tag name to view > matching threads.\n") > -(widget-insert "`=' to refresh this screen. `s' to search messages. `q' > to quit.\n") > +(widget-insert "Hit `?' for context-sensitive help in any Notmuch > screen.\n") > +(widget-insert "Customize ") > +(widget-create 'link > +:notify (lambda (&rest ignore) > + (customize-group 'notmuch)) > +:button-prefix "" :button-suffix "" > +"Notmuch") > +(widget-insert " or ") > (widget-create 'link > :notify (lambda (&rest ignore) >(customize-variable 'notmuch-hello-sections)) > :button-prefix "" :button-suffix "" > -"Customize") > -(widget-insert " this page.") > +"this page.") > (let ((fill-column (- (window-width) notmuch-hello-indent))) >(center-region start (point) > > diff --git a/test/emacs.expected-output/notmuch-hello > b/test/emacs.expected-output/notmuch-hello > index 9ba4cfc1d560..89186082f8a9 100644 > --- a/test/emacs.expected-output/notmuch-hello > +++ b/test/emacs.expected-output/notmuch-hello > @@ -8,8 +8,5 @@ Search:
[PATCH] emacs: hello: promote '?' as the universal help key
Move the brief help text at the bottom of the hello screen to the notmuch-hello-mode help, and promote '?' as the universal help key across Notmuch. This unclutters the hello screen, and allows for a more verbose description in the mode help. Hopefully, this change is useful for both experienced and new users alike. While at it, improve the links to Notmuch and hello screen customization. --- This obsoletes id:1450026221-23286-1-git-send-email-j...@nikula.org --- emacs/notmuch-hello.el | 44 +- test/emacs.expected-output/notmuch-hello | 7 +--- .../emacs.expected-output/notmuch-hello-long-names | 7 +--- .../notmuch-hello-no-saved-searches| 7 +--- .../emacs.expected-output/notmuch-hello-with-empty | 7 +--- 5 files changed, 42 insertions(+), 30 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index b42e0f24148a..8a31f9a1c52c 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -672,6 +672,31 @@ with `notmuch-hello-query-counts'." (defun notmuch-hello-mode () "Major mode for convenient notmuch navigation. This is your entry portal into notmuch. +Saved searches are \"bookmarks\" for arbitrary queries. Hit RET +or click on a saved search to view matching threads. Edit saved +searches with the `edit' button. Type `\\[notmuch-jump-search]' +in any Notmuch screen for quick access to saved searches that +have shortcut keys. + +Type new searches in the search box and hit RET to view matching +threads. Hit RET in a recent search box to re-submit a previous +search. Edit it first if you like. Save a recent search to saved +searches with the `save' button. + +Hit `\\[notmuch-search]' or `\\[notmuch-tree]' in any Notmuch +screen to search for messages and view matching threads or +messages, respectively. Recent searches are available in the +minibuffer history. + +Expand the all tags view with the `show' button (and collapse +again with the `hide' button). Hit RET or click on a tag name to +view matching threads. + +Hit `\\[notmuch-refresh-this-buffer]' to refresh the screen and +`\\[notmuch-bury-or-kill-this-buffer]' to quit. + +The screen may be customized via `\\[customize]'. + Complete list of currently available key bindings: \\{notmuch-hello-mode-map}" @@ -907,20 +932,19 @@ following: (defun notmuch-hello-insert-footer () "Insert the notmuch-hello footer." (let ((start (point))) -(widget-insert "Type a search query and hit RET to view matching threads.\n") -(when notmuch-search-history - (widget-insert "Hit RET to re-submit a previous search. Edit it first if you like.\n") - (widget-insert "Save recent searches with the `save' button.\n")) -(when notmuch-saved-searches - (widget-insert "Edit saved searches with the `edit' button.\n")) -(widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n") -(widget-insert "`=' to refresh this screen. `s' to search messages. `q' to quit.\n") +(widget-insert "Hit `?' for context-sensitive help in any Notmuch screen.\n") +(widget-insert "Customize ") +(widget-create 'link + :notify (lambda (&rest ignore) +(customize-group 'notmuch)) + :button-prefix "" :button-suffix "" + "Notmuch") +(widget-insert " or ") (widget-create 'link :notify (lambda (&rest ignore) (customize-variable 'notmuch-hello-sections)) :button-prefix "" :button-suffix "" - "Customize") -(widget-insert " this page.") + "this page.") (let ((fill-column (- (window-width) notmuch-hello-indent))) (center-region start (point) diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello index 9ba4cfc1d560..89186082f8a9 100644 --- a/test/emacs.expected-output/notmuch-hello +++ b/test/emacs.expected-output/notmuch-hello @@ -8,8 +8,5 @@ Search: . All tags: [show] -Type a search query and hit RET to view matching threads. - Edit saved searches with the `edit' button. - Hit RET or click on a saved search or tag name to view matching threads. - `=' to refresh this screen. `s' to search messages. `q' to quit. - Customize this page. +Hit `?' for context-sensitive help in any Notmuch screen. + Customize Notmuch or this page. diff --git a/test/emacs.exp
Re: [PATCH] emacs: hello: tell the user about help and notmuch customization
Jani Nikula writes: > Make it easier for new users to find out about thing in notmuch-emacs. > --- > emacs/notmuch-hello.el | 11 +-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el > index b42e0f24148a..738baad23b20 100644 > --- a/emacs/notmuch-hello.el > +++ b/emacs/notmuch-hello.el > @@ -915,12 +915,19 @@ following: >(widget-insert "Edit saved searches with the `edit' button.\n")) > (widget-insert "Hit RET or click on a saved search or tag name to view > matching threads.\n") > (widget-insert "`=' to refresh this screen. `s' to search messages. `q' > to quit.\n") > +(widget-insert "`?' in each Notmuch screen to display help for the > current mode.\n") > +(widget-insert "Customize ") > +(widget-create 'link > +:notify (lambda (&rest ignore) > + (customize-group 'notmuch)) > +:button-prefix "" :button-suffix "" > +"Notmuch") > +(widget-insert " or ") > (widget-create 'link > :notify (lambda (&rest ignore) >(customize-variable 'notmuch-hello-sections)) > :button-prefix "" :button-suffix "" > -"Customize") > -(widget-insert " this page.") > +"this page.") > (let ((fill-column (- (window-width) notmuch-hello-indent))) >(center-region start (point) Unfortunately this breaks some tests. d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] emacs: hello: tell the user about help and notmuch customization
This change looks good, seems worthwhile. On Sun, Dec 13 2015, Jani Nikula wrote: > Make it easier for new users to find out about thing in notmuch-emacs. > --- > emacs/notmuch-hello.el | 11 +-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el > index b42e0f24148a..738baad23b20 100644 > --- a/emacs/notmuch-hello.el > +++ b/emacs/notmuch-hello.el > @@ -915,12 +915,19 @@ following: >(widget-insert "Edit saved searches with the `edit' button.\n")) > (widget-insert "Hit RET or click on a saved search or tag name to view > matching threads.\n") > (widget-insert "`=' to refresh this screen. `s' to search messages. `q' > to quit.\n") > +(widget-insert "`?' in each Notmuch screen to display help for the > current mode.\n") > +(widget-insert "Customize ") > +(widget-create 'link > +:notify (lambda (&rest ignore) > + (customize-group 'notmuch)) > +:button-prefix "" :button-suffix "" > +"Notmuch") > +(widget-insert " or ") > (widget-create 'link > :notify (lambda (&rest ignore) >(customize-variable 'notmuch-hello-sections)) > :button-prefix "" :button-suffix "" > -"Customize") > -(widget-insert " this page.") > +"this page.") > (let ((fill-column (- (window-width) notmuch-hello-indent))) >(center-region start (point) > > -- > 2.1.4 > > ___ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] emacs: hello: tell the user about help and notmuch customization
Make it easier for new users to find out about thing in notmuch-emacs. --- emacs/notmuch-hello.el | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index b42e0f24148a..738baad23b20 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -915,12 +915,19 @@ following: (widget-insert "Edit saved searches with the `edit' button.\n")) (widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n") (widget-insert "`=' to refresh this screen. `s' to search messages. `q' to quit.\n") +(widget-insert "`?' in each Notmuch screen to display help for the current mode.\n") +(widget-insert "Customize ") +(widget-create 'link + :notify (lambda (&rest ignore) +(customize-group 'notmuch)) + :button-prefix "" :button-suffix "" + "Notmuch") +(widget-insert " or ") (widget-create 'link :notify (lambda (&rest ignore) (customize-variable 'notmuch-hello-sections)) :button-prefix "" :button-suffix "" - "Customize") -(widget-insert " this page.") + "this page.") (let ((fill-column (- (window-width) notmuch-hello-indent))) (center-region start (point) -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] cli: enable notmuch --help command
David Bremner writes: > David Bremner writes: > >> This functionality seems to have been undocumented, if it ever >> existed. Document it now. > > Apparently this is a patch that fixes our currently broken subtest. That > might have even been why I wrote it. I'll push (a whitespace cleaned up > version of) this unless I hear some objections. As threatened, I pushed this. d
[PATCH 1/3] configure: alphabetize --without help
Now that the "without" options seem to be multiplying, try to make it easier for people to find the one they want. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index b8b2c67..1e17b46 100755 --- a/configure +++ b/configure @@ -144,9 +144,9 @@ Some specific library versions can be specified (auto-detected otherwise): Some features can be disabled (--with-feature=no is equivalent to --without-feature) : + --without-bash-completion Do not install bash completions files --without-docs Do not install documentation and man pages --without-emacs Do not install lisp file - --without-bash-completion Do not install bash completions files --without-zsh-completionDo not install zsh completions files Additional options are accepted for compatibility with other -- 2.1.4
Re: [PATCH] cli: enable notmuch --help command
David Bremner writes: > David Bremner writes: > >> This functionality seems to have been undocumented, if it ever >> existed. Document it now. > > Apparently this is a patch that fixes our currently broken subtest. That > might have even been why I wrote it. I'll push (a whitespace cleaned up > version of) this unless I hear some objections. As threatened, I pushed this. d ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/3] configure: alphabetize --without help
Now that the "without" options seem to be multiplying, try to make it easier for people to find the one they want. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index b8b2c67..1e17b46 100755 --- a/configure +++ b/configure @@ -144,9 +144,9 @@ Some specific library versions can be specified (auto-detected otherwise): Some features can be disabled (--with-feature=no is equivalent to --without-feature) : + --without-bash-completion Do not install bash completions files --without-docs Do not install documentation and man pages --without-emacs Do not install lisp file - --without-bash-completion Do not install bash completions files --without-zsh-completionDo not install zsh completions files Additional options are accepted for compatibility with other -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] cli: enable notmuch --help command
David Bremner writes: > This functionality seems to have been undocumented, if it ever > existed. Document it now. Apparently this is a patch that fixes our currently broken subtest. That might have even been why I wrote it. I'll push (a whitespace cleaned up version of) this unless I hear some objections. d
Re: [PATCH] cli: enable notmuch --help command
David Bremner writes: > This functionality seems to have been undocumented, if it ever > existed. Document it now. Apparently this is a patch that fixes our currently broken subtest. That might have even been why I wrote it. I'll push (a whitespace cleaned up version of) this unless I hear some objections. d ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] cli: enable notmuch --help command
This functionality seems to have been undocumented, if it ever existed. Document it now. --- doc/man1/notmuch.rst | 4 +++- notmuch.c| 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/man1/notmuch.rst b/doc/man1/notmuch.rst index ae0461a..87fb7bc 100644 --- a/doc/man1/notmuch.rst +++ b/doc/man1/notmuch.rst @@ -39,8 +39,10 @@ OPTIONS Supported global options for ``notmuch`` include -``--help`` +``--help`` [command-name] Print a synopsis of available commands and exit. +With an optional command name, show the man page +for that subcommand. ``--version`` Print the installed version of notmuch, and exit. diff --git a/notmuch.c b/notmuch.c index c528dce..9580c3f 100644 --- a/notmuch.c +++ b/notmuch.c @@ -381,11 +381,11 @@ main (int argc, char *argv[]) goto DONE; } -notmuch_process_shared_options (NULL); - if (opt_index < argc) command_name = argv[opt_index]; +notmuch_process_shared_options (command_name); + command = find_command (command_name); if (!command) { fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n", -- 2.1.4
[PATCH] cli: enable notmuch --help command
This functionality seems to have been undocumented, if it ever existed. Document it now. --- doc/man1/notmuch.rst | 4 +++- notmuch.c| 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/man1/notmuch.rst b/doc/man1/notmuch.rst index ae0461a..87fb7bc 100644 --- a/doc/man1/notmuch.rst +++ b/doc/man1/notmuch.rst @@ -39,8 +39,10 @@ OPTIONS Supported global options for ``notmuch`` include -``--help`` +``--help`` [command-name] Print a synopsis of available commands and exit. +With an optional command name, show the man page +for that subcommand. ``--version`` Print the installed version of notmuch, and exit. diff --git a/notmuch.c b/notmuch.c index c528dce..9580c3f 100644 --- a/notmuch.c +++ b/notmuch.c @@ -381,11 +381,11 @@ main (int argc, char *argv[]) goto DONE; } -notmuch_process_shared_options (NULL); - if (opt_index < argc) command_name = argv[opt_index]; +notmuch_process_shared_options (command_name); + command = find_command (command_name); if (!command) { fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n", -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] fixup! cli: add standard option processing to config, help and setup
--- test/random-corpus.c | 8 1 file changed, 8 insertions(+) diff --git a/test/random-corpus.c b/test/random-corpus.c index 6c467bb..b377eb4 100644 --- a/test/random-corpus.c +++ b/test/random-corpus.c @@ -125,6 +125,14 @@ notmuch_process_shared_options (unused (const char *dummy)) } int +notmuch_minimal_options (unused (const char *subcommand), +unused (int argc), +unused (char **argv)) +{ +return 0; +} + +int main (int argc, char **argv) { -- 2.1.4
[PATCH] fixup! cli: add standard option processing to config, help and setup
--- test/random-corpus.c | 8 1 file changed, 8 insertions(+) diff --git a/test/random-corpus.c b/test/random-corpus.c index 6c467bb..b377eb4 100644 --- a/test/random-corpus.c +++ b/test/random-corpus.c @@ -125,6 +125,14 @@ notmuch_process_shared_options (unused (const char *dummy)) } int +notmuch_minimal_options (unused (const char *subcommand), +unused (int argc), +unused (char **argv)) +{ +return 0; +} + +int main (int argc, char **argv) { -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 4/4] cli: add standard option processing to config, help and setup
In particular this fixes a recently encountered bug where the "--config" argument to "notmuch setup" is silently ignored, which the unpleasant consequence of overwriting the users config file. --- notmuch-client.h | 2 ++ notmuch-config.c | 9 - notmuch-setup.c | 3 +++ notmuch.c| 32 +++- test/random-corpus.c | 9 + 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index 8ecfac6..78680aa 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -468,4 +468,6 @@ notmuch_database_dump (notmuch_database_t *notmuch, #include "command-line-arguments.h" extern const notmuch_opt_desc_t notmuch_shared_options []; void notmuch_process_shared_options (const char* subcommand_name); +int notmuch_minimal_options (const char* subcommand_name, +int argc, char **argv); #endif diff --git a/notmuch-config.c b/notmuch-config.c index 2d5c297..9348278 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -872,8 +872,15 @@ int notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]) { int ret; +int opt_index; -argc--; argv++; /* skip subcommand argument */ +opt_index = notmuch_minimal_options ("config", argc, argv); +if (opt_index < 0) + return EXIT_FAILURE; + +/* skip at least subcommand argument */ +argc-= opt_index; +argv+= opt_index; if (argc < 1) { fprintf (stderr, "Error: notmuch config requires at least one argument.\n"); diff --git a/notmuch-setup.c b/notmuch-setup.c index 36a6171..7dd5822 100644 --- a/notmuch-setup.c +++ b/notmuch-setup.c @@ -145,6 +145,9 @@ notmuch_setup_command (notmuch_config_t *config, chomp_newline (response); \ } while (0) +if (notmuch_minimal_options ("setup", argc, argv) < 0) + return EXIT_FAILURE; + if (notmuch_config_is_new (config)) welcome_message_pre_setup (); diff --git a/notmuch.c b/notmuch.c index 3a9da90..2198b73 100644 --- a/notmuch.c +++ b/notmuch.c @@ -71,6 +71,28 @@ notmuch_process_shared_options (const char *subcommand_name) { } } +/* This is suitable for subcommands that do not actually open the + * database. + */ +int notmuch_minimal_options (const char *subcommand_name, + int argc, char **argv) +{ +int opt_index; + +notmuch_opt_desc_t options[] = { + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, + { 0, 0, 0, 0, 0 } +}; + +opt_index = parse_arguments (argc, argv, options, 1); + +if (opt_index < 0) + return -1; + +/* We can't use argv here as it is sometimes NULL */ +notmuch_process_shared_options (subcommand_name); +return opt_index; +} static command_t commands[] = { { NULL, notmuch_command, TRUE, @@ -250,7 +272,15 @@ _help_for (const char *topic_name) static int notmuch_help_command (unused (notmuch_config_t * config), int argc, char *argv[]) { -argc--; argv++; /* Ignore "help" */ +int opt_index; + +opt_index = notmuch_minimal_options ("help", argc, argv); +if (opt_index < 0) + return EXIT_FAILURE; + +/* skip at least subcommand argument */ +argc-= opt_index; +argv+= opt_index; if (argc == 0) { return _help_for (NULL); diff --git a/test/random-corpus.c b/test/random-corpus.c index 790193d..6c467bb 100644 --- a/test/random-corpus.c +++ b/test/random-corpus.c @@ -114,6 +114,15 @@ random_utf8_string (void *ctx, size_t char_count) return buf; } +/* stubs since we cannot link with notmuch.o */ +const notmuch_opt_desc_t notmuch_shared_options[] = { + { 0, 0, 0, 0, 0 } +}; + +void +notmuch_process_shared_options (unused (const char *dummy)) +{ +} int main (int argc, char **argv) -- 2.1.4
[PATCH 3/4] cli: define shared options, use for --help and --version
tmuch-tag.c +++ b/notmuch-tag.c @@ -206,6 +206,7 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 }, { NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 }, { NOTMUCH_OPT_BOOLEAN, &remove_all, "remove-all", 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -213,6 +214,8 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + if (input_file_name) { batch = TRUE; input = fopen (input_file_name, "r"); diff --git a/notmuch.c b/notmuch.c index bff941f..3a9da90 100644 --- a/notmuch.c +++ b/notmuch.c @@ -43,6 +43,35 @@ notmuch_help_command (notmuch_config_t *config, int argc, char *argv[]); static int notmuch_command (notmuch_config_t *config, int argc, char *argv[]); +static int +_help_for (const char *topic); + +static notmuch_bool_t print_version = FALSE, print_help = FALSE; + +const notmuch_opt_desc_t notmuch_shared_options [] = { +{ NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 }, +{ NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 }, +{0, 0, 0, 0, 0} +}; + +/* any subcommand wanting to support these options should call + * inherit notmuch_shared_options and call + * notmuch_process_shared_options (subcommand_name); + */ +void +notmuch_process_shared_options (const char *subcommand_name) { +if (print_version) { + printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); + exit (EXIT_SUCCESS); +} + +if (print_help) { + int ret = _help_for (subcommand_name); + exit (ret); +} +} + + static command_t commands[] = { { NULL, notmuch_command, TRUE, "Notmuch main command." }, @@ -295,14 +324,12 @@ main (int argc, char *argv[]) command_t *command; char *config_file_name = NULL; notmuch_config_t *config = NULL; -notmuch_bool_t print_help=FALSE, print_version=FALSE; int opt_index; int ret; notmuch_opt_desc_t options[] = { - { NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 }, - { NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 }, { NOTMUCH_OPT_STRING, &config_file_name, "config", 'c', 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -324,24 +351,7 @@ main (int argc, char *argv[]) goto DONE; } -/* Handle notmuch --help [command] and notmuch command --help. */ -if (print_help || - (opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) { - /* -* Pass the first positional argument as argv[1] so the help -* command can give help for it. The help command ignores the -* argv[0] passed to it. -*/ - ret = notmuch_help_command (NULL, argc - opt_index + 1, - argv + opt_index - 1); - goto DONE; -} - -if (print_version) { - printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); - ret = EXIT_SUCCESS; - goto DONE; -} +notmuch_process_shared_options (NULL); if (opt_index < argc) command_name = argv[opt_index]; -- 2.1.4
[PATCH 4/4] cli: add standard option processing to config, help and setup
In particular this fixes a recently encountered bug where the "--config" argument to "notmuch setup" is silently ignored, which the unpleasant consequence of overwriting the users config file. --- notmuch-client.h | 2 ++ notmuch-config.c | 9 - notmuch-setup.c | 3 +++ notmuch.c| 32 +++- test/random-corpus.c | 9 + 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index 8ecfac6..78680aa 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -468,4 +468,6 @@ notmuch_database_dump (notmuch_database_t *notmuch, #include "command-line-arguments.h" extern const notmuch_opt_desc_t notmuch_shared_options []; void notmuch_process_shared_options (const char* subcommand_name); +int notmuch_minimal_options (const char* subcommand_name, +int argc, char **argv); #endif diff --git a/notmuch-config.c b/notmuch-config.c index 2d5c297..9348278 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -872,8 +872,15 @@ int notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]) { int ret; +int opt_index; -argc--; argv++; /* skip subcommand argument */ +opt_index = notmuch_minimal_options ("config", argc, argv); +if (opt_index < 0) + return EXIT_FAILURE; + +/* skip at least subcommand argument */ +argc-= opt_index; +argv+= opt_index; if (argc < 1) { fprintf (stderr, "Error: notmuch config requires at least one argument.\n"); diff --git a/notmuch-setup.c b/notmuch-setup.c index 36a6171..7dd5822 100644 --- a/notmuch-setup.c +++ b/notmuch-setup.c @@ -145,6 +145,9 @@ notmuch_setup_command (notmuch_config_t *config, chomp_newline (response); \ } while (0) +if (notmuch_minimal_options ("setup", argc, argv) < 0) + return EXIT_FAILURE; + if (notmuch_config_is_new (config)) welcome_message_pre_setup (); diff --git a/notmuch.c b/notmuch.c index 3a9da90..2198b73 100644 --- a/notmuch.c +++ b/notmuch.c @@ -71,6 +71,28 @@ notmuch_process_shared_options (const char *subcommand_name) { } } +/* This is suitable for subcommands that do not actually open the + * database. + */ +int notmuch_minimal_options (const char *subcommand_name, + int argc, char **argv) +{ +int opt_index; + +notmuch_opt_desc_t options[] = { + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, + { 0, 0, 0, 0, 0 } +}; + +opt_index = parse_arguments (argc, argv, options, 1); + +if (opt_index < 0) + return -1; + +/* We can't use argv here as it is sometimes NULL */ +notmuch_process_shared_options (subcommand_name); +return opt_index; +} static command_t commands[] = { { NULL, notmuch_command, TRUE, @@ -250,7 +272,15 @@ _help_for (const char *topic_name) static int notmuch_help_command (unused (notmuch_config_t * config), int argc, char *argv[]) { -argc--; argv++; /* Ignore "help" */ +int opt_index; + +opt_index = notmuch_minimal_options ("help", argc, argv); +if (opt_index < 0) + return EXIT_FAILURE; + +/* skip at least subcommand argument */ +argc-= opt_index; +argv+= opt_index; if (argc == 0) { return _help_for (NULL); diff --git a/test/random-corpus.c b/test/random-corpus.c index 790193d..6c467bb 100644 --- a/test/random-corpus.c +++ b/test/random-corpus.c @@ -114,6 +114,15 @@ random_utf8_string (void *ctx, size_t char_count) return buf; } +/* stubs since we cannot link with notmuch.o */ +const notmuch_opt_desc_t notmuch_shared_options[] = { + { 0, 0, 0, 0, 0 } +}; + +void +notmuch_process_shared_options (unused (const char *dummy)) +{ +} int main (int argc, char **argv) -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/4] cli: define shared options, use for --help and --version
1e4..35f971d 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -206,6 +206,7 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 }, { NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 }, { NOTMUCH_OPT_BOOLEAN, &remove_all, "remove-all", 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -213,6 +214,8 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + if (input_file_name) { batch = TRUE; input = fopen (input_file_name, "r"); diff --git a/notmuch.c b/notmuch.c index bff941f..3a9da90 100644 --- a/notmuch.c +++ b/notmuch.c @@ -43,6 +43,35 @@ notmuch_help_command (notmuch_config_t *config, int argc, char *argv[]); static int notmuch_command (notmuch_config_t *config, int argc, char *argv[]); +static int +_help_for (const char *topic); + +static notmuch_bool_t print_version = FALSE, print_help = FALSE; + +const notmuch_opt_desc_t notmuch_shared_options [] = { +{ NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 }, +{ NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 }, +{0, 0, 0, 0, 0} +}; + +/* any subcommand wanting to support these options should call + * inherit notmuch_shared_options and call + * notmuch_process_shared_options (subcommand_name); + */ +void +notmuch_process_shared_options (const char *subcommand_name) { +if (print_version) { + printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); + exit (EXIT_SUCCESS); +} + +if (print_help) { + int ret = _help_for (subcommand_name); + exit (ret); +} +} + + static command_t commands[] = { { NULL, notmuch_command, TRUE, "Notmuch main command." }, @@ -295,14 +324,12 @@ main (int argc, char *argv[]) command_t *command; char *config_file_name = NULL; notmuch_config_t *config = NULL; -notmuch_bool_t print_help=FALSE, print_version=FALSE; int opt_index; int ret; notmuch_opt_desc_t options[] = { - { NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 }, - { NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 }, { NOTMUCH_OPT_STRING, &config_file_name, "config", 'c', 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -324,24 +351,7 @@ main (int argc, char *argv[]) goto DONE; } -/* Handle notmuch --help [command] and notmuch command --help. */ -if (print_help || - (opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) { - /* -* Pass the first positional argument as argv[1] so the help -* command can give help for it. The help command ignores the -* argv[0] passed to it. -*/ - ret = notmuch_help_command (NULL, argc - opt_index + 1, - argv + opt_index - 1); - goto DONE; -} - -if (print_version) { - printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); - ret = EXIT_SUCCESS; - goto DONE; -} +notmuch_process_shared_options (NULL); if (opt_index < argc) command_name = argv[opt_index]; -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[Patch v2 3/4] cli: define shared options, use for --help and --version
Hi > +void notmuch_process_shared_options (const char* help_name); > diff --git a/notmuch.c b/notmuch.c > +/* any subcommand wanting to support these options should call > + * inherit notmuch_shared_options and call > + * notmuch_process_shared_options (subcommand_name); > + */ > +void > +notmuch_process_shared_options (const char *help_name) { Perhaps call the argument something else as it might be used by other commands later? Eg subcommand_name? (and in notmuch-client.h too) Best wishes Mark > +if (print_version) { > + printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); > + exit (EXIT_SUCCESS); > +} > + > +if (print_help) { > + int ret = _help_for (help_name); > + exit (ret); > +} > +} > + > + > static command_t commands[] = { > { NULL, notmuch_command, TRUE, >"Notmuch main command." }, > @@ -295,14 +324,12 @@ main (int argc, char *argv[]) > command_t *command; > char *config_file_name = NULL; > notmuch_config_t *config = NULL; > -notmuch_bool_t print_help=FALSE, print_version=FALSE; > int opt_index; > int ret; > > notmuch_opt_desc_t options[] = { > - { NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 }, > - { NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 }, > { NOTMUCH_OPT_STRING, &config_file_name, "config", 'c', 0 }, > + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, > { 0, 0, 0, 0, 0 } > }; > > @@ -324,24 +351,7 @@ main (int argc, char *argv[]) > goto DONE; > } > > -/* Handle notmuch --help [command] and notmuch command --help. */ > -if (print_help || > - (opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) { > - /* > - * Pass the first positional argument as argv[1] so the help > - * command can give help for it. The help command ignores the > - * argv[0] passed to it. > - */ > - ret = notmuch_help_command (NULL, argc - opt_index + 1, > - argv + opt_index - 1); > - goto DONE; > -} > - > -if (print_version) { > - printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); > - ret = EXIT_SUCCESS; > - goto DONE; > -} > +notmuch_process_shared_options (NULL); > > if (opt_index < argc) > command_name = argv[opt_index]; > -- > 2.1.4 > > ___ > notmuch mailing list > notmuch at notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch
Re: [Patch v2 3/4] cli: define shared options, use for --help and --version
Hi > +void notmuch_process_shared_options (const char* help_name); > diff --git a/notmuch.c b/notmuch.c > +/* any subcommand wanting to support these options should call > + * inherit notmuch_shared_options and call > + * notmuch_process_shared_options (subcommand_name); > + */ > +void > +notmuch_process_shared_options (const char *help_name) { Perhaps call the argument something else as it might be used by other commands later? Eg subcommand_name? (and in notmuch-client.h too) Best wishes Mark > +if (print_version) { > + printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); > + exit (EXIT_SUCCESS); > +} > + > +if (print_help) { > + int ret = _help_for (help_name); > + exit (ret); > +} > +} > + > + > static command_t commands[] = { > { NULL, notmuch_command, TRUE, >"Notmuch main command." }, > @@ -295,14 +324,12 @@ main (int argc, char *argv[]) > command_t *command; > char *config_file_name = NULL; > notmuch_config_t *config = NULL; > -notmuch_bool_t print_help=FALSE, print_version=FALSE; > int opt_index; > int ret; > > notmuch_opt_desc_t options[] = { > - { NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 }, > - { NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 }, > { NOTMUCH_OPT_STRING, &config_file_name, "config", 'c', 0 }, > + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, > { 0, 0, 0, 0, 0 } > }; > > @@ -324,24 +351,7 @@ main (int argc, char *argv[]) > goto DONE; > } > > -/* Handle notmuch --help [command] and notmuch command --help. */ > -if (print_help || > - (opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) { > - /* > - * Pass the first positional argument as argv[1] so the help > - * command can give help for it. The help command ignores the > - * argv[0] passed to it. > - */ > - ret = notmuch_help_command (NULL, argc - opt_index + 1, > - argv + opt_index - 1); > - goto DONE; > -} > - > -if (print_version) { > - printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); > - ret = EXIT_SUCCESS; > - goto DONE; > -} > +notmuch_process_shared_options (NULL); > > if (opt_index < argc) > command_name = argv[opt_index]; > -- > 2.1.4 > > ___ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[Patch v2 3/4] cli: define shared options, use for --help and --version
ebug", 'd', 0 }, { NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -941,6 +942,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + /* quiet trumps verbose */ if (quiet) add_files_state.verbosity = VERBOSITY_QUIET; diff --git a/notmuch-reply.c b/notmuch-reply.c index d51fdfc..4464741 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -790,6 +790,7 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) { "sender", FALSE }, { 0, 0 } } }, { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -797,6 +798,8 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + if (format == FORMAT_HEADERS_ONLY) { reply_format_func = notmuch_reply_format_headers_only; } else if (format == FORMAT_JSON) { diff --git a/notmuch-restore.c b/notmuch-restore.c index 584d9f9..2a534dc 100644 --- a/notmuch-restore.c +++ b/notmuch-restore.c @@ -154,6 +154,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[]) { 0, 0 } } }, { NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 }, { NOTMUCH_OPT_BOOLEAN, &accumulate, "accumulate", 'a', 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -163,6 +164,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[]) goto DONE; } +notmuch_process_shared_options (argv[0]); name_for_error = input_file_name ? input_file_name : "stdin"; if (! accumulate) diff --git a/notmuch-search.c b/notmuch-search.c index b81ac01..994ae58 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -681,6 +681,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0 }, { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0 }, { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -689,6 +690,8 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES && ctx->dupe != -1) { fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n"); diff --git a/notmuch-show.c b/notmuch-show.c index 43bf71c..b80933a 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1114,6 +1114,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.verify, "verify", 'v', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.output_body, "body", 'b', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.include_html, "include-html", 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -1121,6 +1122,8 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + /* decryption implies verification */ if (params.crypto.decrypt) params.crypto.verify = TRUE; diff --git a/notmuch-tag.c b/notmuch-tag.c index 5b2f1e4..35f971d 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -206,6 +206,7 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 }, { NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 }, { NOTMUCH_OPT_BOOLEAN, &remove_all, "remove-all", 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -213,6 +214,8 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + if (input_file_name) { batch = TRUE; input
[PATCH 3/4] cli: define shared options, use for --help and --version
*) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -941,6 +942,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + /* quiet trumps verbose */ if (quiet) add_files_state.verbosity = VERBOSITY_QUIET; diff --git a/notmuch-reply.c b/notmuch-reply.c index d51fdfc..4464741 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -790,6 +790,7 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) { "sender", FALSE }, { 0, 0 } } }, { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -797,6 +798,8 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + if (format == FORMAT_HEADERS_ONLY) { reply_format_func = notmuch_reply_format_headers_only; } else if (format == FORMAT_JSON) { diff --git a/notmuch-search.c b/notmuch-search.c index b81ac01..994ae58 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -681,6 +681,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0 }, { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0 }, { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -689,6 +690,8 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES && ctx->dupe != -1) { fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n"); diff --git a/notmuch-show.c b/notmuch-show.c index 43bf71c..b80933a 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1114,6 +1114,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.verify, "verify", 'v', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.output_body, "body", 'b', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.include_html, "include-html", 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -1121,6 +1122,8 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + /* decryption implies verification */ if (params.crypto.decrypt) params.crypto.verify = TRUE; diff --git a/notmuch-tag.c b/notmuch-tag.c index 5b2f1e4..35f971d 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -206,6 +206,7 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 }, { NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 }, { NOTMUCH_OPT_BOOLEAN, &remove_all, "remove-all", 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -213,6 +214,8 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + if (input_file_name) { batch = TRUE; input = fopen (input_file_name, "r"); diff --git a/notmuch.c b/notmuch.c index bff941f..c7f8c8f 100644 --- a/notmuch.c +++ b/notmuch.c @@ -43,6 +43,35 @@ notmuch_help_command (notmuch_config_t *config, int argc, char *argv[]); static int notmuch_command (notmuch_config_t *config, int argc, char *argv[]); +static int +_help_for (const char *topic); + +static notmuch_bool_t print_version = FALSE, print_help = FALSE; + +const notmuch_opt_desc_t notmuch_shared_options [] = { +{ NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 }, +{ NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 }, +{0, 0, 0, 0, 0} +}; + +/* any subcommand wanting to support these options should call + * inherit notmuch_shared_options and call + * notmuch_process_shared_options (subcommand_name); + */ +void +notmuch_process_shared_options (const char *help_name) { +if (print_version) { + printf ("notmuch " STRINGIFY
[Patch v2 3/4] cli: define shared options, use for --help and --version
batch = TRUE; input = fopen (input_file_name, "r"); diff --git a/notmuch.c b/notmuch.c index bff941f..c7f8c8f 100644 --- a/notmuch.c +++ b/notmuch.c @@ -43,6 +43,35 @@ notmuch_help_command (notmuch_config_t *config, int argc, char *argv[]); static int notmuch_command (notmuch_config_t *config, int argc, char *argv[]); +static int +_help_for (const char *topic); + +static notmuch_bool_t print_version = FALSE, print_help = FALSE; + +const notmuch_opt_desc_t notmuch_shared_options [] = { +{ NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 }, +{ NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 }, +{0, 0, 0, 0, 0} +}; + +/* any subcommand wanting to support these options should call + * inherit notmuch_shared_options and call + * notmuch_process_shared_options (subcommand_name); + */ +void +notmuch_process_shared_options (const char *help_name) { + if (print_version) { + printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); + exit (EXIT_SUCCESS); +} + +if (print_help) { + int ret = _help_for (help_name); + exit (ret); +} +} + + static command_t commands[] = { { NULL, notmuch_command, TRUE, "Notmuch main command." }, @@ -295,14 +324,12 @@ main (int argc, char *argv[]) command_t *command; char *config_file_name = NULL; notmuch_config_t *config = NULL; - notmuch_bool_t print_help=FALSE, print_version=FALSE; int opt_index; int ret; notmuch_opt_desc_t options[] = { - { NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 }, - { NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 }, { NOTMUCH_OPT_STRING, &config_file_name, "config", 'c', 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -324,24 +351,7 @@ main (int argc, char *argv[]) goto DONE; } -/* Handle notmuch --help [command] and notmuch command --help. */ -if (print_help || - (opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) { - /* -* Pass the first positional argument as argv[1] so the help -* command can give help for it. The help command ignores the -* argv[0] passed to it. -*/ - ret = notmuch_help_command (NULL, argc - opt_index + 1, - argv + opt_index - 1); - goto DONE; -} - -if (print_version) { - printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n"); - ret = EXIT_SUCCESS; - goto DONE; -} +notmuch_process_shared_options (NULL); if (opt_index < argc) command_name = argv[opt_index]; -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/4] cli: define shared options, use for --help and --version
HERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -941,6 +942,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + /* quiet trumps verbose */ if (quiet) add_files_state.verbosity = VERBOSITY_QUIET; diff --git a/notmuch-reply.c b/notmuch-reply.c index d51fdfc..4464741 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -790,6 +790,7 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) { "sender", FALSE }, { 0, 0 } } }, { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -797,6 +798,8 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + if (format == FORMAT_HEADERS_ONLY) { reply_format_func = notmuch_reply_format_headers_only; } else if (format == FORMAT_JSON) { diff --git a/notmuch-search.c b/notmuch-search.c index b81ac01..994ae58 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -681,6 +681,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0 }, { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0 }, { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -689,6 +690,8 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES && ctx->dupe != -1) { fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n"); diff --git a/notmuch-show.c b/notmuch-show.c index 43bf71c..b80933a 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1114,6 +1114,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.verify, "verify", 'v', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.output_body, "body", 'b', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.include_html, "include-html", 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -1121,6 +1122,8 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + /* decryption implies verification */ if (params.crypto.decrypt) params.crypto.verify = TRUE; diff --git a/notmuch-tag.c b/notmuch-tag.c index 5b2f1e4..35f971d 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -206,6 +206,7 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 }, { NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 }, { NOTMUCH_OPT_BOOLEAN, &remove_all, "remove-all", 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -213,6 +214,8 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; +notmuch_process_shared_options (argv[0]); + if (input_file_name) { batch = TRUE; input = fopen (input_file_name, "r"); diff --git a/notmuch.c b/notmuch.c index bff941f..c7f8c8f 100644 --- a/notmuch.c +++ b/notmuch.c @@ -43,6 +43,35 @@ notmuch_help_command (notmuch_config_t *config, int argc, char *argv[]); static int notmuch_command (notmuch_config_t *config, int argc, char *argv[]); +static int +_help_for (const char *topic); + +static notmuch_bool_t print_version = FALSE, print_help = FALSE; + +const notmuch_opt_desc_t notmuch_shared_options [] = { +{ NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 }, +{ NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 }, +{0, 0, 0, 0, 0} +}; + +/* any subcommand wanting to support these options should call + * inherit notmuch_shared_options and call + * notmuch_process_shared_options (subcommand_name); + */ +void +notmuch_process_shared_options (const char *help_name) { +if (print_version) { + printf ("notmuch " STRING
[PATCH 1/2] cli: fix top level --help combined with other options
Jani Nikula writes: > If the top level --help is combined with other options, help > fails. For example: > > $ notmuch --version --help > > Sorry, --help is not a known command. There's not much I can do to > help pushed these two
Re: [PATCH 1/2] cli: fix top level --help combined with other options
Jani Nikula writes: > If the top level --help is combined with other options, help > fails. For example: > > $ notmuch --version --help > > Sorry, --help is not a known command. There's not much I can do to > help pushed these two ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/2] cli: add support for notmuch command --help
On Mon, Mar 09 2015, David Bremner wrote: > Jani Nikula writes: > >> -if (print_help) { >> +/* Handle notmuch --help [command] and notmuch command --help. */ >> +if (print_help || >> +(opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) { > > I like the feature, and I can live with the implementation. I'm reminded This part above I agree :D > that you once proposed a more sophisticated way of handling shared > arguments for subcommands, but that foundered on a reef of bikeshedding. > > d Tomi
[PATCH 1/2] cli: fix top level --help combined with other options
On Mon, Mar 09 2015, David Bremner wrote: > Jani Nikula writes: > >> -ret = notmuch_help_command (NULL, argc - 1, &argv[1]); >> +/* >> + * Pass the first positional argument as argv[1] so the help >> + * command can give help for it. The help command ignores the >> + * argv[0] passed to it. >> + */ >> +ret = notmuch_help_command (NULL, argc - opt_index + 1, >> +argv + opt_index - 1); >> goto DONE; >> } > > LGTM Also to me, too. Tomi
Re: [PATCH 2/2] cli: add support for notmuch command --help
On Mon, Mar 09 2015, David Bremner wrote: > Jani Nikula writes: > >> -if (print_help) { >> +/* Handle notmuch --help [command] and notmuch command --help. */ >> +if (print_help || >> +(opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) { > > I like the feature, and I can live with the implementation. I'm reminded This part above I agree :D > that you once proposed a more sophisticated way of handling shared > arguments for subcommands, but that foundered on a reef of bikeshedding. > > d Tomi ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 1/2] cli: fix top level --help combined with other options
On Mon, Mar 09 2015, David Bremner wrote: > Jani Nikula writes: > >> -ret = notmuch_help_command (NULL, argc - 1, &argv[1]); >> +/* >> + * Pass the first positional argument as argv[1] so the help >> + * command can give help for it. The help command ignores the >> + * argv[0] passed to it. >> + */ >> +ret = notmuch_help_command (NULL, argc - opt_index + 1, >> +argv + opt_index - 1); >> goto DONE; >> } > > LGTM Also to me, too. Tomi ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/2] cli: add support for notmuch command --help
Jani Nikula writes: > -if (print_help) { > +/* Handle notmuch --help [command] and notmuch command --help. */ > +if (print_help || > + (opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) { I like the feature, and I can live with the implementation. I'm reminded that you once proposed a more sophisticated way of handling shared arguments for subcommands, but that foundered on a reef of bikeshedding. d
[PATCH 1/2] cli: fix top level --help combined with other options
Jani Nikula writes: > - ret = notmuch_help_command (NULL, argc - 1, &argv[1]); > + /* > + * Pass the first positional argument as argv[1] so the help > + * command can give help for it. The help command ignores the > + * argv[0] passed to it. > + */ > + ret = notmuch_help_command (NULL, argc - opt_index + 1, > + argv + opt_index - 1); > goto DONE; > } LGTM
Re: [PATCH 2/2] cli: add support for notmuch command --help
Jani Nikula writes: > -if (print_help) { > +/* Handle notmuch --help [command] and notmuch command --help. */ > +if (print_help || > + (opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) { I like the feature, and I can live with the implementation. I'm reminded that you once proposed a more sophisticated way of handling shared arguments for subcommands, but that foundered on a reef of bikeshedding. d ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 1/2] cli: fix top level --help combined with other options
Jani Nikula writes: > - ret = notmuch_help_command (NULL, argc - 1, &argv[1]); > + /* > + * Pass the first positional argument as argv[1] so the help > + * command can give help for it. The help command ignores the > + * argv[0] passed to it. > + */ > + ret = notmuch_help_command (NULL, argc - opt_index + 1, > + argv + opt_index - 1); > goto DONE; > } LGTM ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/2] cli: add support for notmuch command --help
Recognize 'notmuch command --help' at the top level as a special case, and show help for the command. Note that for simplicity, --help is only recognized as the first option for the subcommand. --- Creeping featurism or useful? ISTR Mark wanted this. --- notmuch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notmuch.c b/notmuch.c index 1717e8b3683c..a5b2877aee09 100644 --- a/notmuch.c +++ b/notmuch.c @@ -314,7 +314,9 @@ main (int argc, char *argv[]) goto DONE; } -if (print_help) { +/* Handle notmuch --help [command] and notmuch command --help. */ +if (print_help || + (opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) { /* * Pass the first positional argument as argv[1] so the help * command can give help for it. The help command ignores the -- 2.1.4
[PATCH 1/2] cli: fix top level --help combined with other options
If the top level --help is combined with other options, help fails. For example: $ notmuch --version --help Sorry, --help is not a known command. There's not much I can do to help. Fix this by adjusting argc and argv appropriately. The help command ignores argv[0] anyway, so we don't have to set it to "help". --- notmuch.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/notmuch.c b/notmuch.c index 0fac0997865e..1717e8b3683c 100644 --- a/notmuch.c +++ b/notmuch.c @@ -315,7 +315,13 @@ main (int argc, char *argv[]) } if (print_help) { - ret = notmuch_help_command (NULL, argc - 1, &argv[1]); + /* +* Pass the first positional argument as argv[1] so the help + * command can give help for it. The help command ignores the +* argv[0] passed to it. +*/ + ret = notmuch_help_command (NULL, argc - opt_index + 1, + argv + opt_index - 1); goto DONE; } -- 2.1.4
[PATCH 2/2] cli: add support for notmuch command --help
Recognize 'notmuch command --help' at the top level as a special case, and show help for the command. Note that for simplicity, --help is only recognized as the first option for the subcommand. --- Creeping featurism or useful? ISTR Mark wanted this. --- notmuch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notmuch.c b/notmuch.c index 1717e8b3683c..a5b2877aee09 100644 --- a/notmuch.c +++ b/notmuch.c @@ -314,7 +314,9 @@ main (int argc, char *argv[]) goto DONE; } -if (print_help) { +/* Handle notmuch --help [command] and notmuch command --help. */ +if (print_help || + (opt_index + 1 < argc && strcmp (argv[opt_index + 1], "--help") == 0)) { /* * Pass the first positional argument as argv[1] so the help * command can give help for it. The help command ignores the -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/2] cli: fix top level --help combined with other options
If the top level --help is combined with other options, help fails. For example: $ notmuch --version --help Sorry, --help is not a known command. There's not much I can do to help. Fix this by adjusting argc and argv appropriately. The help command ignores argv[0] anyway, so we don't have to set it to "help". --- notmuch.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/notmuch.c b/notmuch.c index 0fac0997865e..1717e8b3683c 100644 --- a/notmuch.c +++ b/notmuch.c @@ -315,7 +315,13 @@ main (int argc, char *argv[]) } if (print_help) { - ret = notmuch_help_command (NULL, argc - 1, &argv[1]); + /* +* Pass the first positional argument as argv[1] so the help + * command can give help for it. The help command ignores the +* argv[0] passed to it. +*/ + ret = notmuch_help_command (NULL, argc - opt_index + 1, + argv + opt_index - 1); goto DONE; } -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Inspired but need help searching folder names containing spaces
David Bremner writes: > > I'm not sure about the exact syntax, but some separate prefix to mean > only in the To header would be possible. As far as I know we'd need to > add more terms to the database [1], so you'd need to convince people > that the increase in the size of everyone's database was worthwhile. And > of course someone needs to write the code, but it would not be that > hard, I think. Austin pointed out on IRC that if we had fields indexed seperately then the current query parser then we could actually use the current Xapian query parser to generate an OR of several database fields from a single query prefix. So if someone wanted to take this on, that would probably be the way to go. d ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Inspired but need help searching folder names containing spaces
David Bremner writes: > > I'm not sure about the exact syntax, but some separate prefix to mean > only in the To header would be possible. As far as I know we'd need to > add more terms to the database [1], so you'd need to convince people > that the increase in the size of everyone's database was worthwhile. And > of course someone needs to write the code, but it would not be that > hard, I think. Austin pointed out on IRC that if we had fields indexed seperately then the current query parser then we could actually use the current Xapian query parser to generate an OR of several database fields from a single query prefix. So if someone wanted to take this on, that would probably be the way to go. d
Inspired but need help searching folder names containing spaces
Matthew Lear writes: > > Thanks. Explains everything. Any thoughts on searching on 'to' only? > I'm not sure if this is also related to what Xapian needs to be > provided with. If not, and if only searching in the to, cc and bcc > fields of the header is possible, maybe we could consider adopting and > integrating case sensitive syntax in notmuch such as TO:me rather than > to:me..? I'm not sure about the exact syntax, but some separate prefix to mean only in the To header would be possible. As far as I know we'd need to add more terms to the database [1], so you'd need to convince people that the increase in the size of everyone's database was worthwhile. And of course someone needs to write the code, but it would not be that hard, I think. d [1]: this could also be solved with the semi-mythical custom query parser.
Re: Inspired but need help searching folder names containing spaces
Matthew Lear writes: > > Thanks. Explains everything. Any thoughts on searching on 'to' only? > I'm not sure if this is also related to what Xapian needs to be > provided with. If not, and if only searching in the to, cc and bcc > fields of the header is possible, maybe we could consider adopting and > integrating case sensitive syntax in notmuch such as TO:me rather than > to:me..? I'm not sure about the exact syntax, but some separate prefix to mean only in the To header would be possible. As far as I know we'd need to add more terms to the database [1], so you'd need to convince people that the increase in the size of everyone's database was worthwhile. And of course someone needs to write the code, but it would not be that hard, I think. d [1]: this could also be solved with the semi-mythical custom query parser. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Inspired but need help searching folder names containing spaces
> On 20 Feb 2015, at 18:01, Jani Nikula wrote: > >> On Fri, 20 Feb 2015, Matthew Lear wrote: >> A couple of others things have surprised me, though. Using the date search >> option, such as date:"today" or date:"yesterday", hasn't quite thrown up >> what I expected. Searching with date:"today" shows up no results (which I >> know is wrong) and searching with date:"yesterday" shows up a handful of >> emails all from the same person, in different threads which all arrived on >> a day in May 2014... Got to be a bug there somewhere :-D > > This is a known limitation in the date: prefix queries. You have to > specify it as a range, for example date:today..today (from the beginning > of today until the end of today). If the underlying Xapian search engine > is not given a range expression (with the "..") it searches for the > words "date today" without punctuation, matching whatever it matches, > and notmuch does not even get an error for it. Thanks. Explains everything. Any thoughts on searching on 'to' only? I'm not sure if this is also related to what Xapian needs to be provided with. If not, and if only searching in the to, cc and bcc fields of the header is possible, maybe we could consider adopting and integrating case sensitive syntax in notmuch such as TO:me rather than to:me..? -- Matt
Re: Inspired but need help searching folder names containing spaces
> On 20 Feb 2015, at 18:01, Jani Nikula wrote: > >> On Fri, 20 Feb 2015, Matthew Lear wrote: >> A couple of others things have surprised me, though. Using the date search >> option, such as date:"today" or date:"yesterday", hasn't quite thrown up >> what I expected. Searching with date:"today" shows up no results (which I >> know is wrong) and searching with date:"yesterday" shows up a handful of >> emails all from the same person, in different threads which all arrived on >> a day in May 2014... Got to be a bug there somewhere :-D > > This is a known limitation in the date: prefix queries. You have to > specify it as a range, for example date:today..today (from the beginning > of today until the end of today). If the underlying Xapian search engine > is not given a range expression (with the "..") it searches for the > words "date today" without punctuation, matching whatever it matches, > and notmuch does not even get an error for it. Thanks. Explains everything. Any thoughts on searching on 'to' only? I'm not sure if this is also related to what Xapian needs to be provided with. If not, and if only searching in the to, cc and bcc fields of the header is possible, maybe we could consider adopting and integrating case sensitive syntax in notmuch such as TO:me rather than to:me..? -- Matt ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Inspired but need help searching folder names containing spaces
On Fri, 20 Feb 2015, Matthew Lear wrote: > A couple of others things have surprised me, though. Using the date search > option, such as date:"today" or date:"yesterday", hasn't quite thrown up > what I expected. Searching with date:"today" shows up no results (which I > know is wrong) and searching with date:"yesterday" shows up a handful of > emails all from the same person, in different threads which all arrived on > a day in May 2014... Got to be a bug there somewhere :-D This is a known limitation in the date: prefix queries. You have to specify it as a range, for example date:today..today (from the beginning of today until the end of today). If the underlying Xapian search engine is not given a range expression (with the "..") it searches for the words "date today" without punctuation, matching whatever it matches, and notmuch does not even get an error for it. HTH, Jani.
Inspired but need help searching folder names containing spaces
Hi David, >> notmuch search 'folder:"Deleted Items"' >> >> .. throws up zero results. >> > > Hmm. I tried to duplicate your situation here, and it works for me. Two > things to try: > > 1) notmuch search --output=files $QUERY > > where $QUERY is some query (using e.g. id:) that matches one of those > messages. Check that you have have the whole anchored path from the top > level. > > 2) NOTMUCH_DEBUG_QUERY=1 notmuch count -'folder:"Deleted Items"' > > have a look for XFOLDER:Deleted Items > > 3) try both of the above with "--exclude=false" in case you have tagged > them with an excluded tag. Note that by default "deleted" is such a tag. > You can change the excluded tags with "notmuch config" As part of still playing around with notmuch and strategies for tagging etc, I decided to start afresh with the database so I deleted it. After running notmuch new, I could quite happily search with notmuch search 'folder:"Deleted Items"'. This surprised me greatly because I know that I didn't apply any tags to mails in Deleted Items (couldn't find any in there to tag) and I also already tried searching with --exclude=false. In any case, it seems that searching in folders with spaces now works. Hurrah :-) A couple of others things have surprised me, though. Using the date search option, such as date:"today" or date:"yesterday", hasn't quite thrown up what I expected. Searching with date:"today" shows up no results (which I know is wrong) and searching with date:"yesterday" shows up a handful of emails all from the same person, in different threads which all arrived on a day in May 2014... Got to be a bug there somewhere :-D One last thing which I'd like to explore if I may is searching for emails sent to me. By default, I think notmuch classes 'to me' as 'to or cc or bcc me'. Is there a way to search/filter on emails sent only to me (ie where my name / address is only in the to: field in the message header)? This seems a reasonable requirement / use case so I'm assuming that there's a good reason that notmuch views it differently. An example is an automated bug tracking system which sends emails to the current assignee of the bug (to) and also watchers (cc). I'd like to be able to filter these emails differently (ie bugs I'm watching versus bugs I'm responsible for fixing). Apart from using other fields in the message body (which may be subject to change), there doesn't seem an easy way to do this which is surprising given notmuch's flexibility and power. Thoughts? I'm still exploring strategies for tagging and searching etc. The links on the wiki are helpful. The possibilities are almost infinite and while everybody's mail is different, having a great deal of flexibility can sometimes makes it tricky to decide on exactly what's best. Still, it's an enjoyable task, despite being time consuming, and is well worth the effort. Matt
Re: Inspired but need help searching folder names containing spaces
On Fri, 20 Feb 2015, Matthew Lear wrote: > A couple of others things have surprised me, though. Using the date search > option, such as date:"today" or date:"yesterday", hasn't quite thrown up > what I expected. Searching with date:"today" shows up no results (which I > know is wrong) and searching with date:"yesterday" shows up a handful of > emails all from the same person, in different threads which all arrived on > a day in May 2014... Got to be a bug there somewhere :-D This is a known limitation in the date: prefix queries. You have to specify it as a range, for example date:today..today (from the beginning of today until the end of today). If the underlying Xapian search engine is not given a range expression (with the "..") it searches for the words "date today" without punctuation, matching whatever it matches, and notmuch does not even get an error for it. HTH, Jani. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch