about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--Completion/Unix/Command/_elinks2
-rw-r--r--Completion/Unix/Type/.distfiles1
-rwxr-xr-xCompletion/Unix/Type/_mime_types42
-rw-r--r--Completion/X/Command/.distfiles1
-rwxr-xr-xCompletion/X/Command/_kfmclient93
-rw-r--r--Doc/Zsh/contrib.yo2
-rw-r--r--Functions/MIME/pick-web-browser9
-rw-r--r--Functions/MIME/zsh-mime-setup24
9 files changed, 175 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index b51b03590..d3493d1bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2004-07-26  Peter Stephenson  <pws@csr.com>
 
+	* 20199: Completion/Unix/Command/_elinks,
+	Completion/Unix/Type/.distfiles, Completion/Unix/Type/_mime_types,
+	Completion/X/Command/.distfiles, Completion/X/Command/_kfmclient,
+	Doc/Zsh/contrib.yo, Functions/MIME/pick-web-browser,
+	Functions/MIME/zsh-mime-setup: add completion for MIME types
+	and kfmclient, use kfmclient to talk to konqueror and
+	improve mime-types and mailcap styles.
+
 	* 20198: Src/exec.c, Src/signals.c, Test/C03traps.ztst,
 	Test/Makefile.in, Test/ztst.zsh: EXIT traps were freed before
 	being run.  This isn't recommended by most programming text books.
diff --git a/Completion/Unix/Command/_elinks b/Completion/Unix/Command/_elinks
index 53e7b8ac8..615d9ba80 100644
--- a/Completion/Unix/Command/_elinks
+++ b/Completion/Unix/Command/_elinks
@@ -11,7 +11,7 @@ _arguments -C -A '-*' \
   '*-base-session[clone session with given ID]:ID number:' \
   '*-confdir[set config dir to given string]:configuration directory:_files -/' \
   '*-conffile[configuration file name]:configuration file:_files' \
-  '*-default-mime-type[MIME type to assume for documents]:MIME type:' \
+  '*-default-mime-type[MIME type to assume for documents]:MIME type:_mime_types' \
   '*-dump[write formatted version of given URL to stdout]::boolean:(0 1)' \
   '*-dump-charset[codepage to use with -dump]:codepage:' \
   '*-dump-width[width of document formatted with -dump]:width:' \
diff --git a/Completion/Unix/Type/.distfiles b/Completion/Unix/Type/.distfiles
index 5d4676bac..1392115dd 100644
--- a/Completion/Unix/Type/.distfiles
+++ b/Completion/Unix/Type/.distfiles
@@ -10,4 +10,5 @@ _groups              _perl_basepods       _signals             _users_on
 _hosts               _tar_archive         _time_zone
 _file_systems        _net_interfaces      _terminals           _locales
 _java_class          _services		  _email_addresses     _global_tags
+_mime_types
 '
diff --git a/Completion/Unix/Type/_mime_types b/Completion/Unix/Type/_mime_types
new file mode 100755
index 000000000..1a967501c
--- /dev/null
+++ b/Completion/Unix/Type/_mime_types
@@ -0,0 +1,42 @@
+#autoload
+
+local expl maintype
+local -a default_type_files type_files match mbegin mend
+integer ind
+
+default_type_files=(~/.mime.types /etc/mime.types)
+
+# This is the same style as used by zsh-mime-setup, with a different
+# context.
+if zstyle -a ":completion:${curcontext}:mime" mime-types type_files; then
+  while (( (ind = ${type_files[(I)+]}) > 0 )); do
+    type_files[$ind]=($default_type_files)
+  done
+else
+  type_files=($default_type_files)
+fi
+
+#
+# Handle two different mime type formats; the simple
+# format:
+#   application/x-pws-frobnicate psf pwsf
+# and the extended format
+#   type=application/x-pws-frobnicate \
+#   desc="PWS frobnicated widget" \
+#   exts="pwsf,psf"
+# which Netscape seems to like.
+#
+
+if [[ $PREFIX = (#b)([^/]##)/* ]]; then
+  # Search for subtype.
+  maintype=$match[1]
+  compset -p $(( ${#maintype} + 1 ))
+  _wanted mimesubtype expl 'MIME subtype' \
+      compadd -- $(sed -ne "s%^\(type=\|\)${maintype}/\([^ 	]*\).*$%\2%p" \
+      $type_files)
+else
+  # Search for main type.
+  _wanted mimetype expl 'MIME type' \
+    compadd -S/ -- $(sed -ne "s/^type=//" \
+      -e "s%^\(${PREFIX:-[a-z]}[^=\"]*\)/.*$%\1%p" $type_files)
+fi
diff --git a/Completion/X/Command/.distfiles b/Completion/X/Command/.distfiles
index 391411168..d188982b7 100644
--- a/Completion/X/Command/.distfiles
+++ b/Completion/X/Command/.distfiles
@@ -3,4 +3,5 @@ DISTFILES_SRC='
 _gv        _netscape  _xauth     _xfig      _mozilla   _xterm     _xwit
 _nedit     _vnc       _x_utils   _xdvi      _xmodmap   _xset      _xv
 _acroread  _dcop      _gqview    _xloadimage _mplayer
+_kfmclient
 '
diff --git a/Completion/X/Command/_kfmclient b/Completion/X/Command/_kfmclient
new file mode 100755
index 000000000..f83e51779
--- /dev/null
+++ b/Completion/X/Command/_kfmclient
@@ -0,0 +1,93 @@
+#compdef kfmclient
+
+local expl
+local -a context state line
+typeset -A opt_args
+
+_arguments \
+  '--help[show help message]' \
+  '--help-qt[show Qt specific options]' \
+  '--help-kde[show KDE specific options]' \
+  '--help-all[show all options]' \
+  '--author[show author information]' \
+  '-v[show version information]' \
+  '--version[show version information]' \
+  '--license[show license information]' \
+  '--commands[show available commands]' \
+  '--display=:X display:_x_display' \
+  '--session=:session id for restoring application: ' \
+  '--cmap[use private colormap (8-bit display)]' \
+  '--ncols=:limit on number of colors (8-bit display): ' \
+  '--nograb[never grab mouse or keyboard]' \
+  '--dograb[override nograb in debugger]' \
+  '--sync[switch to synchronous mode when debugging]' \
+  '--fn=:font name:_x_font' \
+  '--font=:font name:_x_font' \
+  '--bg=:background color:_x_color' \
+  '--background=:background color:_x_color' \
+  '--fg=:foreground color:_x_color' \
+  '--foreround=:foreground color:_x_color' \
+  '--btn=:button color:_x_color' \
+  '--button=:button color:_x_color' \
+  '--name=:application name: ' \
+  '--title=:application title (caption): ' \
+  '--visual=:specify visual:_x_visual' \
+  '--inputstyle:X input method:(onthespot overthespot offthespot root)' \
+  '--im:X Input Method server: ' \
+  '--noxim[disable X Input Method]' \
+  '--reverse[reverse widget layout]' \
+  '--caption=:name in titlebar: ' \
+  '--icon=:application icon: ' \
+  '--miniicon=:icon in titlebar: ' \
+  '--config=:configuration  file:_files' \
+  '--dcopserver=:DCOP server: ' \
+  '--nocrashhandler[disable crash handler, allow core dumps]' \
+  '--waitforwm[Wait for a WM_NET compatible window manager]' \
+  '--style=:GUI style for application: ' \
+  '--geometry=:client window geometry:_x_geometry' \
+  '1:client command:(openURL openProfile openProperties exec move
+download copy sortDesktop configure configureDesktop)' \
+  '2::args:->firstarg' \
+  '3::args:->secondarg'  &&  return 0
+
+[[ $state = *arg ]] || return 1
+
+# Argument to previous command.
+
+print $line >/tmp/tmp.out
+
+case $line[1] in
+  (openURL)
+  if [[ $state = secondarg ]]; then
+    _mime_types && return 0
+  elif [[ $state = firstarg ]]; then
+    _urls && return 0
+  fi
+  ;;
+
+  (openProfile)
+  if [[ $state = secondarg ]]; then
+    _urls && return 0
+  elif [[ $state = firstarg ]]; then
+    _wanted profile expl 'Konqueror profile' \
+      compadd -- ~/.kde/share/apps/konqueror/profiles/*(:t) && return 0
+  fi
+  ;;
+
+  (exec)
+  if [[ $state = secondarg ]]; then
+    # TODO: could probe inside Desktop files.
+    _message "KDE binding" && return 0
+  elif [[ $state = firstarg ]]; then
+    _urls && return 0
+  fi
+  ;;
+
+  (move|download|openProperties)
+  if [[ $state = firstarg ]]; then
+      _urls && return 0
+  fi
+  ;;
+esac
+
+_message "no more arguments"
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 7a39980ac..d205cce93 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -1045,11 +1045,13 @@ item(mime-types)(
 A list of files in the format of tt(~/.mime.types) and
 tt(/etc/mime.types) to be read during setup, replacing the default list
 which consists of those two files.  The context is tt(:mime:).
+A tt(PLUS()) in the list will be replaced by the default files.
 )
 item(mailcap)(
 A list of files in the format of tt(~/.mailcap) and
 tt(/etc/mailcap) to be read during setup, replacing the default list
 which consists of those two files.  The context is tt(:mime:).
+A tt(PLUS()) in the list will be replaced by the default files.
 )
 item(handler)(
 Specifies a handler for a suffix; the suffix is given by the context as
diff --git a/Functions/MIME/pick-web-browser b/Functions/MIME/pick-web-browser
index 6f4650c12..1a73b4de7 100644
--- a/Functions/MIME/pick-web-browser
+++ b/Functions/MIME/pick-web-browser
@@ -82,8 +82,13 @@ if [[ -n $DISPLAY ]]; then
   for browser in $xbrowsers; do
     if [[ $windows[(I)(#i)$browser] -ne 0 ]]; then
       if [[ $browser = konqueror ]]; then
-	# I'm sure there's documentation for this somewhere...
-	dcop $(dcop|grep konqueror) default openBrowserWindow $url
+	# kfmclient is less hairy and better supported than direct
+	# use of dcop.  Run kfmclient --commands
+	# for more information.  Note that as konqueror is a fully
+	# featured file manager, this will actually do complete
+	# MIME handling, not just web pages.
+	kfmclient openURL $url ||
+	  dcop $(dcop|grep konqueror) default openBrowserWindow $url
       else
 	# Mozilla bells and whistles are described at:
 	# http://www.mozilla.org/unix/remote.html
diff --git a/Functions/MIME/zsh-mime-setup b/Functions/MIME/zsh-mime-setup
index fee3237f7..d0149ba29 100644
--- a/Functions/MIME/zsh-mime-setup
+++ b/Functions/MIME/zsh-mime-setup
@@ -53,14 +53,30 @@ fi
 # to handlers and their flags.
 typeset -A suffix_type_map type_handler_map type_flags_map
 
+local -a default_type_files default_cap_files
 local -a type_files cap_files array match mbegin mend
 local file line type suffix exts elt flags line2
+integer ind
+
+default_type_files=(~/.mime.types /etc/mime.types)
+default_cap_files=(~/.mailcap /etc/mailcap)
 
 # Customizable list of files to examine.
-zstyle -a :mime: mime-types type_files ||
-  type_files=(~/.mime.types /etc/mime.types)
-zstyle -a :mime: mailcap cap_files ||
-  cap_files=(~/.mailcap /etc/mailcap)
+if zstyle -a :mime: mime-types type_files; then
+  while (( (ind = ${type_files[(I)+]}) > 0 )); do
+    type_files[$ind]=($default_type_files)
+  done
+else
+  type_files=($default_type_files)
+fi
+
+if zstyle -a :mime: mailcap cap_files; then
+  while (( (ind = ${cap_files[(I)+]}) > 0 )); do
+    cap_files[$ind]=($default_cap_files)
+  done
+else
+  cap_files=($default_cap_files)
+fi
 
 {
   mime-setup-add-type() {