* Re: PATCH: Re: PATCH: Improved _mailboxes
@ 2000-02-22 9:10 Sven Wischnowsky
0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 2000-02-22 9:10 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> ...
>
> 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).
I was worried about that, too.
This makes the separator character be removed if it is typed. Not that
I used -r "$sep" so that typing a space or any other of those
characters that normally auto-remove such a suffix will in this case
*not* remove it. Since _multi_parts has to consider the strings it
gets to be exact matches, this is correct. If anyone doesn't like it,
tell me or just replace those `-r "$sep"''s with a -q, I'm not
religiously attached to them.
Bye
Sven
diff -ru ../z.old/Completion/Core/_multi_parts Completion/Core/_multi_parts
--- ../z.old/Completion/Core/_multi_parts Tue Feb 22 09:10:49 2000
+++ Completion/Core/_multi_parts Tue Feb 22 10:06:31 2000
@@ -121,7 +121,7 @@
tmp2=( "${(@M)matches:#${tmp1[1]}${sep}*}" )
if (( $#tmp2 )); then
- compadd "$group[@]" "$expl[@]" -p "$pref" -qS "$sep" "$opts[@]" \
+ compadd "$group[@]" "$expl[@]" -p "$pref" -r "$sep" -S "$sep" "$opts[@]" \
-M "r:|${sep}=* r:|=* $match" - "$tmp1[1]"
else
compadd "$group[@]" "$expl[@]" -p "$pref" "$sopts[@]" \
@@ -162,9 +162,9 @@
fi
for i in "${(@M)matches:#(${(j:|:)~tmp1})*}"; do
if [[ "$i" = *${sep}* ]]; then
- compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" \
+ compadd "$group[@]" "$expl[@]" -r "$sep" -S "$sep" "$opts[@]" \
-p "$pref" \
- -M "r:|${sep}=* r:|=* $match" - "${i%%${sep}*}${sep}"
+ -M "r:|${sep}=* r:|=* $match" - "${i%%${sep}*}"
else
compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" -p "$pref" \
-M "r:|${sep}=* r:|=* $match" - "$i"
@@ -177,9 +177,9 @@
for i in "${(@M)matches:#(${(j:|:)~tmp1})*}"; do
if [[ "$i" = *${sep}* ]]; then
- compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" \
+ compadd "$group[@]" "$expl[@]" -r "$sep" -S "$sep" "$opts[@]" \
-p "$pref" -s "${i#*${sep}}" \
- -M "r:|${sep}=* r:|=* $match" - "${i%%${sep}*}${sep}"
+ -M "r:|${sep}=* r:|=* $match" - "${i%%${sep}*}"
else
compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" -p "$pref" \
-M "r:|${sep}=* r:|=* $match" - "$i"
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: Improved _mailboxes
@ 2000-02-21 12:30 Sven Wischnowsky
2000-02-21 16:41 ` Bart Schaefer
0 siblings, 1 reply; 2+ 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] 2+ messages in thread
* Re: PATCH: Improved _mailboxes
2000-02-21 12:30 Sven Wischnowsky
@ 2000-02-21 16:41 ` Bart Schaefer
2000-02-21 17:25 ` PATCH: " Bart Schaefer
0 siblings, 1 reply; 2+ 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] 2+ messages in thread
* PATCH: Re: PATCH: Improved _mailboxes
2000-02-21 16:41 ` Bart Schaefer
@ 2000-02-21 17:25 ` Bart Schaefer
0 siblings, 0 replies; 2+ 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] 2+ messages in thread
end of thread, other threads:[~2000-02-22 9:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-22 9:10 PATCH: Re: PATCH: Improved _mailboxes Sven Wischnowsky
-- strict thread matches above, loose matches on Subject: below --
2000-02-21 12:30 Sven Wischnowsky
2000-02-21 16:41 ` Bart Schaefer
2000-02-21 17:25 ` PATCH: " 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).