zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh-users List <zsh-users@sunsite.dk>
Subject: Re: Case-insensitive completion
Date: Tue, 16 Sep 2003 17:03:54 +0000	[thread overview]
Message-ID: <1030916170354.ZM30176@candle.brasslantern.com> (raw)
In-Reply-To: <20030915190817.GA582@strindberg.student.uu.se>

On Sep 15,  9:08pm, Jesper Holmberg wrote:
} Subject: Re: Case-insensitive completion
}
} aac.txt aAa.txt Aaa.txt aAb.txt
} 
} If I want to complete for "Aaa.txt", it works well, I just put capital "A"
} and hit tab, and since the matching is only one-way, the completer knows
} that I really want a capital A, and gives me Aaa.txt.
} 
} If, on the other hand, I wanted aac.txt, hitting "aa" would not really
} help me, since "aAa.txt", "Aaa.txt" and "aAb.txt" would all be proposed
} before my aac.txt. I am thus looking for an easy way to specify that 
} *this time* I really want to match on literally "aa".
} 
} Perhaps what I want is unachievable, but has anyone solved this in a smart
} way?

Normally the way to do that would be to use different keybindings for
"complete case-insensitively" vs. "complete case-sensitively" and tell
zsh your preference by which of them you invoke.

Start with zstyles something like this:

  zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
  zstyle ':completion:*:case-sensitive:*' matcher-list ''
  zstyle ':completion:*' completer _expand _complete _ignored

Then, in a file (name doesn't matter much) somewhere in the path where
compinit looks for completion functions, you put:

---- 8< ---- snip ---- 8< ----
#compdef -k complete-word \C-xI
_main_complete _expand _complete:case-sensitive _ignored
---- 8< ---- snip ---- 8< ----

Replace \C-xI (control x shift i) with whatever keybinding you want to
have attached to case-sensitive completion.

You could get a little fancier with the function and avoid hardwiring
the list of completers by copying some of the code from _main_complete
to get the matcher-list context, then modify that list of matchers to
attach :case-sensitive where needed, before calling _main_complete.

Warning, I didn't actually test any of the above.


  reply	other threads:[~2003-09-16 17:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-14 10:30 Jesper Holmberg
2003-09-14 18:58 ` Bart Schaefer
2003-09-15 19:08   ` Jesper Holmberg
2003-09-16 17:03     ` Bart Schaefer [this message]
2003-09-17  7:30       ` Oliver Kiddle
2003-09-17 14:36         ` Bart Schaefer
2003-09-16 10:09   ` Oliver Kiddle
2003-09-16 11:59     ` Peter Stephenson
2003-09-16 12:17       ` Oliver Kiddle
2003-09-16 12:22         ` Jesper Holmberg
2003-09-17  7:40 ` Oliver Kiddle
2003-09-17 14:43   ` Bart Schaefer
2003-09-17 15:15     ` Oliver Kiddle
2003-09-18 10:26       ` Jesper Holmberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1030916170354.ZM30176@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).