[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#174018: elm-me+: [patch] Bash completion of elm folders



Package: elm-me+
Version: 2.4pl25ME+99f-1
Severity: wishlist
Tags: patch

Following is a patch to enable completion of elm folders. It uses only
"Priority: Required" debian packages [bash, coreutils, grep, sed].  For
example:

$ elm -f =de<TAB><TAB>
debian-boot debian-mentors
$ elm -f =debian-

I currently have this installed as "/etc/bash_completion.d/elm", but
probably should be installed as '.../elm-me+' by the package.

Enjoy,
Joe Nahmias
joe@nahmias.net


===== Begin: /etc/bash_completion.d/elm-me+ =====
#!/bin/bash
# elm(1) mail folder completion.  See debian package "elm-me+".
# Written by Joe Nahmias <joe@nahmias.net>.

have elm &&
_elm()
{
	local cur debug elmrc maildir temp

#	debug=true			# Uncomment to print debug messages.
	elmrc=$HOME/.elm/elmrc
	COMPREPLY=()
	cur=${COMP_WORDS[COMP_CWORD]}

	# Are we looking for a mail folder (prefixed by equals '=')?
	if [[ "$cur" == \=* ]]; then
		[ -z $debug ] || echo "\nLooking for a folder in the maildir."

		# Determine elm's Mail Folder directory (maildir).
		maildir=$(cat $elmrc | grep -v ^# | grep maildir | tail -1)
		if [ -z "$maildir" ]; then
			# using default maildir
			[ -z $debug ] || echo "maildir setting not found in elmrc."
			maildir=$HOME/Mail
		else
			# parse maildir entry from elmrc
			[ -z $debug ] || echo "Found maildir setting in elmrc: '$maildir'."
			maildir=$(echo "$maildir" | sed -e 's/.*=[^\/\w]*//')
		fi
		[ -z $debug ] || echo "Using maildir='$maildir'."

		# Match any file in $maildir begining with "$cur".
		cur=$maildir/${cur:1}		# Chop off leading equals.
		_filedir
		[ -z $debug ] || echo "filedir found: '${COMPREPLY[@]}'."

		# String the leading $HOME/Mail on the matches.
		temp=(${COMPREPLY[@]})
		COMPREPLY=()
		for i in ${temp[@]}
		do
			COMPREPLY=(${COMPREPLY[@]} $(basename $i))
		done
		[ -z $debug ] || echo "Using COMPREPLY='${COMPREPLY[@]}'."

	fi

	return 0
}
[ "$have" ] && complete -F _elm $default elm
===== End: /etc/bash_completion.d/elm-me+ =====

-- System Information
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux a750.nahmias.net 2.4.19 #1 Sat Oct 19 23:55:05 EDT 2002 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages elm-me+ depends on:
ii  libc6                    2.2.5-14.3      GNU C Library: Shared libraries an
ii  libncurses5              5.2.20020112a-8 Shared libraries for terminal hand
ii  libssl0.9.6              0.9.6g-6        SSL shared libraries
di  postfix [mail-transport- 1.1.11.0-3      A high-performance mail transport 




Reply to: