Re: [PATCH] ruby: fix ruby 3.1 warnings
Hello. On Sat, Apr 17, 2021 at 7:20 AM David Bremner wrote: > Thanks for the patch. I have a couple of questions / comments > > - It doesn't apply against current master (5248f55d5f1). Can you rebase > it? Huh? That's precisely the commit I used as a base. It applies cleanly. > - What version of ruby is generating those warnings? I don't see it with > ruby 2.7. I guess that's not necessarily a blocker, as long as the > patched version still builds and runs with older ruby. Yeah, not a blocker. I'm using Ruby 3.0. -- Felipe Contreras ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 13/13] vim: README: sync with upstream
Signed-off-by: Felipe Contreras --- vim/README | 27 +-- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/vim/README b/vim/README index c137bacd..d9a635a2 100644 --- a/vim/README +++ b/vim/README @@ -3,7 +3,7 @@ This is a vim plug-in that provides a fully usable mail client interface, utilizing the notmuch framework, through it's ruby bindings. -== install == +== Install == Simply run 'make install'. However, check that you have the dependencies below. @@ -12,6 +12,8 @@ Simply run 'make install'. However, check that you have the dependencies below. Make sure your vim version has ruby support: check for +ruby in 'vim --version' features. + % vim --version | grep +ruby + === ruby bindings === Check if you are able to run the following command cleanly: @@ -28,16 +30,10 @@ directory in the notmuch source tree. Since libnotmuch library concentrates on things other than handling mail, we need a library to do that, and for Ruby the best library for that is called -'mail'. The easiest way to install it is with ruby's gem. In most distro's the -package is called 'rubygems'. - -Once you have gem, run: +'mail': % gem install mail -In some systems gems are installed on a per-user basis by default, so make sure -you are running as the same user as the one that installed them. - This gem is not mandatory, but it's extremely recommended. == Running == @@ -46,6 +42,15 @@ Simple: % gvim -c ':NotMuch' +You might want to write a wrapper script (e.g. `vnm`) + + #!/bin/sh + gvim -c ":NotMuch $*" + +So you can run: + + vnm is:inbox date:yesterday.. + Enjoy ;) == More stuff == @@ -53,10 +58,12 @@ Enjoy ;) As an example to configure a key mapping to add the tag 'to-do' and archive, this is what I use: -let g:notmuch_rb_custom_search_maps = { + +let g:notmuch_custom_search_maps = { \ 't': 'search_tag("+to-do -inbox")', \ } -let g:notmuch_rb_custom_show_maps = { +let g:notmuch_custom_show_maps = { \ 't': 'show_tag("+to-do -inbox")', \ } + -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 12/13] vim: remove backwards compatibility wrappers
Seven years is more than enough. Signed-off-by: Felipe Contreras --- vim/notmuch.vim | 50 + 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/vim/notmuch.vim b/vim/notmuch.vim index e717fb5a..717633c7 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -399,20 +399,16 @@ endfunction "" root function! s:set_defaults() + if !exists('g:notmuch_folders') + let g:notmuch_folders = s:notmuch_folders_default + endif + if !exists('g:notmuch_date_format') - if exists('g:notmuch_rb_date_format') - let g:notmuch_date_format = g:notmuch_rb_date_format - else - let g:notmuch_date_format = s:notmuch_date_format_default - endif + let g:notmuch_date_format = s:notmuch_date_format_default endif if !exists('g:notmuch_datetime_format') - if exists('g:notmuch_rb_datetime_format') - let g:notmuch_datetime_format = g:notmuch_rb_datetime_format - else - let g:notmuch_datetime_format = s:notmuch_datetime_format_default - endif + let g:notmuch_datetime_format = s:notmuch_datetime_format_default endif if !exists('g:notmuch_reply_quote_format') @@ -424,41 +420,21 @@ function! s:set_defaults() endif if !exists('g:notmuch_reader') - if exists('g:notmuch_rb_reader') - let g:notmuch_reader = g:notmuch_rb_reader - else - let g:notmuch_reader = s:notmuch_reader_default - endif + let g:notmuch_reader = s:notmuch_reader_default endif if !exists('g:notmuch_sendmail') - if exists('g:notmuch_rb_sendmail') - let g:notmuch_sendmail = g:notmuch_rb_sendmail - else - let g:notmuch_sendmail = s:notmuch_sendmail_default - endif + let g:notmuch_sendmail = s:notmuch_sendmail_default endif if !exists('g:notmuch_folders_count_threads') - if exists('g:notmuch_rb_count_threads') - let g:notmuch_count_threads = g:notmuch_rb_count_threads - else - let g:notmuch_folders_count_threads = s:notmuch_folders_count_threads_default - endif + let g:notmuch_folders_count_threads = s:notmuch_folders_count_threads_default endif if !exists('g:notmuch_compose_start_insert') let g:notmuch_compose_start_insert = s:notmuch_compose_start_insert_default endif - if !exists('g:notmuch_custom_search_maps') && exists('g:notmuch_rb_custom_search_maps') - let g:notmuch_custom_search_maps = g:notmuch_rb_custom_search_maps - endif - - if !exists('g:notmuch_custom_show_maps') && exists('g:notmuch_rb_custom_show_maps') - let g:notmuch_custom_show_maps = g:notmuch_rb_custom_show_maps - endif - if exists('g:notmuch_custom_search_maps') call extend(g:notmuch_search_maps, g:notmuch_custom_search_maps) endif @@ -466,14 +442,6 @@ function! s:set_defaults() if exists('g:notmuch_custom_show_maps') call extend(g:notmuch_show_maps, g:notmuch_custom_show_maps) endif - - if !exists('g:notmuch_folders') - if exists('g:notmuch_rb_folders') - let g:notmuch_folders = g:notmuch_rb_folders - else - let g:notmuch_folders = s:notmuch_folders_default - endif - endif endfunction function! s:NotMuch(...) -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 11/13] vim: syntax: fix message description highlighting
From: Aaron Borden Signed-off-by: Felipe Contreras --- vim/syntax/notmuch-show.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/syntax/notmuch-show.vim b/vim/syntax/notmuch-show.vim index c3a98b77..de0c43a1 100644 --- a/vim/syntax/notmuch-show.vim +++ b/vim/syntax/notmuch-show.vim @@ -1,8 +1,8 @@ " notmuch show mode syntax file syntax cluster nmShowMsgDesc contains=nmShowMsgDescWho,nmShowMsgDescDate,nmShowMsgDescTags -syntax match nmShowMsgDescWho /[^)]\+)/ contained -syntax match nmShowMsgDescDate / ([^)]\+[0-9]) / contained +syntax match nmShowMsgDescWho /[^)]\+>/ contained +syntax match nmShowMsgDescDate / [^(]\+ / contained syntax match nmShowMsgDescTags /([^)]\+)$/ contained syntax cluster nmShowMsgHead contains=nmShowMsgHeadKey,nmShowMsgHeadVal -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 10/13] vim: option to add reply quote datetime
From: Aaron Borden By default it's empty so the format doesn't change. Cleanup-by: Felipe Contreras Signed-off-by: Felipe Contreras --- vim/notmuch.txt | 7 +++ vim/notmuch.vim | 12 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/vim/notmuch.txt b/vim/notmuch.txt index b658020d..a8a75fed 100644 --- a/vim/notmuch.txt +++ b/vim/notmuch.txt @@ -140,6 +140,13 @@ If you want to change the reply quote format to show the email address: let g:notmuch_reply_quote_format = '%s <%s>' < + *g:notmuch_reply_quote_datetime_format* + +There's also a way to specy the reply quote datetime format: +> + let g:notmuch_reply_quote_datetime_format = '%a %b %e' +< + *g:notmuch_folders_count_threads* If you want to count the threads instead of the messages in the folder view: diff --git a/vim/notmuch.vim b/vim/notmuch.vim index 59914a76..e717fb5a 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -57,6 +57,7 @@ let s:notmuch_folders_default = [ let s:notmuch_date_format_default = '%d.%m.%y' let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S' let s:notmuch_reply_quote_format_default = '%s' +let s:notmuch_reply_quote_datetime_format_default = '' let s:notmuch_reader_default = 'mutt -f %s' let s:notmuch_sendmail_default = 'sendmail' let s:notmuch_folders_count_threads_default = 0 @@ -418,6 +419,10 @@ function! s:set_defaults() let g:notmuch_reply_quote_format = s:notmuch_reply_quote_format_default endif + if !exists('g:notmuch_reply_quote_datetime_format') + let g:notmuch_reply_quote_datetime_format = s:notmuch_reply_quote_datetime_format_default + endif + if !exists('g:notmuch_reader') if exists('g:notmuch_rb_reader') let g:notmuch_reader = g:notmuch_rb_reader @@ -600,12 +605,17 @@ ruby << EOF name = addr.local + "@" if name.nil? && !addr.local.nil? name_format = VIM::evaluate('g:notmuch_reply_quote_format') name = name_format % [name, addr.address] if !addr.address.nil? + date_format = VIM::evaluate('g:notmuch_reply_quote_datetime_format') + quote_datetime = orig.date.strftime(date_format) if !date_format.empty? and orig.date else name = orig[:from] end name = "somebody" if name.nil? - body_lines << "%s wrote:" % name + quote = [] + quote << "On %s" % quote_datetime if quote_datetime + quote << "%s wrote:" % name + body_lines << quote.join(', ') part = orig.find_first_text part.convert.each_line do |l| body_lines << "> %s" % l.chomp -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 09/13] vim: option to add email address to reply quote
From: Aaron Borden Cleanup-by: Felipe Contreras Signed-off-by: Felipe Contreras --- vim/notmuch.txt | 6 ++ vim/notmuch.vim | 7 +++ 2 files changed, 13 insertions(+) diff --git a/vim/notmuch.txt b/vim/notmuch.txt index c98f2b53..b658020d 100644 --- a/vim/notmuch.txt +++ b/vim/notmuch.txt @@ -133,6 +133,12 @@ You can do the same for the thread view: > let g:notmuch_datetime_format = '%d.%m.%y %H:%M:%S' < + *g:notmuch_reply_quote_format* + +If you want to change the reply quote format to show the email address: +> + let g:notmuch_reply_quote_format = '%s <%s>' +< *g:notmuch_folders_count_threads* diff --git a/vim/notmuch.vim b/vim/notmuch.vim index 7a448467..59914a76 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -56,6 +56,7 @@ let s:notmuch_folders_default = [ let s:notmuch_date_format_default = '%d.%m.%y' let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S' +let s:notmuch_reply_quote_format_default = '%s' let s:notmuch_reader_default = 'mutt -f %s' let s:notmuch_sendmail_default = 'sendmail' let s:notmuch_folders_count_threads_default = 0 @@ -413,6 +414,10 @@ function! s:set_defaults() endif endif + if !exists('g:notmuch_reply_quote_format') + let g:notmuch_reply_quote_format = s:notmuch_reply_quote_format_default + endif + if !exists('g:notmuch_reader') if exists('g:notmuch_rb_reader') let g:notmuch_reader = g:notmuch_rb_reader @@ -593,6 +598,8 @@ ruby << EOF addr = Mail::Address.new(orig[:from].value) name = addr.name name = addr.local + "@" if name.nil? && !addr.local.nil? + name_format = VIM::evaluate('g:notmuch_reply_quote_format') + name = name_format % [name, addr.address] if !addr.address.nil? else name = orig[:from] end -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 08/13] vim: trivial cleanup
Signed-off-by: Felipe Contreras --- vim/notmuch.vim | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/vim/notmuch.vim b/vim/notmuch.vim index 8777d412..7a448467 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -641,9 +641,7 @@ ruby << EOF $searches.clear folders.each do |name, search| q = $curbuf.query(search) - $exclude_tags.each { |t| - q.add_tag_exclude(t) - } + $exclude_tags.each { |e| q.add_tag_exclude(e) } $searches << search count = count_threads ? q.count_threads : q.count_messages b << "%9d %-20s (%s)" % [count, name, search] @@ -655,9 +653,7 @@ ruby << EOF date_fmt = VIM::evaluate('g:notmuch_date_format') q = $curbuf.query(search) q.sort = Notmuch::SORT_NEWEST_FIRST - $exclude_tags.each { |t| - q.add_tag_exclude(t) - } + $exclude_tags.each { |e| q.add_tag_exclude(e) } $threads.clear t = q.search_threads -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 07/13] vim: use notmuch config command
This simplifies the configuration parsing, is more efficient, and also reverts back to previous logic. Signed-off-by: Felipe Contreras --- vim/notmuch.vim | 26 -- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/vim/notmuch.vim b/vim/notmuch.vim index 97167461..8777d412 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -484,24 +484,22 @@ ruby << EOF $searches = [] $threads = [] $messages = [] + $config = {} $mail_installed = defined?(Mail) - def get_config_item(item) - result = '' - IO.popen(['notmuch', 'config', 'get', item]) { |out| - result = out.read - } - return result.rstrip - end - def get_config - $db_name = get_config_item('database.path') - $email_name = get_config_item('user.name') - $email_address = get_config_item('user.primary_email') - $email_name = get_config_item('user.name') + IO.popen(%w[notmuch config list]) do |io| + io.each(chomp: true) do |e| + key, value = e.split('=') + $config[key] = value + end + end + + $db_name = $config['database.path'] + $email_name = $config['user.name'] + $email_address = $config['user.primary_email'] + $exclude_tags = $config['search.exclude_tags']&.split(';') || [] $email = "%s <%s>" % [$email_name, $email_address] - ignore_tags = get_config_item('search.exclude_tags') - $exclude_tags = ignore_tags.split("\n") end def vim_puts(s) -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 06/13] vim: trivial cleanup
Signed-off-by: Felipe Contreras --- vim/notmuch.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vim/notmuch.vim b/vim/notmuch.vim index dd715828..97167461 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -471,9 +471,8 @@ function! s:NotMuch(...) ruby << EOF require 'notmuch' - require 'rubygems' - require 'tempfile' require 'socket' + require 'tempfile' begin require 'mail' rescue LoadError -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 05/13] vim: show first part if no text part is detected
Better something than nothing. Signed-off-by: Felipe Contreras --- vim/notmuch.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/notmuch.vim b/vim/notmuch.vim index e2362a2d..dd715828 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -333,7 +333,7 @@ ruby << EOF b << "Date: %s" % msg['date'] nm_m.body_start = b.count if part - b << "--- %s ---" % part.mime_type + b << "--- %s ---" % [part.mime_type || 'none'] part.convert.each_line do |l| b << l.chomp end @@ -925,7 +925,7 @@ ruby << EOF def find_first_text return self if not multipart? - return text_part || html_part + return text_part || html_part || parts.first end def convert -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 04/13] vim: fix for missing parts
Sometimes Mail incorrectly parses multipart messages. See: https://github.com/mikel/mail/issues/1438 Check for empty parts instead of crashing. Signed-off-by: Felipe Contreras --- vim/notmuch.vim | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vim/notmuch.vim b/vim/notmuch.vim index 541698cd..e2362a2d 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -332,9 +332,13 @@ ruby << EOF b << "Cc: %s" % msg['cc'] b << "Date: %s" % msg['date'] nm_m.body_start = b.count - b << "--- %s ---" % part.mime_type - part.convert.each_line do |l| - b << l.chomp + if part + b << "--- %s ---" % part.mime_type + part.convert.each_line do |l| + b << l.chomp + end + else + b << "--- %s ---" % 'missing' end b << "" nm_m.end = b.count -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 01/13] vim: fix Mail 2.8.0 warning
Passing an unparsed header field to Mail::Field.new is deprecated and will be removed in Mail 2.8.0. Use Mail::Field.parse instead. Signed-off-by: Felipe Contreras --- vim/notmuch.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/notmuch.vim b/vim/notmuch.vim index ad8b7c80..541698cd 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -666,7 +666,7 @@ ruby << EOF date = Time.at(e.newest_date).strftime(date_fmt) subject = e.messages.first['subject'] if $mail_installed - subject = Mail::Field.new("Subject: " + subject).to_s + subject = Mail::Field.parse("Subject: " + subject).to_s else subject = subject.force_encoding('utf-8') end -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 03/13] vim: doc: minor spelling fix
From: John Gliksberg Signed-off-by: Felipe Contreras --- vim/notmuch.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/notmuch.txt b/vim/notmuch.txt index 4a038102..c98f2b53 100644 --- a/vim/notmuch.txt +++ b/vim/notmuch.txt @@ -144,7 +144,7 @@ If you want to count the threads instead of the messages in the folder view: *g:notmuch_reader* *g:notmuch_sendmail* -You can also configure your externail mail reader and sendemail program: +You can also configure your external mail reader and sendmail program: > let g:notmuch_reader = 'mutt -f %s' let g:notmuch_sendmail = 'sendmail' -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 02/13] vim: doc: small fixes
Signed-off-by: Felipe Contreras --- vim/notmuch.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/notmuch.txt b/vim/notmuch.txt index 43741022..4a038102 100644 --- a/vim/notmuch.txt +++ b/vim/notmuch.txt @@ -89,7 +89,7 @@ s Send CONFIGURATION *notmuch-config* You can add the following configurations to your `.vimrc`, or -`~/.vim/plugin/notmuch.vim`. +`~/.vim/after/plugin/notmuch.vim`. *g:notmuch_folders* @@ -138,7 +138,7 @@ You can do the same for the thread view: If you want to count the threads instead of the messages in the folder view: > - let g:notmuch_folders_count_threads = 0 + let g:notmuch_folders_count_threads = 1 < *g:notmuch_reader* -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 00/13] vim: a bunch of updates from upstream
I finally took some time to update notmuch-vim and include some fixes, as well as pull requests. Here are the transplanted patches. Aaron Borden (3): vim: option to add email address to reply quote vim: option to add reply quote datetime vim: syntax: fix message description highlighting Felipe Contreras (9): vim: fix Mail 2.8.0 warning vim: doc: small fixes vim: fix for missing parts vim: show first part if no text part is detected vim: trivial cleanup vim: use notmuch config command vim: trivial cleanup vim: remove backwards compatibility wrappers vim: README: sync with upstream John Gliksberg (1): vim: doc: minor spelling fix vim/README | 27 +--- vim/notmuch.txt | 19 +- vim/notmuch.vim | 120 +++- vim/syntax/notmuch-show.vim | 4 +- 4 files changed, 86 insertions(+), 84 deletions(-) -- 2.31.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] compat: expose canonicalize_file_name to C++
On Sun, Apr 18 2021, Tomi Ollila wrote: > > not perl, but python3 -c 'import socket; print(socket.getfqdn())' notmuch_passwd_sanitize() { python3 -c ' import os, sys, pwd, socket pw = pwd.getpwuid(os.getuid()) user = pw.pw_name name = pw.pw_gecos.partition(",")[0] fqdn = socket.getfqdn() for l in sys.stdin: l = l.replace(user, "USERNAME").replace(fqdn, "FQDN").replace(name, "USER_FULL_NAME") sys.stdout.write(l) ' } could work, could not remember whether it was PYTHON or NOTMUCH_PYTHON, and tested only manually on command line... > > Tomi Tomi ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] compat: expose canonicalize_file_name to C++
On Sun, Apr 18 2021, David Bremner wrote: > Đoàn Trần Công Danh writes: > >> >> Anyway, I see some failure in the testsuite due to: >> - *My* hostname(1) (from coreutils) doesn't understand "-f" Interesting (neither of these use coreutils hostname) $ rpm -q -f =hostname hostname-3.23-3.fc33.x86_64 $ rpm -q -f =hostname 'net-tools-1.60-109.el6.x86_64 Out of curiosity, about non-linux systems hostname... > > ah, any suggestions for a portable replacement? I guess some perl one > liner might work. not perl, but python3 -c 'import socket; print(socket.getfqdn())' (dropped other comments I had for notmuch_passwd_sanitize() (this time ;) Tomi ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] lib/n_d_index_file: check return value from _n_m_add_filename
David Bremner writes: > Ignoring this return value seems like a bad idea in general, and in > particular it has been hiding one or more bugs related to handling > long directory names. > --- > > This is not a fix for the aforementioned bugs, but it at least makes > clear part of the problem. The XDDIRENTRYn: terms are not checked > for length in the same way as XDIRECTORY terms. It isn't clear the > same hashing strategy will work, as the XDDIRECTORY terms are used to > create lists of child directories. It may be the best we can do is > enforce a limit on the length of path elements in trees indexed by > notmuch. Applied to master. d ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] test-lib: unset XDG_CONFIG_HOME
Đoàn Trần Công Danh writes: > lib/open.cc:_load_key_file will only open xdg-config files in > $XDG_CONFIG_HOME if it's defined, $HOME/.config will be considered if > and only if XDG_CONFIG_HOME not defined. > > Let's unset said variable before running the test. applied to master. d ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: v1 deletion patches
David Bremner writes: > This version has a better commit message for 2/2 and portability fixes > (thanks to Tomi) for 1/2. > > It obsoletes the WIP version [1] > > [1]: id:20210414021627.1236560-1-da...@tethera.net Applied to master. d ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] compat: expose canonicalize_file_name to C++
Đoàn Trần Công Danh writes: > > Anyway, I see some failure in the testsuite due to: > - *My* hostname(1) (from coreutils) doesn't understand "-f" ah, any suggestions for a portable replacement? I guess some perl one liner might work. > - All emacs tests depend on dtach(1) but the > test_require_external_prereq dtach is missing. Would you want > to see those patches for test_require_external_prereq dtach? > It's pretty trivial. Sure. ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] compat: expose canonicalize_file_name to C++
On 2021-04-18 10:08:31+0300, Tomi Ollila wrote: > On Sun, Apr 18 2021, Đoàn Trần Công Danh wrote: > > > On 2021-04-17 11:39:59-0300, David Bremner wrote: > >> Đoàn Trần Công Danh writes: > >> > >> > > >> > However, I see that lib/open.cc uses g_key_file_get_value from GLib > >> > already, we may switch to g_canonicalize_file_name then? > >> > > >> > >> Yes that could work. I think the treatment of NULL input might need some > >> extra care with g_canonicalize_file_name; at least my 5 minute attempt > >> to do a replacement causes many test failures. Do you want to make a > >> patch that uses g_canonicalize_file_name? The one other place we use > >> canonicalize_file_name (not totally coincidentally) also uses glib, so > >> in principle we could completely eliminate the compat function. > > > > Now, I'm thinking more about it and digging into GLib history, > > I think using g_canonicalize_filename would be problem, since it's > > available from 2.57.1/2.58 only. I think we're requiring glib-2.0 2.22 > > as of it's now. A big jump in dependencies isn't worth it. > > > > I think below patch would be better? > > If that worked (I did not test), instead of macro "hackery", inline function > could be better(?) i.e. something like the following in notmuch_compat.h: > > #if HAVE_CANONICALIZE_FILE_NAME > static inline char * > notmuch_canonicalize_file_name (const char *path) > { > return canonicalize_file_name (path) > } > #else > char * > notmuch_canonicalize_file_name (const char *path); > #endif > Yes, inline function are always better than macro. I feel embarassed that I couldn't think about that earlier. Here is a revised patch: ---8< Subject: [PATCH] compat: rename {,notmuch_}canonicalize_file_name When compat canonicalize_file_name was introduced, it was limited to C code only because it was used by C code only during that time. From 5ec6fd4d, (lib/open: check for split configuration when creating database., 2021-02-16), lib/open.cc, which is C++, relies on the existent of canonicalize_file_name. However, we can't blindly enable canonicalize_file_name for C++ code, because different implementation has different additional signature for C++ and users can arbitrarily add -DHAVE_CANONICALIZE_FILE_NAME=0 to {C,CXX}FLAGS. Let's put our implementation of canonicalize_file_name to our namespace, and prefer system's canonicalize_file_name if it's existed via an inline function. Helped-by: Tomi Ollila --- compat/canonicalize_file_name.c | 2 +- compat/compat.h | 13 - lib/open.cc | 4 ++-- notmuch-config.c| 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/compat/canonicalize_file_name.c b/compat/canonicalize_file_name.c index 000f9e78..84f2a2c2 100644 --- a/compat/canonicalize_file_name.c +++ b/compat/canonicalize_file_name.c @@ -4,7 +4,7 @@ #include char * -canonicalize_file_name (const char *path) +notmuch_canonicalize_file_name (const char *path) { #ifdef PATH_MAX char *resolved_path = malloc (PATH_MAX + 1); diff --git a/compat/compat.h b/compat/compat.h index 8f15e585..c3ef4051 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -37,12 +37,15 @@ extern "C" { #define _POSIX_PTHREAD_SEMANTICS 1 #endif -#if ! HAVE_CANONICALIZE_FILE_NAME -/* we only call this function from C, and this makes testing easier */ -#ifndef __cplusplus +#if HAVE_CANONICALIZE_FILE_NAME +static inline char * +notmuch_canonicalize_file_name (const char *path) +{ + return canonicalize_file_name (path); +} +#else char * -canonicalize_file_name (const char *path); -#endif +notmuch_canonicalize_file_name (const char *path); #endif #if ! HAVE_GETLINE diff --git a/lib/open.cc b/lib/open.cc index 5d80a884..7454ffae 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -612,9 +612,9 @@ notmuch_database_create_with_config (const char *database_path, _set_database_path (notmuch, database_path); if (key_file && ! split) { - char *mail_root = canonicalize_file_name ( + char *mail_root = notmuch_canonicalize_file_name ( g_key_file_get_value (key_file, "database", "mail_root", NULL)); - char *db_path = canonicalize_file_name (database_path); + char *db_path = notmuch_canonicalize_file_name (database_path); split = (mail_root && (0 != strcmp (mail_root, db_path))); diff --git a/notmuch-config.c b/notmuch-config.c index 16e86916..d8d47768 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -327,7 +327,7 @@ notmuch_conffile_save (notmuch_conffile_t *config) } /* Try not to overwrite symlinks. */ -filename = canonicalize_file_name (config->filename); +filename = notmuch_canonicalize_file_name (config->filename); if (! filename) { if (errno == ENOENT) { filename = strdup (config->filename); -- Danh ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send
Re: v1 deletion patches
On Fri, Apr 16 2021, David Bremner wrote: > This version has a better commit message for 2/2 and portability fixes > (thanks to Tomi) for 1/2. Looks safe enough to be pushed in. Tomi > > It obsoletes the WIP version [1] > > [1]: id:20210414021627.1236560-1-da...@tethera.net ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] compat: expose canonicalize_file_name to C++
On Sun, Apr 18 2021, Đoàn Trần Công Danh wrote: > On 2021-04-17 11:39:59-0300, David Bremner wrote: >> Đoàn Trần Công Danh writes: >> >> > >> > However, I see that lib/open.cc uses g_key_file_get_value from GLib >> > already, we may switch to g_canonicalize_file_name then? >> > >> >> Yes that could work. I think the treatment of NULL input might need some >> extra care with g_canonicalize_file_name; at least my 5 minute attempt >> to do a replacement causes many test failures. Do you want to make a >> patch that uses g_canonicalize_file_name? The one other place we use >> canonicalize_file_name (not totally coincidentally) also uses glib, so >> in principle we could completely eliminate the compat function. > > Now, I'm thinking more about it and digging into GLib history, > I think using g_canonicalize_filename would be problem, since it's > available from 2.57.1/2.58 only. I think we're requiring glib-2.0 2.22 > as of it's now. A big jump in dependencies isn't worth it. > > I think below patch would be better? If that worked (I did not test), instead of macro "hackery", inline function could be better(?) i.e. something like the following in notmuch_compat.h: #if HAVE_CANONICALIZE_FILE_NAME static inline char * notmuch_canonicalize_file_name (const char *path) { return canonicalize_file_name (path) } #else char * notmuch_canonicalize_file_name (const char *path); #endif (OTOH I'd like to get upgraded to 2.57.1 but I still have 2.49 in the system that builds this notmuch so... # 2.57.1 works w/o meson/ninja (and has ./configure) but requires libmount #glib_lnk=http://ftp.gnome.org/pub/gnome/sources/glib/2.57/glib-2.57.1.tar.xz #glib_cks=d029e7c4536835f1f103472f7510332c28d58b9b7d6cd0e9f45c2653e670d9b4 glib_lnk=http://ftp.gnome.org/pub/gnome/sources/glib/2.49/glib-2.49.4.tar.xz glib_cks=9e914f9d7ebb88f99f234a7633368a7c1133ea21b5cac9db2a33bc25f7a0e0d1 ) > -/* we only call this function from C, and this makes testing easier */ > -#ifndef __cplusplus > char * > -canonicalize_file_name (const char *path); > -#endif > +notmuch_canonicalize_file_name (const char *path); > +#else > +#define notmuch_canonicalize_file_name canonicalize_file_name > #endif > > Anyway, I see some failure in the testsuite due to: > - *My* hostname(1) (from coreutils) doesn't understand "-f" > - All emacs tests depend on dtach(1) but the > test_require_external_prereq dtach is missing. Would you want > to see those patches for test_require_external_prereq dtach? > It's pretty trivial. > -8<- > Subject: [PATCH] compat: rename {,notmuch_}canonicalize_file_name > > When compat canonicalize_file_name was introduced, it was limited to > C code only because it was used by C code only during that time. > > From 5ec6fd4d, (lib/open: check for split configuration when creating > database., 2021-02-16), lib/open.cc, which is C++, relies on the > existent of canonicalize_file_name. > > However, we can't blindly enable canonicalize_file_name for C++ code, > because different implementation has different additional signature for > C++ and users can arbitrarily add -DHAVE_CANONICALIZE_FILE_NAME=0 to > {C,CXX}FLAGS. > > Let's put our implementation of canonicalize_file_name to our namespace, > and prefer system's canonicalize_file_name if it's existed via a macro. > --- > compat/canonicalize_file_name.c | 6 +- > compat/compat.h | 7 +++ > lib/open.cc | 4 ++-- > notmuch-config.c| 2 +- > 4 files changed, 11 insertions(+), 8 deletions(-) > > diff --git a/compat/canonicalize_file_name.c b/compat/canonicalize_file_name.c > index 000f9e78..ba003268 100644 > --- a/compat/canonicalize_file_name.c > +++ b/compat/canonicalize_file_name.c > @@ -3,8 +3,12 @@ > #undef _GNU_SOURCE > #include > > +#ifdef notmuch_canonicalize_file_name > +#undef notmuch_canonicalize_file_name > +#endif > + > char * > -canonicalize_file_name (const char *path) > +notmuch_canonicalize_file_name (const char *path) w> { > #ifdef PATH_MAX > char *resolved_path = malloc (PATH_MAX + 1); > diff --git a/compat/compat.h b/compat/compat.h > index 8f15e585..a38bc460 100644 > --- a/compat/compat.h > +++ b/compat/compat.h > @@ -38,11 +38,10 @@ extern "C" { > #endif > > #if ! HAVE_CANONICALIZE_FILE_NAME > -/* we only call this function from C, and this makes testing easier */ > -#ifndef __cplusplus > char * > -canonicalize_file_name (const char *path); > -#endif > +notmuch_canonicalize_file_name (const char *path); > +#else > +#define notmuch_canonicalize_file_name canonicalize_file_name > #endif > > #if ! HAVE_GETLINE > diff --git a/lib/open.cc b/lib/open.cc > index 5d80a884..7454ffae 100644 > --- a/lib/open.cc > +++ b/lib/open.cc > @@ -612,9 +612,9 @@ notmuch_database_create_with_config (const char > *database_path, > _set_database_path (notmuch, database_path); > > if (key_file && ! split) { > - char *mail_root = canonicalize_file_nam