zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _most_recent_file
@ 2001-05-14 13:18 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2001-05-14 13:18 UTC (permalink / raw)
  To: Zsh hackers list

Just noticed this is bad about quoting, both with existing quoted
characters and inserting characters which need quoting.  Probably there
wasn't a way to fix this simply when I first wrote it.  Don't suppose
anyone else uses it anyway.

Index: Completion/Base/Widget/_most_recent_file
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_most_recent_file,v
retrieving revision 1.1
diff -u -r1.1 _most_recent_file
--- Completion/Base/Widget/_most_recent_file	2001/04/02 11:16:36	1.1
+++ Completion/Base/Widget/_most_recent_file	2001/05/14 13:17:09
@@ -1,22 +1,24 @@
 #compdef -k complete-word \C-xm
 
-# Complete the most recent file matching the pattern on the line so
-# far: globbing is active, i.e. *.txt will be expanded to the most recent
+# Complete the most recently modified file matching the pattern on the line
+# so far: globbing is active, i.e. *.txt will be expanded to the most recent
 # file ending in .txt
 #
 # With a prefix argument, select the Nth most recent matching file;
 # negative arguments work in the opposite direction, so for example
 # `Esc - \C-x m' gets you the oldest file.
-#
-# (`Most recent' means most recently modified.)
 
 local file tilde etilde
 if [[ $PREFIX = \~*/* ]]; then
   tilde=${PREFIX%%/*}
   etilde=${~tilde}
-  file=($~PREFIX*$~SUFFIX(om[${NUMERIC:-1}]N))
-  file=(${file/#$etilde/$tilde})
+  # PREFIX and SUFFIX have full command line quoting in, but we want
+  # any globbing characters which are quoted to stay quoted.
+  eval "file=($PREFIX*$SUFFIX(om[${NUMERIC:-1}]N))"
+  file=(${file/#$etilde})
+  file=($tilde${(q)^file})
 else
-  file=($~PREFIX*$~SUFFIX(om[${NUMERIC:-1}]N))
+  eval "file=($PREFIX*$SUFFIX(om[${NUMERIC:-1}]N))"
+  file=(${(q)file})
 fi
 (( $#file )) && compadd -U -i "$IPREFIX" -I "$ISUFFIX" -f -Q $file

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-05-14 13:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-14 13:18 PATCH: _most_recent_file Peter Stephenson

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).