From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "David J. Biesack" Newsgroups: gmane.emacs.bugs Subject: bug#4902: 23.1; directory-abbrev-alist is not handled early enough Date: Wed, 11 Nov 2009 14:41:40 -0500 Message-ID: References: Reply-To: "David J. Biesack" , 4902@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1257968865 21297 80.91.229.12 (11 Nov 2009 19:47:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Nov 2009 19:47:45 +0000 (UTC) Cc: 4902@emacsbugs.donarmstrong.com To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 11 20:47:38 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 1N8JAC-00089m-9c for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Nov 2009 20:47:32 +0100 Original-Received: from localhost ([127.0.0.1]:54439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8JAB-0000tX-RZ for geb-bug-gnu-emacs@m.gmane.org; Wed, 11 Nov 2009 14:47:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8JA7-0000sq-Pr for bug-gnu-emacs@gnu.org; Wed, 11 Nov 2009 14:47:27 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8JA2-0000rG-Un for bug-gnu-emacs@gnu.org; Wed, 11 Nov 2009 14:47:27 -0500 Original-Received: from [199.232.76.173] (port=35000 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8JA2-0000r4-Ny for bug-gnu-emacs@gnu.org; Wed, 11 Nov 2009 14:47:22 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:44422) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N8JA1-00081W-6z for bug-gnu-emacs@gnu.org; Wed, 11 Nov 2009 14:47:21 -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 nABJlI5k018089; Wed, 11 Nov 2009 11:47:18 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nABJj4eM017747; Wed, 11 Nov 2009 11:45:04 -0800 Resent-Date: Wed, 11 Nov 2009 11:45:04 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: "David J. Biesack" Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Wed, 11 Nov 2009 19:45:03 +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.125796850717519 (code B ref 4902); Wed, 11 Nov 2009 19:45:03 +0000 Original-Received: (at 4902) by emacsbugs.donarmstrong.com; 11 Nov 2009 19:41:47 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from mercav15.na.sas.com (mercav15.na.sas.com [149.173.6.149]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nABJfjpn017515 for <4902@emacsbugs.donarmstrong.com>; Wed, 11 Nov 2009 11:41:46 -0800 X-TM-IMSS-Message-ID: <25c9e5560000fc19@mercav15.na.sas.com> Original-Received: from d16922.us.sas.com ([10.40.12.239]) by mercav15.na.sas.com ([10.19.9.223]) with ESMTP (TREND IMSS SMTP Service 7.0) id 25c9e5560000fc19 ; Wed, 11 Nov 2009 14:41:42 -0500 In-reply-to: (message from Stefan Monnier on Wed, 11 Nov 2009 09:52:19 -0500) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Wed, 11 Nov 2009 14:47: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:32548 Archived-At: Eli and Stefan; Thanks for you assistance. I really appreciate the time you've spent investigating this. Obviously, the file naming structure is far beyond my control and not something I can or want to change (it would break far too many tools and processes). Suffice it to say, it's something I have to live with. I was able to achieve what I want with (defadvice find-file-noselect (before find-file-noselect-apply-abbreviations (filename &optional nowarn rawfile wildcards) activate) ;; normalize the file via (customize-variable 'directory-abbrev-alist) ;; *before* find-file-noselect calls (expand-file-name filename) ;; which puts C: at the front of paths. (ad-set-arg 0 (abbreviate-file-name filename)) ) and calling abbreviate-file-name in a couple other functions I use (my own version of find-file-at-point etc.) At least, so far it is working as I expect. I was aware of file-name-handler-alist from looking through cygwin-mount and had considered that but it seemed complicated. I'll save the following suggestion and install it if my own customizations prove insufficient. djb > From: Stefan Monnier > CC: <4902@emacsbugs.donarmstrong.com> > Date: Wed, 11 Nov 2009 09:52:19 -0500 > > > 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)) > > > -- David J. Biesack, SAS SAS Campus Dr. Cary, NC 27513 www.sas.com (919) 531-7771