GNU bug report logs - #4902
23.1; directory-abbrev-alist is not handled early enough

Previous Next

Package: emacs;

Reported by: David Biesack <David.Biesack <at> sas.com>

Date: Tue, 10 Nov 2009 18:00:04 UTC

Severity: wishlist

Tags: wontfix

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 4902 in the body.
You can then email your comments to 4902 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4902; Package emacs. (Tue, 10 Nov 2009 18:00:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Biesack <David.Biesack <at> sas.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 10 Nov 2009 18:00:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: David Biesack <David.Biesack <at> sas.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: 23.1; directory-abbrev-alist is not handled early enough
Date: Tue, 10 Nov 2009 12:54:06 -0500
Start emacs -q on a Windows system

In *scratch* buffer, evaluate

(setq directory-abbrev-alist '(("^/mount/" . "//uncpath/mount/")))

Even after setting this value, it is not honored on Windows.
Lower level functions appear to ignore directory-abbrev-alist,
so find-file and find-file-noselect etc. end up with "true" filenames that
contain drive letters:

(file-truename "/mount/somefile.x")
=> "c:/mount/somefile.x"

(expand-file-name "/mount/somefile.x")
=> "c:/mount/somefile.x"

(c:/mount does not exist, but //uncpath/mount/ does)



In GNU Emacs 23.1.1 (i386-mingw-nt5.1.2600)
 of 2009-07-30 on SOFT-MJASON
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<help-echo> <help-echo> <help-echo> <down-mouse-1>
<mouse-1> C-x b <return> C-y C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-e M-x e v a - <backspace> l - p r i SPC
SPC <return> q <down-mouse-1> <mouse-1> <down-mouse-1>
<mouse-1> C-j SPC q SPC SPC SPC ( C-b ' C-n C-b <backspace>
SPC SPC SPC C-n C-n C-p C-a SPC SPC C-e ) M-x e v a
l - p r SPC <return> C-p C-k C-p C-e M-x e v a l -
p r SPC SPC SPC <return> C-n <down-mouse-1> <mouse-1>
C-x h C-w <down-mouse-1> <mouse-1> C-y C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-e M-x e v a l - c SPC SPC
SPC <return> C-n C-n C-n C-a C-k C-p C-e M-x e v a
l - p r SPC <return> C-n C-k C-k C-e M-x e v a l -
p r SPC SPC <return> C-k C-k C-k C-k C-k C-SPC C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-w M-x r e p o
r t - e SPC SPC SPC <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
Entering debugger...
Back to top level.
Entering debugger...
Back to top level.





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4902; Package emacs. (Tue, 10 Nov 2009 19:45:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 10 Nov 2009 19:45:05 GMT) Full text and rfc822 format available.

Message #10 received at 4902 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: David Biesack <David.Biesack <at> sas.com>
Cc: 4902 <at> debbugs.gnu.org
Subject: Re: bug#4902: 23.1; directory-abbrev-alist is not handled early enough
Date: Tue, 10 Nov 2009 14:35:54 -0500
> (setq directory-abbrev-alist '(("^/mount/" . "//uncpath/mount/")))

> Even after setting this value, it is not honored on Windows.
> Lower level functions appear to ignore directory-abbrev-alist,
> so find-file and find-file-noselect etc. end up with "true" filenames that
> contain drive letters:

> (file-truename "/mount/somefile.x")
> => "c:/mount/somefile.x"

file-truename does not use directory-abbrev-alist.
Only abbreviate-file-name does.


        Stefan



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4902; Package emacs. (Tue, 10 Nov 2009 20:00:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to "David J. Biesack" <David.Biesack <at> sas.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 10 Nov 2009 20:00:04 GMT) Full text and rfc822 format available.

Message #15 received at 4902 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "David J. Biesack" <David.Biesack <at> sas.com>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 4902 <at> debbugs.gnu.org
Subject: Re: bug#4902: 23.1; directory-abbrev-alist is not handled early enough
Date: Tue, 10 Nov 2009 14:52:11 -0500
> From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
> CC: <4902 <at> emacsbugs.donarmstrong.com>
> Date: Tue, 10 Nov 2009 14:35:54 -0500
> 
> > (setq directory-abbrev-alist '(("^/mount/" . "//uncpath/mount/")))
> 
> > Even after setting this value, it is not honored on Windows.
> > Lower level functions appear to ignore directory-abbrev-alist,
> > so find-file and find-file-noselect etc. end up with "true" filenames that
> > contain drive letters:
> 
> > (file-truename "/mount/somefile.x")
> > => "c:/mount/somefile.x"
> 
> file-truename does not use directory-abbrev-alist.
> Only abbreviate-file-name does.

Perhaps that is why it is a bug :-)

For example, if the path /mount/somefile.x shows up in RMAIL
or in a source file, I want to do find-file-at-point 
on that path. When I do, Emacs tries to open c:/mount/somefile.x
instead. 

In other words, I does not matter what low level function
uses directory-abbrev-alist and which don't, but the net
effect is find-file-at-point and other functions
(filemenu http://www.eskimo.com/~seldon/filemenu.el)
which use find-file or find-file-noselect do *not*
use directory-abbrev-alist when the doc string
implies (to me) that they should.

My hack workaround is to add a new hook to
find-file-not-found-hooks which should not be necessary.

-- 
David J. Biesack, SAS
SAS Campus Dr. Cary, NC 27513
www.sas.com    (919) 531-7771



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4902; Package emacs. (Tue, 10 Nov 2009 21:10:13 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 10 Nov 2009 21:10:13 GMT) Full text and rfc822 format available.

Message #20 received at 4902 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: "David J. Biesack" <David.Biesack <at> sas.com>
Cc: 4902 <at> debbugs.gnu.org
Subject: Re: bug#4902: 23.1; directory-abbrev-alist is not handled early enough
Date: Tue, 10 Nov 2009 16:02:26 -0500
> For example, if the path /mount/somefile.x shows up in RMAIL
> or in a source file, I want to do find-file-at-point 
> on that path. When I do, Emacs tries to open c:/mount/somefile.x
> instead.

As the docstring of directory-abbrev-alist says:

   FROM and TO should be equivalent names, which refer to the
   same directory.

So the feature you want is not the feature provided by
directory-abbrev-alist :-(

Maybe we could change the code so as to expand the scope of
directory-abbrev-alist to include your situation, but I'm not actually
sure that's a good idea, because it doesn't seem clear exactly when that
rewrite should take place.

Maybe if you give us a bit more context to your problem, we can come up
with a better solution.
For starters explain to us: if the system doesn't have a "/mount"
directory, why does it show up in source files, email, and filemenu?


        Stefan



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4902; Package emacs. (Tue, 10 Nov 2009 21:35:16 GMT) Full text and rfc822 format available.

Acknowledgement sent to "David J. Biesack" <David.Biesack <at> sas.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 10 Nov 2009 21:35:16 GMT) Full text and rfc822 format available.

Message #25 received at 4902 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "David J. Biesack" <David.Biesack <at> sas.com>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 4902 <at> debbugs.gnu.org
Subject: Re: bug#4902: 23.1; directory-abbrev-alist is not handled early enough
Date: Tue, 10 Nov 2009 16:29:36 -0500
> From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
> CC: <4902 <at> emacsbugs.donarmstrong.com>
> Date: Tue, 10 Nov 2009 16:02:26 -0500
> 
> > For example, if the path /mount/somefile.x shows up in RMAIL
> > or in a source file, I want to do find-file-at-point 
> > on that path. When I do, Emacs tries to open c:/mount/somefile.x
> > instead.
> 
> As the docstring of directory-abbrev-alist says:
> 
>    FROM and TO should be equivalent names, which refer to the
>    same directory.
>
> So the feature you want is not the feature provided by
> directory-abbrev-alist :-(

:-(
 
> Maybe we could change the code so as to expand the scope of
> directory-abbrev-alist to include your situation, but I'm not actually
> sure that's a good idea, because it doesn't seem clear exactly when that
> rewrite should take place.
> 
> Maybe if you give us a bit more context to your problem, we can come up
> with a better solution.
> For starters explain to us: if the system doesn't have a "/mount"
> directory, why does it show up in source files, email, and filemenu?

Sure, here is my context.

Our source code, doc, tools, etc is stored on netapps.  We split
development between Linux and Windows. For the most part, source
filenames are passed around or mentioned in doc or email reports etc. using Unix
paths: /sas/dev/mva-v930/tkacl for example. On Windows, these
paths are available via Samba and UNC paths etc. as //dntsrc/sas/dev/mva-v930/tkacl .
For example, we run builds from Windows but they run remotely on Unix
and therefore all compiler messages refer to the files via the Unix names,
and different hosts do different mangling of the names.

But when I see a path in a source file or email it is almost always in Unix format.

Similarly, our network login directories are on the netapps, for example,
my "home" directory is /u/sasdjb , but that is only available from
Windows via a UNC path, //dntsrc/u/sasdjb or or //sashq/too/u/sasdjb
or /nfs/sanyo/vol/vol2/u22/sasdjb or via a mapped network
drive, u:/ 

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/"))

If I'm running Emacs on Linux, I would normalize all
these variations the other way:

directory-abbrev-alist:

'(("^//dntsrc/u/sasdjb" . "/u/sasdjb")
  ("^u:" . "/u/sasdjb")
  ("^//sashq/root/u/sasdjb" . "/u/sasdjb")
  ("^/nfs/sanyo/vol/vol2/u22/sasdjb" . "/u/sasdjb")
  ("^//sashq/root/u/sasdjb" . "/u/sasdjb")
  ("^//dntsrc/sas/" . "/sas/")
  ("^//dntsrc/sasgen/" . "/sasgen"))

There are many ways in which I can open files in Emacs

C-x C-f
filemenu http://www.eskimo.com/~seldon/filemenu.el
find-file-at-point
gud/gdb
compile/next-error

and probably 5 or 6 other ways, and I'd like them to all honor directory-abbrev-alist

>         Stefan

-- 
David J. Biesack, SAS
SAS Campus Dr. Cary, NC 27513
www.sas.com    (919) 531-7771



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4902; Package emacs. (Wed, 11 Nov 2009 04:20:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eli Zaretskii <eliz <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 11 Nov 2009 04:20:04 GMT) Full text and rfc822 format available.

Message #30 received at 4902 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "David J. Biesack" <David.Biesack <at> sas.com>,
        4902 <at> debbugs.gnu.org
Cc: monnier <at> IRO.UMontreal.CA
Subject: Re: bug#4902: 23.1; directory-abbrev-alist is not handled early enough
Date: Wed, 11 Nov 2009 06:11:54 +0200
> Date: Tue, 10 Nov 2009 16:29:36 -0500
> From: "David J. Biesack" <David.Biesack <at> sas.com>
> Cc: 4902 <at> emacsbugs.donarmstrong.com
> 
> 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/"))
> 
> If I'm running Emacs on Linux, I would normalize all
> these variations the other way:
> 
> directory-abbrev-alist:
> 
> '(("^//dntsrc/u/sasdjb" . "/u/sasdjb")
>   ("^u:" . "/u/sasdjb")
>   ("^//sashq/root/u/sasdjb" . "/u/sasdjb")
>   ("^/nfs/sanyo/vol/vol2/u22/sasdjb" . "/u/sasdjb")
>   ("^//sashq/root/u/sasdjb" . "/u/sasdjb")
>   ("^//dntsrc/sas/" . "/sas/")
>   ("^//dntsrc/sasgen/" . "/sasgen"))

So you are trying to solve in Emacs a problem that is not for Emacs to
solve.  You are trying to emulate a symlink using Emacs features that
are not at all intended for such a use.

Personally, I don't think this problem even should be solved in
Emacs.  You still have other tools which need to see the correct file
name, so any mapping Emacs does internally will never be sufficient.

About the only thing I can suggest is to run with the drive u: being
the current drive.  Then /foo/bar on both Windows and Unix will refer
to the same place, and you don't need any mapping at all.

If that doesn't help for some reason, I think you need to solve your
problem in an entirely different manner.



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4902; Package emacs. (Wed, 11 Nov 2009 12:55:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to "David J. Biesack" <David.Biesack <at> sas.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 11 Nov 2009 12:55:05 GMT) Full text and rfc822 format available.

Message #35 received at 4902 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "David J. Biesack" <David.Biesack <at> sas.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 4902 <at> debbugs.gnu.org, monnier <at> IRO.UMontreal.CA
Subject: Re: bug#4902: 23.1; directory-abbrev-alist is not handled early enough
Date: Wed, 11 Nov 2009 07:47:36 -0500
> Date: Wed, 11 Nov 2009 06:11:54 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
> CC: <monnier <at> IRO.UMontreal.CA>
> 
> > Date: Tue, 10 Nov 2009 16:29:36 -0500
> > From: "David J. Biesack" <David.Biesack <at> sas.com>
> > Cc: 4902 <at> emacsbugs.donarmstrong.com
> > 
> > Obviously, there are too many different names for the same file,
> > and I want Emacs to normalize all files to a canonical
> > form

> So you are trying to solve in Emacs a problem that is not for Emacs to
> solve.  You are trying to emulate a symlink using Emacs features that
> are not at all intended for such a use.

I could not disagree more. Emacs is and has been my primary operating
environment for my job; it is my primary tool for working with all
of the files on our network. We're a big organization (10,000 people)
and there are many different and independent servers and configurations that
I must integrate, and Emacs is my only hope.

If you choose to not allow Emacs proper to assist, I'll just go it
alone. But other people around the world have to deal with networks and 
file aliases;; I'd rather see Emacs help all of us.

> Personally, I don't think this problem even should be solved in
> Emacs.  You still have other tools which need to see the correct file
> name, so any mapping Emacs does internally will never be sufficient.

Some progress is better than no progress.
 
> About the only thing I can suggest is to run with the drive u: being
> the current drive.  Then /foo/bar on both Windows and Unix will refer
> to the same place, and you don't need any mapping at all.

that still won't work for Unix network paths that are not mapped in U:
 
> If that doesn't help for some reason, I think you need to solve your
> problem in an entirely different manner.

so I will.

-- 
David J. Biesack, SAS
SAS Campus Dr. Cary, NC 27513
www.sas.com    (919) 531-7771



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4902; Package emacs. (Wed, 11 Nov 2009 15:00:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 11 Nov 2009 15:00:05 GMT) Full text and rfc822 format available.

Message #40 received at 4902 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: "David J. Biesack" <David.Biesack <at> sas.com>
Cc: 4902 <at> debbugs.gnu.org
Subject: Re: bug#4902: 23.1; directory-abbrev-alist is not handled early enough
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))



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4902; Package emacs. (Wed, 11 Nov 2009 18:45:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eli Zaretskii <eliz <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 11 Nov 2009 18:45:05 GMT) Full text and rfc822 format available.

Message #45 received at 4902 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "David J. Biesack" <David.Biesack <at> sas.com>
Cc: 4902 <at> debbugs.gnu.org, monnier <at> IRO.UMontreal.CA
Subject: Re: bug#4902: 23.1; directory-abbrev-alist is not handled early enough
Date: Wed, 11 Nov 2009 20:35:23 +0200
> Date: Wed, 11 Nov 2009 07:47:36 -0500
> From: "David J. Biesack" <David.Biesack <at> sas.com>
> CC: 4902 <at> emacsbugs.donarmstrong.com, monnier <at> IRO.UMontreal.CA
> 
> > About the only thing I can suggest is to run with the drive u: being
> > the current drive.  Then /foo/bar on both Windows and Unix will refer
> > to the same place, and you don't need any mapping at all.
> 
> that still won't work for Unix network paths that are not mapped in U:

What prevents you from mapping them all to U: ?



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4902; Package emacs. (Wed, 11 Nov 2009 19:45:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to "David J. Biesack" <David.Biesack <at> sas.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 11 Nov 2009 19:45:04 GMT) Full text and rfc822 format available.

Message #50 received at 4902 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "David J. Biesack" <David.Biesack <at> sas.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4902 <at> debbugs.gnu.org
Subject: Re: bug#4902: 23.1; directory-abbrev-alist is not handled early enough
Date: Wed, 11 Nov 2009 14:41:40 -0500
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 <monnier <at> iro.umontreal.ca>
> CC: <4902 <at> 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



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4902; Package emacs. (Wed, 11 Nov 2009 21:05:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to "David J. Biesack" <David.Biesack <at> sas.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 11 Nov 2009 21:05:05 GMT) Full text and rfc822 format available.

Message #55 received at 4902 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "David J. Biesack" <David.Biesack <at> sas.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 4902 <at> debbugs.gnu.org, monnier <at> IRO.UMontreal.CA
Subject: Re: bug#4902: 23.1; directory-abbrev-alist is not handled early enough
Date: Wed, 11 Nov 2009 15:57:03 -0500
> Date: Wed, 11 Nov 2009 20:35:23 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
> CC: <4902 <at> emacsbugs.donarmstrong.com>, <monnier <at> IRO.UMontreal.CA>
> 
> > Date: Wed, 11 Nov 2009 07:47:36 -0500
> > From: "David J. Biesack" <David.Biesack <at> sas.com>
> > CC: 4902 <at> emacsbugs.donarmstrong.com, monnier <at> IRO.UMontreal.CA
> > 
> > > About the only thing I can suggest is to run with the drive u: being
> > > the current drive.  Then /foo/bar on both Windows and Unix will refer
> > > to the same place, and you don't need any mapping at all.
> > 
> > that still won't work for Unix network paths that are not mapped in U:
> 
> What prevents you from mapping them all to U: ?

There are dozens if not hundreds of them.  U: is mapped (by our IT department)
to our Unix login (Unix/User, hence U:) directory. 
Other things are not our login directories and it would be wrong to map them there.
Similarly, we would not want to require each user to duplicate a bunch of
drive mappings on their desktops (or symlinks in their unix login directories)
Thus, We use UNC paths for these other locations.
For example, I would access your login at \\sashq\root\u\eliz 
whereas it would be U:\ for your, and you would see mine
at \\sashq\root\u\sasdjb

This has all evolved over a period of years...

-- 
David J. Biesack, SAS
SAS Campus Dr. Cary, NC 27513
www.sas.com    (919) 531-7771



Severity set to 'wishlist' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Thu, 12 Nov 2009 07:30:39 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#4902; Package emacs. (Sat, 02 Nov 2019 05:22:01 GMT) Full text and rfc822 format available.

Message #60 received at 4902 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4902 <at> debbugs.gnu.org, "David J. Biesack" <David.Biesack <at> sas.com>
Subject: Re: bug#4902: 23.1; directory-abbrev-alist is not handled early enough
Date: Sat, 02 Nov 2019 06:21:20 +0100
tags 4902 + wontfix
close 4902
thanks

Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

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

That was ten years ago.

It seems like the OP found a solution to his problem, and according to
what Stefan writes above, we don't want to change anything in Emacs
here.  I'm therefore closing this as wontfix.

If that's incorrect, please reopen the bug report.

Best regards,
Stefan Kangas




Added tag(s) wontfix. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 02 Nov 2019 05:22:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 4902 <at> debbugs.gnu.org and David Biesack <David.Biesack <at> sas.com> Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 02 Nov 2019 05:22:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 30 Nov 2019 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 147 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.