zsh-workers
 help / color / mirror / code / Atom feed
* Re: can't run _email-mutt
       [not found]       ` <20050602123718.GA21218@xpeerience.u-strasbg.fr>
@ 2005-06-06 16:42         ` Oliver Kiddle
  2005-06-19 17:09           ` curtag (Re: can't run _email-mutt) Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2005-06-06 16:42 UTC (permalink / raw)
  To: Marc Chantreux; +Cc: zsh-workers

On 2 Jun, Marc Chantreux wrote:
> 
> a pure zsh solution is trying to parse all files that are sourced (
> using the source command ) by .muttrc.

Following patch is an attempt to do that. I'd be interested in any
feedback on how well this copes with your setup and if it breaks for
anyone's mutt/mush/zmail/whatever setup.

Has anyone got any ideas on how to narrow the context for the plugin
tag-order. Currently, if you want to specify a list of plugins as a
global setting, you need a context like ':completion:*'. That's not
nice  but the best alternative is listing commands:
':completion:*:(mailx|Mail|mutt|mush|ali|netscape):*'
Ideally, _tags should allow me to put 'email-addresses' in as a tag. It
should perhaps use $curtag.

Oliver

Index: Completion/Unix/Type/_email_addresses
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_email_addresses,v
retrieving revision 1.3
diff -u -r1.3 _email_addresses
--- Completion/Unix/Type/_email_addresses	15 Jan 2004 16:56:56 -0000	1.3
+++ Completion/Unix/Type/_email_addresses	6 Jun 2005 16:26:35 -0000
@@ -14,7 +14,16 @@
 # plugins
 (( $+functions[_email-mail] )) ||
 _email-mail() {
-  reply=( ${${${(M)${(f)"$(<$files[$plugin])"}:#alias*}##alias[[:blank:]]##}/[[:blank:]]##/:} )
+  local rc rcfiles i
+
+  rcfiles=( $files[$plugin] )
+  for ((i=1;i<=$#rcfiles;i++)); do
+    rcfiles+=( ${~${(M)${(f)"$(<$rcfiles[i])"}:#source*}##source[[:blank:]]##}(N) )
+  done
+  reply=()
+  for rc in $rcfiles; do
+    reply+=( ${${${(M)${(f)"$(<$rc)"}:#alias*}##alias[[:blank:]]##}/[[:blank:]]##/:} )
+  done
   return 300
 }
 (( $+functions[_email-mutt] )) || _email-mutt() { _email-mail }
@@ -79,7 +88,7 @@
 _email_addresses() {
   local -a plugins reply list args
   local -A opts files
-  local plugin rcfile expl ret fret
+  local plugin rcfile muttrc expl ret fret
 
   local __specialx='][()<>@,;:\\".'
   local __spacex=" 	"				# Space, tab
@@ -119,7 +128,10 @@
   fi
 
   # get list of all plugins except any with missing config files
-  files=( MH ${MH:-~/.mh_profile} mutt ~/.muttrc mush ~/.mushrc mail ${MAILRC:-~/.mailrc} pine ~/.addressbook )
+  if ! zstyle -s ":completion:${curcontext}:email-addresses" muttrc muttrc; then
+    [[ -e ~/mutt/muttrc ]] && muttrc="~/mutt/muttrc" || muttrc="~/.muttrc"
+  fi
+  files=( MH ${MH:-~/.mh_profile} mutt $muttrc mush ~/.mushrc mail ${MAILRC:-~/.mailrc} pine ~/.addressbook )
   plugins=( 
     ${${(k)functions[(I)_email-*]#*-}:#(${(kj.|.)~files})}
     $files(Ne:'REPLY=( ${(k)files[(r)$REPLY]} ):')


This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* curtag (Re: can't run _email-mutt)
  2005-06-06 16:42         ` can't run _email-mutt Oliver Kiddle
@ 2005-06-19 17:09           ` Bart Schaefer
  2005-06-20 12:17             ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2005-06-19 17:09 UTC (permalink / raw)
  To: zsh-workers

Just got a chance to look at this ...

On Jun 6,  6:42pm, Oliver Kiddle wrote:
} 
} Has anyone got any ideas on how to narrow the context for the plugin
} tag-order. Currently, if you want to specify a list of plugins as a
} global setting, you need a context like ':completion:*'. That's not
} nice  but the best alternative is listing commands:
} ':completion:*:(mailx|Mail|mutt|mush|ali|netscape):*'

One possibility would be for _email_addresses to call

  _tags -C email-addresses email-$plugins

which would make the context look like

  :completion:*:*:*:email-addresses:*

} Ideally, _tags should allow me to put 'email-addresses' in as a tag. It
} should perhaps use $curtag.

I'm not sure how $curtag would apply in this case, because it's not set
until _requested or _wanted calls _all_labels from inside the _tags loop?
Or are we talking about nested _tags loops here, which is already a bit
of a sticky wicket?

It's entirely possible that there's some subtlety I'm missing.

On a more general note, though, it would appear that $curtag is rather
under-utilized.  By a quick grep I count about 15 functions that use both
_tags and zstyle without reference to $curtag.  _email_addresses is the
only one that seems to use it as it was intended.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: curtag (Re: can't run _email-mutt)
  2005-06-19 17:09           ` curtag (Re: can't run _email-mutt) Bart Schaefer
@ 2005-06-20 12:17             ` Oliver Kiddle
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Kiddle @ 2005-06-20 12:17 UTC (permalink / raw)
  To: zsh-workers

Bart wrote:

> I'm not sure how $curtag would apply in this case, because it's not set
> until _requested or _wanted calls _all_labels from inside the _tags loop?
> Or are we talking about nested _tags loops here, which is already a bit
> of a sticky wicket?

It'd need to use ${curtag:-email-addresses} to cover cases where a tag
isn't supplied by the calling function. I just think that the tag is the
right place for it. We could use the argument field as you suggested.
It's not really what that's meant for and we'd lose any existing value
in the argument field. That means you can't, for example, spot when you
have the -c flag to mutt. But the argument field is probably better than
nothing.

> It's entirely possible that there's some subtlety I'm missing.
> 
> On a more general note, though, it would appear that $curtag is rather
> under-utilized.  By a quick grep I count about 15 functions that use both
> _tags and zstyle without reference to $curtag.  _email_addresses is the
> only one that seems to use it as it was intended.

It really depends whether it is potentially useful to have different
settings for different tags or tag labels in each situation. It is
under-utilized, however.

Searching for uses of _tags and zstyle isn't necessarily helpful because
different settings for tag labels could also be useful. For example in
_pids, we could put _call_program within a tag loop. I've not tested
this but it should then be possible to do the following:

zstyle ':completion:*:processes' tag-order \
    'processes:-tty' 'processes:-mine' 'processes:-all'
zstyle ':completion:*:processes-tty' command ps
zstyle ':completion:*:processes-mine' command "ps -u $EUID"
zstyle ':completion:*:processes-all' command 'ps -e'

Then, when completing process IDs, _next_tags can be used to control
which processes are listed.

Oliver



This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-06-20 12:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20050527141638.GA9644@xpeerience.u-strasbg.fr>
     [not found] ` <7779.1117444705@trentino.groupinfra.com>
     [not found]   ` <20050530135757.GA12204@xpeerience.u-strasbg.fr>
     [not found]     ` <13199.1117464233@trentino.groupinfra.com>
     [not found]       ` <20050602123718.GA21218@xpeerience.u-strasbg.fr>
2005-06-06 16:42         ` can't run _email-mutt Oliver Kiddle
2005-06-19 17:09           ` curtag (Re: can't run _email-mutt) Bart Schaefer
2005-06-20 12:17             ` Oliver Kiddle

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).