zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-users@math.gatech.edu
Subject: Case insensitive completion (Re: zsh - new user with questions)
Date: Wed, 19 Aug 1998 10:53:43 -0700	[thread overview]
Message-ID: <980819105343.ZM11457@candle.brasslantern.com> (raw)
In-Reply-To: <C1256665.00522C7D.00@bavaria3.pc-plus.de>

On Aug 19,  5:09pm, Stephen Riehm wrote:
} Subject: Re: zsh - new user with questions
}
} All that is required is that all routines that compare file names need
} to convert both strings for comparison to lower (or upper) case before
} comparison.

Minor nit:  It can't be _all_ routines that compare file names, because
the files README ReadMe Readme readme and rEaDmE might all exist in the
same directory.  At some point you have to notice case to identify the
one you really mean.  Case-insenstive globbing is much more dangerous
than case-insensitive completion, particularly given multios (where e.g.
"echo foo > r*me" might clobber all five files).

In any case (pun intended), here's a bit of a hack to make the multicomp
function be case-insensitive in the ASCII set, including making `-' and
`_' interchangable.  It should be obvious how to add other mappings; for
example, to equate comma and period, append :gs/,/./:gs/./.,/

There might be a simpler way to achieve this, but short of using process
substitution I couldn't think of one.

Index: Functions/multicomp
===================================================================
--- multicomp	1998/06/01 17:08:43	1.1.1.1
+++ multicomp	1998/08/19 17:40:06
@@ -53,7 +53,17 @@
     else
       wild='*'
     fi
-    reply=(${sofar}"${head}${wild}${globdir}")
+
+    # Simulate case-insensitive globbing for ASCII characters
+    wild="[${(j(][))${(s())head:l}}]${wild}"	# :gs/a/[a]/ etc.
+    # The following could all be one expansion, but for readability:
+    wild=$wild:gs/a/aA/:gs/b/bB/:gs/c/cC/:gs/d/dD/:gs/e/eE/:gs/f/fF/
+    wild=$wild:gs/g/gG/:gs/h/hH/:gs/i/iI/:gs/j/jJ/:gs/k/kK/:gs/l/lL/
+    wild=$wild:gs/m/mM/:gs/n/nN/:gs/o/oO/:gs/p/pP/:gs/q/qQ/:gs/r/rR/
+    wild=$wild:gs/s/sS/:gs/t/tT/:gs/u/uU/:gs/v/vV/:gs/w/wW/:gs/x/xX/
+    wild=$wild:gs/y/yY/:gs/z/zZ/:gs/-/_/:gs/_/-_/
+
+    reply=(${sofar}"${wild}${globdir}")
     reply=(${~reply})
   fi
 

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


      parent reply	other threads:[~1998-08-19 18:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-19 15:09 zsh - new user with questions Stephen Riehm
1998-08-19 17:35 ` Goran Larsson
1998-08-19 19:18   ` Bart Schaefer
1998-08-19 19:58     ` Roland Jesse
1998-08-19 20:33       ` Sweth Chandramouli
1998-08-19 21:19         ` Roland Jesse
1998-08-20  9:47       ` Andrej Borsenkow
1998-08-19 17:53 ` Bart Schaefer [this message]

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=980819105343.ZM11457@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@math.gatech.edu \
    /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).