Add missing file for vi completions that is needed to complete files selectively based on mime types. Also use it to improve emacs completions, in order to balance my GNU karma.

darcs-hash:20070222214555-ac50b-60aa6a3e4cea77451c51d40d2a574d145f3de4fe.gz
This commit is contained in:
axel 2007-02-23 07:45:55 +10:00
parent 58755fc579
commit e50f43416b
3 changed files with 35 additions and 1 deletions

View file

@ -1,6 +1,10 @@
# #
# These completions are uncomplete # These completions are uncomplete
# #
# Primarily complete text files
complete -c emacs -x -a "(__fish_complete_mime 'text/*')"
complete -c emacs -s q --description "Do not load init files" complete -c emacs -s q --description "Do not load init files"
complete -c emacs -s u --description "Load users init file" -xa "(__fish_complete_users)" complete -c emacs -s u --description "Load users init file" -xa "(__fish_complete_users)"
complete -c emacs -s t --description "Use file as terminal" -r complete -c emacs -s t --description "Use file as terminal" -r

View file

@ -0,0 +1,30 @@
function __fish_complete_mime -d "Complete using text files"
# Find all possible file completions
set -l all
set -l comp (commandline -ct)
set -l base (echo $comp | sed -e 's/\.[a-zA-Z0-9]*$//')
set -l mimetype $argv[1]
eval "set all $base*"
# Select text files only
set -l files (__fish_filter_mime $mimetype $all)
# Get descriptions for files
set desc (mimedb -d $files)
# Format completions and descriptions
set -l res
for i in (seq (count $files))
set res $res $files[$i]\t$desc[$i]
end
if test $res[1]
printf "%s\n" $res
end
# Also do directory completion, since there might be files
# with the correct suffix in a subdirectory
__fish_complete_directories $comp
end

View file

@ -7,7 +7,7 @@ function __fish_complete_vi -d "Compleletions for vi and its aliases"
set -l cmds -c $argv set -l cmds -c $argv
complete $cmds -x -a "(__fish_complete_text)" complete $cmds -x -a "(__fish_complete_mime 'text/*')"
# vim # vim
if test -n "$is_vim" if test -n "$is_vim"