Function: hpath:cache-mswindows-mount-points
hpath:cache-mswindows-mount-points is an autoloaded, interactive and
byte-compiled function defined in hpath.el.
Signature
(hpath:cache-mswindows-mount-points)
Documentation
Cache valid MSWindows mounts when under a non-MSWindows OS, e.g. WSL.
Mount points are cached in directory-abbrev-alist.
Call this function manually if mount points change after Hyperbole is loaded.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hpath.el
;;;###autoload
(defun hpath:cache-mswindows-mount-points ()
"Cache valid MSWindows mounts when under a non-MSWindows OS, e.g. WSL.
Mount points are cached in `directory-abbrev-alist'.
Call this function manually if mount points change after Hyperbole is loaded."
(interactive)
(when (not hyperb:microsoft-os-p)
(let (mount-points-to-add)
;; Convert plist to alist for sorting.
(hypb:map-plist (lambda (path mount-point)
(when (string-match "\\`\\([a-zA-Z]\\):\\'" path)
(setq path (concat "/" (match-string 1 path))))
;; Drive letter must be downcased
;; in order to work when converted back to Posix.
;; Assume all mounted Windows paths are
;; lowercase for now.
(setq path (downcase path))
(push (cons (downcase path) mount-point)
mount-points-to-add)
;; If a network share with a domain
;; name, also add an entry WITHOUT the
;; domain name to the mount points
;; table since Windows paths often omit
;; the domain.
(when (string-match "\\`\\([\\/][\\/][^.\\/]+\\)\\([^\\/]+\\)" path)
(push (cons (concat (match-string 1 path)
(substring path (match-end 0)))
mount-point)
mount-points-to-add)))
;; Return a plist of MSWindows path-mounted mount-point pairs.
;; Next call will raise an error if default-directory is set to
;; a URL, e.g. in RFC buffers; just ignore it and return nil in
;; such a case.
(ignore-errors
(split-string (shell-command-to-string (format "df -a -t drvfs 2> /dev/null | sort | uniq | grep -v '%s' | sed -e 's+ .*[-%%] /+ /+g'" hpath:posix-mount-points-regexp)))))
;; Sort alist of (path-mounted . mount-point) elements from shortest
;; to longest path so that the longest path is selected first within
;; 'directory-abbrev-alist' (elements are added in reverse order).
(setq mount-points-to-add
(sort mount-points-to-add
(lambda (cons1 cons2) (<= (length (car cons1)) (length (car cons2))))))
(let (path
mount-point)
(mapc (lambda (path-and-mount-point)
(setq path (car path-and-mount-point)
mount-point (cdr path-and-mount-point))
;; Don't abbreviate /mnt or /cygdrive to /, skip this entry.
(unless (equal mount-point "/")
(add-to-list 'directory-abbrev-alist (cons (format "\\`%s\\>" (regexp-quote path))
mount-point))))
mount-points-to-add))
;; Save the reverse of each mount-points-to-add so
;; can expand paths when going from posix-to-mswindows.
(setq hpath:posix-mount-point-to-mswindows-alist
(mapcar (lambda (elt) (cons (concat "\\`" (cdr elt) "\\>")
(car elt))) mount-points-to-add))
mount-points-to-add)))