From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: find-file-noselect needs save-match-data Date: Fri, 15 Jun 2007 10:20:49 -0400 Message-ID: References: <87k5ueq23m.fsf@kfs-lx.testafd.dk> <87myz8c10t.fsf@jurta.org> <18030.3441.204697.244518@rgrjr.dyndns.org> <87zm3515r4.fsf@jurta.org> <85k5u8x2gm.fsf@lola.goethe.zz> <87r6og6czf.fsf@catnip.gol.com> <85bqfkx0i5.fsf@lola.goethe.zz> <87odjjzaoz.fsf@catnip.gol.com> <46723234.2090704@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1181917273 23933 80.91.229.12 (15 Jun 2007 14:21:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 15 Jun 2007 14:21:13 +0000 (UTC) Cc: rms@gnu.org, miles.bader@necel.com, schwab@suse.de, emacs-devel@gnu.org, juri@jurta.org, Miles Bader To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 15 16:21:02 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HzCfd-0000Yu-P0 for ged-emacs-devel@m.gmane.org; Fri, 15 Jun 2007 16:21:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HzCfd-0006LN-6y for ged-emacs-devel@m.gmane.org; Fri, 15 Jun 2007 10:21:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HzCfZ-0006LI-Co for emacs-devel@gnu.org; Fri, 15 Jun 2007 10:20:57 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HzCfY-0006L6-4M for emacs-devel@gnu.org; Fri, 15 Jun 2007 10:20:57 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HzCfY-0006L3-0W for emacs-devel@gnu.org; Fri, 15 Jun 2007 10:20:56 -0400 Original-Received: from tomts32.bellnexxia.net ([209.226.175.106] helo=tomts32-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HzCfV-0004kb-Uw; Fri, 15 Jun 2007 10:20:54 -0400 Original-Received: from pastel.home ([70.55.143.156]) by tomts20-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070615142049.DDLH1637.tomts20-srv.bellnexxia.net@pastel.home>; Fri, 15 Jun 2007 10:20:49 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 7738C7F83; Fri, 15 Jun 2007 10:20:49 -0400 (EDT) In-Reply-To: <46723234.2090704@gmx.at> (martin rudalics's message of "Fri\, 15 Jun 2007 08\:31\:16 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-detected-kernel: Solaris 8 (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:72955 Archived-At: >> Actually, I'd even argue against any such new function, > How about adding another optional argument then? Same deal: you're trying to solve a non-problem. >> on the grounds that it's solving a non-problem, i.e. it will just add new >> functions, new code, new complexity for no real benefit. > Consider `abbreviate-file-name'. It has the following construct: > (if (and (string-match abbreviated-home-dir filename) > ;; If the home dir is just /, don't change it. > (not (and (= (match-end 0) 1) > (= (aref filename 0) ?/))) > ;; MS-DOS root directories can come with a drive letter; > ;; Novell Netware allows drive letters beyond `Z:'. > (not (and (or (eq system-type 'ms-dos) > (eq system-type 'cygwin) > (eq system-type 'windows-nt)) > (save-match-data > (string-match "^[a-zA-`]:/$" filename))))) > (setq filename > (concat "~" > (match-string 1 filename) > (substring filename (match-end 0))))) Looks fine to me. I don't find it particularly unreadable and its efficiency seems to be perfectly adequate. Stefan PS: By the way, the above code looks odd. The comment seems to imply that the MS-DOS check just reproduces the preceding / check, but it's not the case: the / check makes sure that if HOME is / then /a/b will not be changed to ~/a/b, whereas the MS-DOS check will only prevent changing A:/ to ~ but it will not prevent changing A:/b/c to ~/b/c. I noticed this when I considered replacing those two checks with ;; If the home dir is just /, don't change it. ;; Same thing for A:/ under FreeDOS. (let ((home (directory-file-name (match-string 0)))) (equal home (file-name-directory home)))