From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#4902: 23.1; directory-abbrev-alist is not handled early enough Date: Wed, 11 Nov 2009 09:52:19 -0500 Message-ID: References: Reply-To: Stefan Monnier , 4902@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1257953297 28460 80.91.229.12 (11 Nov 2009 15:28:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Nov 2009 15:28:17 +0000 (UTC) Cc: 4902@emacsbugs.donarmstrong.com To: "David J. Biesack" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 11 16:28:10 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N8F7B-0006S2-Hj for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Nov 2009 16:28:10 +0100 Original-Received: from localhost ([127.0.0.1]:53686 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8F7A-0003Xk-UX for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Nov 2009 10:28:09 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8EnB-0004XU-3k for bug-gnu-emacs@gnu.org; Wed, 11 Nov 2009 10:07:29 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8En4-0004ST-Tw for bug-gnu-emacs@gnu.org; Wed, 11 Nov 2009 10:07:27 -0500 Original-Received: from [199.232.76.173] (port=48181 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8En4-0004SN-KD for bug-gnu-emacs@gnu.org; Wed, 11 Nov 2009 10:07:22 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:44628) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N8En3-0001Xt-EY for bug-gnu-emacs@gnu.org; Wed, 11 Nov 2009 10:07:22 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nABF7ITh015929; Wed, 11 Nov 2009 07:07:18 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nABF058H014241; Wed, 11 Nov 2009 07:00:05 -0800 Resent-Date: Wed, 11 Nov 2009 07:00:05 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Stefan Monnier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Wed, 11 Nov 2009 15:00:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4902 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 4902-submit@emacsbugs.donarmstrong.com id=B4902.125795114713481 (code B ref 4902); Wed, 11 Nov 2009 15:00:04 +0000 Original-Received: (at 4902) by emacsbugs.donarmstrong.com; 11 Nov 2009 14:52:27 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from ironport2-out.pppoe.ca (ironport2-out.teksavvy.com [206.248.154.181]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nABEqPk2013458 for <4902@emacsbugs.donarmstrong.com>; Wed, 11 Nov 2009 06:52:27 -0800 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsEAGBe+kpMCpsp/2dsb2JhbACBT9thhDwEgWuHOA X-IronPort-AV: E=Sophos;i="4.44,723,1249272000"; d="scan'208";a="49099650" Original-Received: from 76-10-155-41.dsl.teksavvy.com (HELO pastel.home) ([76.10.155.41]) by ironport2-out.pppoe.ca with ESMTP; 11 Nov 2009 09:52:20 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id EED9F8373; Wed, 11 Nov 2009 09:52:19 -0500 (EST) In-Reply-To: (David J. Biesack's message of "Tue, 10 Nov 2009 16:29:36 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Wed, 11 Nov 2009 10:07:27 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:32539 Archived-At: > Obviously, there are too many different names for the same file, > and I want Emacs to normalize all files to a canonical > form; i.e. all the variations of my network home should > be normalized to u:/ and so forth. > directory-abbrev-alist: > '(("^//dntsrc/u/sasdjb" . "u:") > ("^/u/sasdjb" . "u:") > ("^//sashq/root/u/sasdjb" . "u:") > ("^/nfs/sanyo/vol/vol2/u22/sasdjb" . "u:/") > ("^//sashq/root/u/sasdjb" . "u:") > ("^/sas/" . "//dntsrc/sas/") > ("^/sasgen" . "//dntsrc/sasgen/")) The way I see it, the problem really is in the way you organize and use your naming structure. So "the right solution" would be a combination of discipline, conventions, and symlinks to sort out this mess and make sure that you see much fewer variations of filenames and that all the ones you see work everywhere (via symlinks, for example). Now, I understand this may not be practically feasible for you, but I think that changing Emacs to accomodate this particular situation is a bit hard to justify. OTOH, Emacs does provide enough hooks already for you to be able to make it work, I think. The hook you want is file-name-handler-alist. The only problem with it, is that it's very powerful and quite a bit trickier to use than directory-abbrev-alist. You could try the code below (guaranteed 100% untested). Stefan (defvar djb-filemess-remappings '(("\\`/\\(/dntsrc/u\\|u\\|/sashq/root/u\\|nfs/sanyo/vol/vol2/u22\\)/sasdjb" . "u:") ("\\`/\\(sas\\(gen\\)?\\)/" . "//dntsrc/\\1/"))) (defun djb-filemess-run-real-handler (operation args) (let ((inhibit-file-name-handlers (cons 'djb-filemess-handler (and (eq inhibit-file-name-operation operation) inhibit-file-name-handlers))) (inhibit-file-name-operation operation)) (apply operation args)))) (defun djb-filemess-handler (operation &rest args) (let ((fn (get operation 'djb-filemess-handler))) (if fn (funcall fn operation args) (djb-filemess-run-real-handler operation args)))) (defun djb-filemess-remap-1 (operation args) (let ((file (car args)) (remappings djb-filemess-remappings) newfile) (while (and (null newfile) remappings) (if (string-match (caar remappings) file) (setq newfile (replace-match (cdar remappings) t nil file)) (setq remappings (cdr remappings)))) (djb-filemess-run-real-handler operation (cons (or newfile file) (cdr args))))) (put 'expand-file-name 'djb-filemess-handler 'djb-filemess-remap-1) (put 'substitute-in-file-name 'djb-filemess-handler 'djb-filemess-remap-1) (dolist (remapping djb-filemess-remappings) (push (cons (car remapping) 'djb-filemess-handler) file-name-handler-alist))