GNU bug report logs - #65120
29.1; directory-abbrev-alist breaks various things when inside an abbreviated directory

Previous Next

Package: emacs;

Reported by: Sean Allred <allred.sean <at> gmail.com>

Date: Sun, 6 Aug 2023 23:40:01 UTC

Severity: normal

Found in version 29.1

Full log


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

From: Sean Allred <allred.sean <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 65120 <at> debbugs.gnu.org
Subject: Re: bug#65120: 29.1; directory-abbrev-alist breaks various things
 when inside an abbreviated directory
Date: Wed, 09 Aug 2023 18:31:50 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:
> I don't think there's something in Emacs.  But you can use
> directory-abbrev-alist if you define a drive (using 'subst') that
> would remove the need for using the full file name.  Something like
>
>   subst x: C:\$MegaCorpSource
>
> Then you could use "x:/" in directory-abbrev-alist.  This actually
> matches the "symlink" idea of this feature on Unix.

Oh, neat! This is definitely not something I would make work 'out of the
box' in my distribution, but I will absolutely add a note in my
documentation to call out this strategy. We already have ~10ish mapped
drives on the network -- as well as folks who use external drives. Would
hate to clobber someone's environment.

In the meantime, I think I'll create a new defcustom/defun pair:

    (defcustom directory-abbrev-display-alist
      nil
      "Like `directory-abbrev-alist', but for `abbreviate-file-name-for-display'.")

    (defun abbreviate-file-name-for-display (filename)
      "Like `abbreviate-file-name', but is not guaranteed to produce a functional path."
      (let ((directory-abbrev-alist (append directory-abbrev-display-alist
                                            directory-abbrev-alist)))
        (abbreviate-file-name filename)))

    ;; e.g.
    (let ((directory-abbrev-display-alist
           '(("C:/MegaCorpSource" . "@src"))))
      (abbreviate-file-name-for-display "C:/MegaCorpSource/foo"))
    => "@src/foo

(Symbol names prefixed with my package prefix, of course.)

If I get good mileage out of this, would this be the kind of thing I
could submit a patch for? It turned out prettier than I was expecting.
(I've already sorted out the FSF paperwork.)

> (Yes, I know: corporate IT doesn't like SUBST very much, either.  But
> maybe you will be lucky...)

Better to ask forgiveness... :-) [obligatory 'kidding' to any of my
corporate IT friends who may be reading this post!]

Thanks!

--
Sean Allred




This bug report was last modified 1 year and 317 days ago.

Previous Next


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