bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65120: 29.1; directory-abbrev-alist breaks various things when insid


From: Sean Allred
Subject: bug#65120: 29.1; directory-abbrev-alist breaks various things when inside an abbreviated directory
Date: Wed, 09 Aug 2023 18:31:50 -0500
User-agent: mu4e 1.11.1; emacs 29.1

Eli Zaretskii <eliz@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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]