* Re: PATCH: Improved _mailboxes
@ 2000-02-21 12:30 Sven Wischnowsky
2000-02-21 16:41 ` Bart Schaefer
0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-02-21 12:30 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> This works pretty well, following Sven's most recent patches to _multi_parts.
> It now can handle mailboxes for elm, mail, mh, mutt, pine, and zmail.
>
> Things I like it to do that it doesn't yet:
>
> (1) The default style should be to make the all-files group be alternate
> completions, i.e., not shown unless the -default- group is empty.
No. We should use tags so the user can decide what he wants to see.
> (2) The all-files group for pine (currently commented out) should contain
> only full paths, not relative ones. How does one accomplish that?
For now I've just made the test before the initial call to _tags check
if $PREFIX starts with / or ~. Otherwise: interesting problem. One can
get almost that with `-W '(/)' -P/'.
> (3) I'm sometimes offered a blank completion -- an empty slot at the top
> of the list of all completions. I don't know where that comes from;
> it shouldn't be there. Quoting problem somewhere?
Almost. There was no test for $MAIL and in _multi_parts a missing ()
at an assignment. And some more of these in _mailboxes.
> And of course, I haven't yet written any actual completion functions to
> call this one; it's used only from _mutt, so far.
I think we should make the caching somewhat cleverer. I.e. only build
the caches for the commands really used (tried completion upon). Because
I happen to have a ~/mail with several thousend files so that the
initialisation for the pine cache takes quite some time and will never
be used. However, I sometimes use `mail -f' so I may have _mailboxes
executed.
The -J and -V options should never be used directly, I think. It's the
job of _description so that users can choose their own group names,
have the groups combined or separated and have different descriptions
displayed for different groups.
The patch should also fix the problem mentioned in 9814 -- make the
compadd in _multi_parts behave more _path_file'ish.
Oh, and I could not apply 9812 and 9815 automatically, I hope this
patch here applies without problems. Dunno how that happened.
Bye
Sven
diff -ru ../z.old/Completion/Core/_multi_parts Completion/Core/_multi_parts
--- ../z.old/Completion/Core/_multi_parts Mon Feb 21 11:02:07 2000
+++ Completion/Core/_multi_parts Mon Feb 21 12:52:31 2000
@@ -83,7 +83,7 @@
if [[ -n "$PREFIX$SUFFIX" || "$pre" = ${sep}* ]]; then
tmp1=( "${(@M)matches:#${PREFIX}${SUFFIX}${sep}*}" )
else
- tmp1=
+ tmp1=()
fi
if (( $#tmp1 )); then
@@ -233,10 +233,21 @@
PREFIX="${opre}${osuf}"
SUFFIX=""
- [[ -n "$pref" && "$orig" != "$pref" ]] &&
+ if [[ -n "$pref" && "$orig" != "$pref" ]]; then
+ if [[ "$pref" = *${sep} ]]; then
+ compadd "$group[@]" "$expl[@]" "$opts[@]" \
+ -p "${pref%${sep}*${sep}}${sep}" -S "$sep" \
+ -M "r:|${sep}=* r:|=* $match" - "${${pref%${sep}}##*${sep}}"
+
+ elif [[ "$pref" = *${sep}* ]]; then
+ compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" \
+ -p "${pref%${sep}*}${sep}" \
+ -M "r:|${sep}=* r:|=* $match" - "${pref##*${sep}}"
+ else
compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" \
-M "r:|${sep}=* r:|=* $match" - "$pref"
-
+ fi
+ fi
return
fi
done
diff -ru ../z.old/Completion/User/_mailboxes Completion/User/_mailboxes
--- ../z.old/Completion/User/_mailboxes Mon Feb 21 12:34:13 2000
+++ Completion/User/_mailboxes Mon Feb 21 13:17:57 2000
@@ -6,7 +6,7 @@
# This is still needlessly mutt-biased and should be fixed.
local -U dirboxes
-local i j expl muttrc="${muttrc:-~/.muttrc}"
+local i j expl muttrc="${muttrc:-~/.muttrc}" files nm="$compstate[nmatches]"
local pinedirectory="${pinedirectory:-~/mail}"
local maildirectory="${maildirectory:-~/Mail}"
@@ -15,6 +15,13 @@
typeset -U -g _mailbox_cache
typeset -U -g _maildir_cache _mbox_cache _mh_cache _mutt_cache _pine_cache
+ _mailbox_cache=()
+ _mbox_cache=()
+ _maildir_cache=()
+ _mh_cache=()
+ _mutt_cache=()
+ _pine_cache=()
+
[[ -f ${~muttrc:-.} ]] &&
_mutt_cache=( ${$(grep mailboxes ${~muttrc})[2,-1]} )
@@ -41,48 +48,73 @@
[[ -n "$mailpath" ]] &&
_mailbox_cache=( "${_mailbox_cache[@]}" "${(@)mailpath%%\?*}" )
- _mailbox_cache=( "${_mailbox_cache[@]}" $MAIL )
+ [[ -n "$MAIL" ]] && _mailbox_cache=( "${_mailbox_cache[@]}" $MAIL )
fi
-if _wanted files expl 'mailbox specification'; then
- local -U mbox_names
- case "${curcontext}" in
- (*:elm:*) # I've probably got this wrong, or at least incomplete
- mbox_names=( "${_mbox_cache[@]}" "${_mailbox_cache[@]}" )
- compadd "${expl[@]}" - \! \< \>;;
- (*:mail:*)
- if compset -P '+|-f+'; then
- mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
- else
- mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}" "${_mailbox_cache[@]}" )
- _path_files -J all-files
- fi;;
- (*:mh:*) # I've probably got this wrong, or at least incomplete
- (( $#_mh_cache )) && _multi_parts "${expl[@]}" / _mh_cache
- return;;
- (*:mutt:*)
- mbox_names=( "${_mutt_cache[@]}" "${_mailbox_cache[@]}" "${_maildir_cache[@]}" )
- compadd "${expl[@]}" - \! \< \>;;
- (*:pine:*)
- # Pine is like mail but with no leading `+' to disambiguate;
- # any files not in $pinedirectory must be absolute paths.
- mbox_names=( "${(@)_pine_cache#$~pinedirectory/}" "${_mbox_cache[@]}" )
- # _path_files -J all-files -g '/*'
- ;;
- (*:(zmail|zmlite):*)
- if compset -P '+|-f+'; then
- mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
- else
- mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
- "${_mailbox_cache[@]}" "${_mh_cache[@]}" )
- compadd "${expl[@]}" - % \&
- _path_files -J all-files
- fi
- ;;
- (*) # Some other program wants mailbox names? Use them all?
- mbox_names=( "${_mailbox_cache[@]}" "${_mbox_cache[@]}"
- "${_mh_cache[@]}" "${_mutt_cache[@]}" "${_pine_cache[@]}" );;
- esac
+# Files for pine must be absolute paths.
- (( $#mbox_names )) && _multi_parts "${expl[@]}" / mbox_names
+if [[ "$PREFIX" != (|-f)+* &&
+ ( "${curcontext}" = *:(mail|zmail|zmlite):* ||
+ ( "${curcontext}" = *:pine:* && "$PREFIX" = (|-f)[/\~]* ) ) ]]; then
+ _tags mailboxes files
+else
+ _tags mailboxes
fi
+
+while _tags; do
+ if _requested mailboxes expl 'mailbox specification'; then
+ local mbox_short
+ local -U mbox_names
+
+ mbox_short=()
+ mbox_names=()
+
+ case "${curcontext}" in
+ (*:elm:*) # I've probably got this wrong, or at least incomplete
+ mbox_names=( "${_mbox_cache[@]}" "${_mailbox_cache[@]}" )
+ mbox_short=( \! \< \> )
+ ;;
+ (*:mail:*)
+ if compset -P '+|-f+'; then
+ mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
+ else
+ mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}" "${_mailbox_cache[@]}" )
+ fi
+ ;;
+ (*:mh:*) # I've probably got this wrong, or at least incomplete
+ (( $#_mh_cache )) && _multi_parts "${expl[@]}" / _mh_cache
+ ;;
+ (*:mutt:*)
+ mbox_names=( "${_mutt_cache[@]}" "${_mailbox_cache[@]}" "${_maildir_cache[@]}" )
+ mbox_short=( \! \< \> );;
+ (*:pine:*)
+ # Pine is like mail but with no leading `+' to disambiguate;
+ # any files not in $pinedirectory must be absolute paths.
+ mbox_names=( "${(@)_pine_cache#$~pinedirectory/}" "${_mbox_cache[@]}" )
+ ;;
+ (*:(zmail|zmlite):*)
+ if compset -P '+|-f+'; then
+ mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
+ else
+ mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
+ "${_mailbox_cache[@]}" "${_mh_cache[@]}" )
+ mbox_short=( % \& )
+ fi
+ ;;
+ (*) # Some other program wants mailbox names? Use them all?
+ mbox_names=( "${_mailbox_cache[@]}" "${_mbox_cache[@]}"
+ "${_mh_cache[@]}" "${_mutt_cache[@]}" "${_pine_cache[@]}" )
+ ;;
+ esac
+
+ (( $#mbox_names )) && _multi_parts "${expl[@]}" / mbox_names
+ (( $#mbox_short )) && compadd "$expl[@]" - "$mbox_short[@]"
+ fi
+ if _requested files expl 'mailbox file'; then
+ compset -P -f
+ _path_files "$expl[@]"
+ fi
+ [[ nm -ne $compstate[nmatches] ]] && return 0
+done
+
+return 1
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: Improved _mailboxes
2000-02-21 12:30 PATCH: Improved _mailboxes Sven Wischnowsky
@ 2000-02-21 16:41 ` Bart Schaefer
2000-02-21 17:25 ` PATCH: " Bart Schaefer
2000-02-21 20:06 ` Peter Stephenson
0 siblings, 2 replies; 8+ messages in thread
From: Bart Schaefer @ 2000-02-21 16:41 UTC (permalink / raw)
To: Sven Wischnowsky, zsh-workers
On Feb 21, 1:30pm, Sven Wischnowsky wrote:
} Subject: Re: PATCH: Improved _mailboxes
}
} > (1) The default style should be to make the all-files group be alternate
} > completions, i.e., not shown unless the -default- group is empty.
}
} No. We should use tags so the user can decide what he wants to see.
Ah; that is of course what I meant, thank you for doing it.
} > (3) I'm sometimes offered a blank completion -- an empty slot at the top
} > of the list of all completions. I don't know where that comes from;
} > it shouldn't be there. Quoting problem somewhere?
}
} Almost. There was no test for $MAIL and in _multi_parts a missing ()
} at an assignment. And some more of these in _mailboxes.
Hmm, I thought `typeset -U' would deal with that, but of course it also
applies to colon-separated lists. Could have used `typeset -Ua' though,
nowadays, instead of all those empty initializations you added.
} > And of course, I haven't yet written any actual completion functions to
} > call this one; it's used only from _mutt, so far.
}
} I think we should make the caching somewhat cleverer. I.e. only build
} the caches for the commands really used (tried completion upon).
The problem is that mutt uses _maildir_cache, pine uses _mbox_cache, and
zmail uses _mh_cache. (Actually now that I think about it, pine can use
_mh_cache too.) How do you deal with the crossover without caching them
all? I'd rather not duplicate the knowledge of which programs can read
which other programs' mailboxes in both caching and tag-testing sections.
} Oh, and I could not apply 9812 and 9815 automatically, I hope this
} patch here applies without problems. Dunno how that happened.
That could be my trouble, as I was playing with _mailboxes before. Did
anyone else have a problem? I can re-diff against -dev-19 if needed.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* PATCH: Re: PATCH: Improved _mailboxes
2000-02-21 16:41 ` Bart Schaefer
@ 2000-02-21 17:25 ` Bart Schaefer
2000-02-21 20:06 ` Peter Stephenson
1 sibling, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2000-02-21 17:25 UTC (permalink / raw)
To: zsh-workers
On Feb 21, 4:41pm, Bart Schaefer wrote:
} Subject: Re: PATCH: Improved _mailboxes
}
} The problem is that mutt uses _maildir_cache, pine uses _mbox_cache, and
} zmail uses _mh_cache. (Actually now that I think about it, pine can use
} _mh_cache too.)
This patch adds mush and tkrat, and lets pine complete mh mailboxes.
There's one oddment left: When completing the full paths added by
_multi_parts under menu completion, one gets things like
zsh% mutt -f /<TAB>
/home /usr /var
zsh% mutt -f /<TAB>
zsh% mutt -f /home/
Now hitting TAB just cycles /home /usr /var. But if I type a / to continue
completing within /home, I get
zsh% mutt -f /home//
I tried adding -S/ -q to the _multi_parts call but the slash still does not
become autoremovable. It does vanish when I next type TAB:
zsh% mutt -f /home//<TAB>
zsh% mutt -f /home/schaefer/
This is with Sven's latest _multi_parts patch (9816).
Index: Completion/User/_mailboxes
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-3.1/Completion/User/_mailboxes,v
retrieving revision 1.10
diff -u -r1.10 _mailboxes
--- _mailboxes 2000/02/21 16:30:58 1.10
+++ _mailboxes 2000/02/21 16:55:16
@@ -54,7 +54,7 @@
# Files for pine must be absolute paths.
if [[ "$PREFIX" != (|-f)+* &&
- ( "${curcontext}" = *:(mail|zmail|zmlite):* ||
+ ( "${curcontext}" = *:(mail|mush|zmail|zmlite):* ||
( "${curcontext}" = *:pine:* && "$PREFIX" = (|-f)[/\~]* ) ) ]]; then
_tags mailboxes files
else
@@ -78,19 +78,35 @@
if compset -P '+|-f+'; then
mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
else
- mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}" "${_mailbox_cache[@]}" )
+ mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
+ "${_mailbox_cache[@]}" )
fi
;;
(*:mh:*) # I've probably got this wrong, or at least incomplete
(( $#_mh_cache )) && _multi_parts "${expl[@]}" / _mh_cache
;;
+ (*:mush:*)
+ if compset -P '+|-f+'; then
+ mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
+ else
+ mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
+ "${_mailbox_cache[@]}" )
+ mbox_short=( % \& )
+ fi
+ ;;
(*:mutt:*)
- mbox_names=( "${_mutt_cache[@]}" "${_mailbox_cache[@]}" "${_maildir_cache[@]}" )
+ mbox_names=( "${_mutt_cache[@]}" "${_mailbox_cache[@]}"
+ "${_maildir_cache[@]}" )
mbox_short=( \! \< \> );;
(*:pine:*)
# Pine is like mail but with no leading `+' to disambiguate;
# any files not in $pinedirectory must be absolute paths.
- mbox_names=( "${(@)_pine_cache#$~pinedirectory/}" "${_mbox_cache[@]}" )
+ mbox_names=( "${(@)_pine_cache#$~pinedirectory/}" "${_mbox_cache[@]}"
+ "${_mailbox_cache[@]}" "${_mh_cache[@]}" )
+ ;;
+ (*:tkrat:*) # Has a couple of custom formats I haven't programmed for.
+ mbox_names=( "${_mbox_cache[@]}"
+ "${_mailbox_cache[@]}" "${_mh_cache[@]}" )
;;
(*:(zmail|zmlite):*)
if compset -P '+|-f+'; then
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: Improved _mailboxes
2000-02-21 16:41 ` Bart Schaefer
2000-02-21 17:25 ` PATCH: " Bart Schaefer
@ 2000-02-21 20:06 ` Peter Stephenson
2000-02-21 21:59 ` Bart Schaefer
1 sibling, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 2000-02-21 20:06 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 909 bytes --]
"Bart Schaefer" wrote:
> } Oh, and I could not apply 9812 and 9815 automatically, I hope this
> } patch here applies without problems. Dunno how that happened.
>
> That could be my trouble, as I was playing with _mailboxes before. Did
> anyone else have a problem? I can re-diff against -dev-19 if needed.
I had this problem, and in fact with Sven's patch although that's probably
due to indifferent success at applying the previousones by hand, something
I've never been good at since it requires patience. The last patch applied
OK, however. Here's _mailbox as I currently have it to check, and if
correct to install for other people with problems.
I've attached it, so that it comes out right. What's the correct
Content-Type? I've left it as text/plain since it's not actually supposed
to be run. I don't know the etiquette on such matters.
--
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
[-- Attachment #2: Completion/User/_mailboxes --]
[-- Type: text/plain, Size: 4021 bytes --]
#autoload
#emulate -L zsh
setopt localoptions nullglob
# This is still needlessly mutt-biased and should be fixed.
local -U dirboxes
local i j expl muttrc="${muttrc:-~/.muttrc}" files nm="$compstate[nmatches]"
local pinedirectory="${pinedirectory:-~/mail}"
local maildirectory="${maildirectory:-~/Mail}"
if (( ! $+_mailbox_cache )) then
typeset -U -g _mailbox_cache
typeset -U -g _maildir_cache _mbox_cache _mh_cache _mutt_cache _pine_cache
_mailbox_cache=()
_mbox_cache=()
_maildir_cache=()
_mh_cache=()
_mutt_cache=()
_pine_cache=()
[[ -f ${~muttrc:-.} ]] &&
_mutt_cache=( ${$(grep mailboxes ${~muttrc})[2,-1]} )
_mbox_cache=( ${~maildirectory}/*(^/) )
_pine_cache=( ${~pinedirectory}/**/*(.) )
dirboxes=( ${~maildirectory}/*(/) )
while (( $#dirboxes )); do
i=${dirboxes[1]}
shift dirboxes
if [[ -d "$i/cur" ]]; then
_maildir_cache=( "${_maildir_cache[@]}" "$i" )
elif j=( "$i"/<1-> ) && [[ -n "$j" ]]; then
_mh_cache=( "${_mh_cache[@]}" "$i" )
else
_mbox_cache=( "${_mbox_cache[@]}" "$i"/*(.) )
dirboxes=( $dirboxes $i/*(/) )
fi
done
[[ -n "$_mutt_cache" || -d ~/.elm || -d ~/.mutt ]] &&
_mailbox_cache=( \! \< \> )
[[ -n "$mailpath" ]] &&
_mailbox_cache=( "${_mailbox_cache[@]}" "${(@)mailpath%%\?*}" )
[[ -n "$MAIL" ]] && _mailbox_cache=( "${_mailbox_cache[@]}" $MAIL )
fi
# Files for pine must be absolute paths.
if [[ "$PREFIX" != (|-f)+* &&
( "${curcontext}" = *:(mail|mush|zmail|zmlite):* ||
( "${curcontext}" = *:pine:* && "$PREFIX" = (|-f)[/\~]* ) ) ]]; then
_tags mailboxes files
else
_tags mailboxes
fi
while _tags; do
if _requested mailboxes expl 'mailbox specification'; then
local mbox_short
local -U mbox_names
mbox_short=()
mbox_names=()
case "${curcontext}" in
(*:elm:*) # I've probably got this wrong, or at least incomplete
mbox_names=( "${_mbox_cache[@]}" "${_mailbox_cache[@]}" )
mbox_short=( \! \< \> )
;;
(*:mail:*)
if compset -P '+|-f+'; then
mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
else
mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
"${_mailbox_cache[@]}" )
fi
;;
(*:mh:*) # I've probably got this wrong, or at least incomplete
(( $#_mh_cache )) && _multi_parts "${expl[@]}" / _mh_cache
;;
(*:mush:*)
if compset -P '+|-f+'; then
mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
else
mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
"${_mailbox_cache[@]}" )
mbox_short=( % \& )
fi
;;
(*:mutt:*)
mbox_names=( "${_mutt_cache[@]}" "${_mailbox_cache[@]}"
"${_maildir_cache[@]}" )
mbox_short=( \! \< \> );;
(*:pine:*)
# Pine is like mail but with no leading `+' to disambiguate;
# any files not in $pinedirectory must be absolute paths.
mbox_names=( "${(@)_pine_cache#$~pinedirectory/}" "${_mbox_cache[@]}"
"${_mailbox_cache[@]}" "${_mh_cache[@]}" )
;;
(*:tkrat:*) # Has a couple of custom formats I haven't programmed for.
mbox_names=( "${_mbox_cache[@]}"
"${_mailbox_cache[@]}" "${_mh_cache[@]}" )
;;
(*:(zmail|zmlite):*)
if compset -P '+|-f+'; then
mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
else
mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
"${_mailbox_cache[@]}" "${_mh_cache[@]}" )
mbox_short=( % \& )
fi
;;
(*) # Some other program wants mailbox names? Use them all?
mbox_names=( "${_mailbox_cache[@]}" "${_mbox_cache[@]}"
"${_mh_cache[@]}" "${_mutt_cache[@]}" "${_pine_cache[@]}" )
;;
esac
(( $#mbox_names )) && _multi_parts "${expl[@]}" / mbox_names
(( $#mbox_short )) && compadd "$expl[@]" - "$mbox_short[@]"
fi
if _requested files expl 'mailbox file'; then
compset -P -f
_path_files "$expl[@]"
fi
[[ nm -ne $compstate[nmatches] ]] && return 0
done
return 1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: Improved _mailboxes
2000-02-21 20:06 ` Peter Stephenson
@ 2000-02-21 21:59 ` Bart Schaefer
0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2000-02-21 21:59 UTC (permalink / raw)
To: Peter Stephenson, zsh-workers
On Feb 21, 8:06pm, Peter Stephenson wrote:
> Subject: Re: PATCH: Improved _mailboxes
>
> Here's _mailbox as I currently have it to check, and if
> correct to install for other people with problems.
The only difference I see is this (I have double-quotes around "$i"):
_mbox_cache=( "${_mbox_cache[@]}" "$i"/*(.) )
- dirboxes=( $dirboxes $i/*(/) )
+ dirboxes=( $dirboxes "$i"/*(/) )
fi
> I've attached it, so that it comes out right. What's the correct
> Content-Type? I've left it as text/plain since it's not actually supposed
> to be run. I don't know the etiquette on such matters.
I think text/plain is fine.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: Improved _mailboxes
@ 2000-02-22 8:52 Sven Wischnowsky
2000-02-22 17:55 ` Peter Stephenson
0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-02-22 8:52 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> ...
>
> } > (3) I'm sometimes offered a blank completion -- an empty slot at the top
> } > of the list of all completions. I don't know where that comes from;
> } > it shouldn't be there. Quoting problem somewhere?
> }
> } Almost. There was no test for $MAIL and in _multi_parts a missing ()
> } at an assignment. And some more of these in _mailboxes.
>
> Hmm, I thought `typeset -U' would deal with that, but of course it also
> applies to colon-separated lists. Could have used `typeset -Ua' though,
> nowadays, instead of all those empty initializations you added.
Right. I always forget to do that. Or think of it too late. I'm
planning to go through the completion functions again at least once
anyway to see where we can optimise them.
Btw, the patch I'm withholding that makes the parser emit wordcode
directly and that also contains several optimisations to the C-code
will make such assignments very cheap.
And since I'm talking about patches to come after 3.1.7: I've just
finished the patch to remove useheap we were talking about (i.e.
making all allocations use heap or real memory explicitly). It seems
to works fine until now and it will be tested even more until 3.1.7
appears, of course.
> } > And of course, I haven't yet written any actual completion functions to
> } > call this one; it's used only from _mutt, so far.
> }
> } I think we should make the caching somewhat cleverer. I.e. only build
> } the caches for the commands really used (tried completion upon).
>
> The problem is that mutt uses _maildir_cache, pine uses _mbox_cache, and
> zmail uses _mh_cache. (Actually now that I think about it, pine can use
> _mh_cache too.) How do you deal with the crossover without caching them
> all? I'd rather not duplicate the knowledge of which programs can read
> which other programs' mailboxes in both caching and tag-testing sections.
I was thinking about an initial test for the command used which would
decide which caches are needed. In the next step, (only) theses caches
are created if they don't exist yet and finally we fall into the
completion generation phase using those caches.
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: Improved _mailboxes
2000-02-22 8:52 Sven Wischnowsky
@ 2000-02-22 17:55 ` Peter Stephenson
0 siblings, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2000-02-22 17:55 UTC (permalink / raw)
To: zsh-workers
Sven Wischnowsky wrote:
> Btw, the patch I'm withholding that makes the parser emit wordcode
> directly and that also contains several optimisations to the C-code
> will make such assignments very cheap.
>
> And since I'm talking about patches to come after 3.1.7: I've just
> finished the patch to remove useheap we were talking about (i.e.
> making all allocations use heap or real memory explicitly). It seems
> to works fine until now and it will be tested even more until 3.1.7
> appears, of course.
Frankly, as regards 3.1.* versions, my policy has generally been to put in
pretty much anything that doesn't cause immediate and obvious problems
straight away, rather than delaying it. There's a big enough user base for
*-dev-* that the bad problems get sorted out pretty quickly; and zsh is
complicated enough that the less bad problems often need the exposure of
the 3.1.x releases to show up at all. So I shouldn't be shy. As I said
yesterday, things my end are going to run to a halt for a few weeks.
I'm delighted about the vanishing of useheap --- this was sort of vaguely
on my to-do list, at least to think about over a cup of tea. This should
reduce the number of memory leaks dramatically. (Not that we have memory
leaks, of course.)
--
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
^ permalink raw reply [flat|nested] 8+ messages in thread
* PATCH: Improved _mailboxes
@ 2000-02-21 10:34 Bart Schaefer
0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2000-02-21 10:34 UTC (permalink / raw)
To: zsh-workers
This works pretty well, following Sven's most recent patches to _multi_parts.
It now can handle mailboxes for elm, mail, mh, mutt, pine, and zmail.
Things I like it to do that it doesn't yet:
(1) The default style should be to make the all-files group be alternate
completions, i.e., not shown unless the -default- group is empty.
(2) The all-files group for pine (currently commented out) should contain
only full paths, not relative ones. How does one accomplish that?
(3) I'm sometimes offered a blank completion -- an empty slot at the top
of the list of all completions. I don't know where that comes from;
it shouldn't be there. Quoting problem somewhere?
And of course, I haven't yet written any actual completion functions to
call this one; it's used only from _mutt, so far.
Index: Completion/User/_mailboxes
===================================================================
@@ -5,43 +5,89 @@
# This is still needlessly mutt-biased and should be fixed.
-local -U muttboxes mboxes dirboxes MHboxes maildirboxes
+local -U dirboxes
local i j expl muttrc="${muttrc:-~/.muttrc}"
local pinedirectory="${pinedirectory:-~/mail}"
local maildirectory="${maildirectory:-~/Mail}"
if (( ! $+_mailbox_cache )) then
- [[ -f ${~muttrc:-.} ]] && muttboxes=( ${$(grep mailboxes ${~muttrc})[2,-1]} )
+ typeset -U -g _mailbox_cache
+ typeset -U -g _maildir_cache _mbox_cache _mh_cache _mutt_cache _pine_cache
- mboxes=( ${~maildirectory}/*(^/) ${~pinedirectory}/**/*(.) )
+ [[ -f ${~muttrc:-.} ]] &&
+ _mutt_cache=( ${$(grep mailboxes ${~muttrc})[2,-1]} )
+
+ _mbox_cache=( ${~maildirectory}/*(^/) )
+ _pine_cache=( ${~pinedirectory}/**/*(.) )
+
dirboxes=( ${~maildirectory}/*(/) )
while (( $#dirboxes )); do
- i=$dirboxes[1]
+ i=${dirboxes[1]}
shift dirboxes
if [[ -d "$i/cur" ]]; then
- maildirboxes=( $maildirboxes $i )
+ _maildir_cache=( "${_maildir_cache[@]}" "$i" )
elif j=( $i/<1-> ) && [[ -n "$j" ]]; then
- MHboxes=( $MHboxes $i )
+ _mh_cache=( "${_mh_cache[@]}" "$i" )
else
- mboxes=( $mboxes $i/*(.) )
+ _mbox_cache=( "${_mbox_cache[@]}" "$i"/*(.) )
dirboxes=( $dirboxes $i/*(/) )
fi
done
- [[ -n "$muttboxes" || -d ~/.elm || -d ~/.mutt ]] &&
- _mailbox_cache=(\! \< \> $muttboxes)
+ [[ -n "$_mutt_cache" || -d ~/.elm || -d ~/.mutt ]] &&
+ _mailbox_cache=( \! \< \> )
[[ -n "$mailpath" ]] &&
- _mailbox_cache=($_mailbox_cache ${mailpath//\?*/})
+ _mailbox_cache=( "${_mailbox_cache[@]}" "${(@)mailpath%%\?*}" )
- _mailbox_cache=($_mailbox_cache $mboxes $maildirboxes $MHboxes)
+ _mailbox_cache=( "${_mailbox_cache[@]}" $MAIL )
fi
if _wanted files expl 'mailbox specification'; then
- if compset -P '+|-f+' || [[ $words[CURRENT-1] = -f ]]; then
- _files -W $maildirectory
+ local -U mbox_names
+ case "${curcontext}" in
+ (*:elm:*) # I've probably got this wrong, or at least incomplete
+ compadd "${expl[@]}" - \! \< \>
+ mbox_names=( "${_mbox_cache[@]}" "${_mailbox_cache[@]}" )
+ _multi_parts "${expl[@]}" / mbox_names;;
+ (*:mail:*)
+ if compset -P '+|-f+'; then
+ mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
+ _multi_parts "${expl[@]}" / mbox_names
+ else
+ mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}" "${_mailbox_cache[@]}" )
+ _multi_parts "${expl[@]}" / mbox_names
+ _path_files -J all-files
+ fi;;
+ (*:mh:*) # I've probably got this wrong, or at least incomplete
+ (( $#_mh_cache )) && _multi_parts "${expl[@]}" / _mh_cache;;
+ (*:mutt:*)
+ mbox_names=( "${_mutt_cache[@]}" "${_mailbox_cache[@]}" "${_maildir_cache[@]}" )
+ compadd "${expl[@]}" - \! \< \>
+ _multi_parts "${expl[@]}" / mbox_names;;
+ (*:pine:*)
+ # Pine is like mail but with no leading `+' to disambiguate;
+ # any files not in $pinedirectory must be absolute paths.
+ mbox_names=( "${(@)_pine_cache#$~pinedirectory/}" "${_mbox_cache[@]}" )
+ _multi_parts "${expl[@]}" / mbox_names
+ # _path_files -J all-files -g '/*'
+ ;;
+ (*:(zmail|zmlite):*)
+ if compset -P '+|-f+'; then
+ mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
+ _multi_parts "${expl[@]}" / mbox_names
else
- compadd "$@" "$expl[@]" - "$_mailbox_cache[@]"
+ compadd "${expl[@]}" - % \&
+ mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
+ "${_mailbox_cache[@]}" "${_mh_cache[@]}" )
+ _multi_parts "${expl[@]}" / mbox_names
+ _path_files -J all-files
fi
+ ;;
+ (*) # Some other program wants mailbox names? Use them all?
+ mbox_names=( "${_mailbox_cache[@]}" "${_mbox_cache[@]}"
+ "${_mh_cache[@]}" "${_mutt_cache[@]}" "${_pine_cache[@]}" )
+ _multi_parts "${expl[@]}" / mbox_names;;
+ esac
fi
Index: Completion/User/_mutt
===================================================================
@@ -8,7 +8,7 @@
'-b:BCC recipient:->userhost' \
'-c:CC recipient:->userhost' \
'-e:post-init configuration:' \
- '-f+:mailbox:_mailboxes' \
+ '-f+:mailbox: _mailboxes' \
'-F+:init file:_files' \
'-h+:help:' \
'-H+:draft file:_files' \
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2000-02-22 17:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-21 12:30 PATCH: Improved _mailboxes Sven Wischnowsky
2000-02-21 16:41 ` Bart Schaefer
2000-02-21 17:25 ` PATCH: " Bart Schaefer
2000-02-21 20:06 ` Peter Stephenson
2000-02-21 21:59 ` Bart Schaefer
-- strict thread matches above, loose matches on Subject: below --
2000-02-22 8:52 Sven Wischnowsky
2000-02-22 17:55 ` Peter Stephenson
2000-02-21 10:34 Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).