
(defun hpath:absolute-to (path &optional default-dirs) "\
Returns PATH as an absolute path relative to one directory from optional DEFAULT-DIRS or 'default-directory'.
Returns PATH unchanged when it is not a valid path or when DEFAULT-DIRS
is invalid.  DEFAULT-DIRS when non-nil may be a single directory or a list of
directories.  The first one in which PATH is found is used." (byte-code ";?ƒ
 ‚g 	?ƒ 
ÃB‰‚* 	;ƒ$ 	ÃB‰‚* 	<†* Ã?ƒ2 ‚g ÃÃ	…= ?…` ÇÈ	@!!Ç\"	A‰ˆÉ!†\\ Ã‰ˆ‚7 ˆ†f *‡" [path default-dirs default-directory nil t rtn dir expand-file-name file-name-as-directory file-exists-p] 7))

(defun hpath:at-p (&optional type non-exist) "\
Returns delimited path or non-delimited ange-ftp path at point, if any.
Delimiters may be:  double quotes, open and close single quote, or
Texinfo file references.
If optional TYPE is the symbol 'file or 'directory, then only that path type is
accepted as a match.  Only locally reachable paths are checked for existence.
With optional NON-EXIST, nonexistent local paths are allowed.
Absolute pathnames must begin with a '/' or '~'.  Relative pathnames
must begin with a './' or '../' to be recognized." (byte-code "Â † ÃÄÅÅ\"† ÄÆÇ\"† ÄÈÉ\"	#‡" [type non-exist hpath:ange-ftp-p hpath:is-p hargs:delimited "\"" "`" "'" "@file{" "}"] 8))

(defun hpath:ange-ftp-p nil "\
Returns an ange-ftp pathname that point is within or nil.
See the 'ange-ftp' Elisp package for pathname format details.
Always returns nil if the ange-ftp package has not been loaded." (byte-code "ÃÄ!…~ 	;ƒ 	‚ ÅÆŠÇÈ!ˆÉÊ!ƒ) ËÌÍ!ÎÍ!\"‚c ÉÏ!ƒ= ÐËÌÍ!ÎÍ!\"Q‚c ÉÑ!…[ ËÌÒ!ÎÒ!\"‰…[ ÓÔËÌÕ!ÎÕ!\"\"…c ÐÖ
R)‰ˆ
…r ×

GSHUƒ| 
ÍØO‚} 
*‡" [user ange-ftp-default-user path featurep ange-ftp "anonymous" nil skip-chars-backward "^[ 	
\"`'({" looking-at "/?[^@/:]+@[^/:@ 	
\"`']+:[^]@ 	
\"`')}]*" buffer-substring match-beginning 0 match-end "@[^/:@ 	
\"`']+:[^]@ 	
\"`')}]*" "/" "/?\\(\\([^/:@ 	
\"`']+\\):[^]@:, 	
\"`')}]*\\)[] 	
,.\"`')}]" 1 string-match "[^.]\\.[^.]" 2 "@" 46 -1] 22))

(defun hpath:find (filename) "\
Edit file FILENAME using program from hpath:find-alist if available.
Switch to a buffer visiting file FILENAME, creating one if none already
exists.  Return non-nil iff file is displayed within a buffer." (interactive "FFind file: ") (byte-code "Ä!‰ˆÅ!ˆÆ!	ƒ ÇÈ	ÉQ\"ˆÂ‚% ÊË!!ˆÃ)‡" [filename find-program nil t hpath:substitute-value hpath:validate hpath:find-program actype:act exec-window-cmd " " switch-to-buffer find-file-noselect] 8))

(defun hpath:find-other-window (filename) "\
Edit file FILENAME, in another window or using program from hpath:find-alist.
May create a new window, or reuse an existing one; see the function display-buffer.
Return non-nil iff file is displayed within a buffer." (interactive "FFind file in other window: ") (byte-code "Ä!‰ˆÅ!ˆÆ!	ƒ ÇÈ	ÉQ\"ˆÂ‚% ÊË!!ˆÃ)‡" [filename find-program nil t hpath:substitute-value hpath:validate hpath:find-program actype:act exec-window-cmd " " switch-to-buffer-other-window find-file-noselect] 8))

(defun hpath:is-p (path &optional type non-exist) "\
Returns PATH if PATH is a Unix path, else nil.
If optional TYPE is the symbol 'file or 'directory, then only that path type
is accepted as a match.  The existence of the path is checked only for
locally reachable paths (Info paths are not checked).  Single spaces are
permitted in middle of pathnames, but not at the start.  Tabs and newlines
are converted to space before the pathname is checked, this normalized path
form is what is returned for PATH.  With optional NON-EXIST, nonexistent
local paths are allowed." (byte-code ";…« ÅÆ\"† ÇÈ\"?…« ÉÊ!!‰…« ÇË\"?†* ÇÌ\"…« ÇÍ\"ƒ< Î!‰‚= Á…« ÇÏ\"?…« ÇÐ\"
ƒ~ Ñ=ƒf ÅÒÓÔO\"?…c ‚{ Õ=ƒz ÅÒÓÔO\"…w ‚{ ‚ª †… Ö!…ª Ñ=ƒ™ ×!?…– ‚ª Õ=ƒ© ×!…¦ ‚ª )‡" [path t remote-path type non-exist string= "" string-match "\\`\\s \\|\\s \\'" hbut:key-to-label hbut:label-to-key "[()]" "\\`([^)]+)[ A-Za-z0-9]" "\\${[^}]+}" hpath:substitute-value "[	
\"`'{}|\\]" "@.+:\\|.+:/" file "/" -1 nil directory file-exists-p file-directory-p] 18))

(defun hpath:relative-to (path &optional default-dir) "\
Returns PATH relative to optional DEFAULT-DIR or 'default-directory'.
Returns PATH unchanged when it is not a valid path." (byte-code ";… Ä!?ƒ ‚C ÅÆ	† 
!!Å!‰ˆ…C 	…C G	G^ÇÈO	\"ƒA ÉÊOP‚B )‡" [path default-dir default-directory end-dir file-exists-p expand-file-name file-name-as-directory string= 0 "./" nil] 9))

(defun hpath:substitute-value (path) "\
Substitutes matching value for Emacs Lisp variables and environment variables in PATH.
Returns path with variable values substituted." (substitute-in-file-name (hypb:replace-match-string "\\${[^}]+}" path (quote (lambda (str) (byte-code "	
O	
Ç\\SO	ÈOÉ!Ê!…# ËÈO‰ˆ…- Ì!ƒ9 ÍÎ\"!‚: ,‡" [var-group path match start var-name rest-of-path sym 2 nil intern-soft file-name-absolute-p 1 boundp directory-file-name hpath:substitute-dir] 7))) t)))

(defun hpath:substitute-var (path) "\
Replaces up to one match in PATH with first matching variable from 'hpath:variables'." (byte-code ";…	 ÈÉ\"?ƒ ‚˜ Ê!‰ˆËËËË
…( 	?…‘ 
@
A‰ˆÌ!…� J‰ˆ;ƒV Í#‰…S ‰‚� ?†� <ƒ‰ …i 	?…† Í@#‰…{ ‰ˆA‰ˆ‚b ‚� ÎÏ\"ˆ‚\" ˆ	†— -‡" [path new-path vars hpath:variables result var val t string-match "/" hpath:symlink-referent nil boundp hpath:substitute-var-name error "(hpath:substitute-var): '%s' has invalid value for hpath:variables"] 10))

(defun hpath:symlink-referent (linkname) "\
Returns expanded file or directory referent of LINKNAME.
LINKNAME should not end with a directory delimiter.
Returns nil if LINKNAME is not a string.
Returns expanded LINKNAME if it is not a symbolic link but is a pathname." (byte-code ";…# ÂÃ!‰… Ä	Å!\"‰ˆ‚ )ˆÄÅ!\"‡" [linkname referent nil file-symlink-p hpath:symlink-expand file-name-directory] 7))

(defun hpath:symlink-expand (referent dirname) "\
Returns expanded file or directory REFERENT relative to DIRNAME." (byte-code "Å
ÆÇ\"…* ÈÉÊ!ËÊ!O!ÌÉÌ!OËÌ!ÅOQ‰ˆ‚ ˆÆÍ\"…7 ÌU…O ÆÎ
\"…G 
ÌËÌ!OÏÊÅOQ‰)ˆÆÐ\"…¦ ÆÑ\"…k ËÊ!ÅO‰ˆ‚X ˆÆÒ\"…‡ ÓÔ	!!	ËÌ!ÅOP‰ˆ‚l ˆÆÕ\"…¢ ÌÉÌ!OËÌ!ÅOP‰ˆ‚ˆ ˆ‚Q ˆÖÌH×\"…¿ ÖÌHØ\"…¿ Ù
\"‰*ˆ‡" [var-link dir dirname referent nd-abbrev nil string-match "\\$(\\([^)]*\\))" getenv match-beginning 1 match-end 0 "`node_data" "^//[^/]+" "/sys/" "\\.\\." "^\\(//\\.\\.\\|/\\.\\.\\)\\(/\\|$\\)" "^\\.\\.\\(/\\|$\\)" file-name-directory directory-file-name "[^/]+/\\.\\./" /= 126 47 expand-file-name] 25))

(defun hpath:validate (path) "\
Returns PATH if PATH is a valid, readable path, else signals error.
Default-directory should be equal to current Hyperbole button source
directory when called so that PATH is expanded relative to it." (byte-code ";… Á!ƒ ‚ ÂÃ\"‡" [path file-readable-p error "(hpath:validate): \"%s\" is not readable."] 4))

(defun hpath:find-program (filename) (byte-code "	ÅÅ
?… …' Æ@‰@\"… A‰ˆA‰ˆ‚ ˆ
+‡" [regexp-alist hpath:find-alist prog elt filename nil string-match] 4))

(defun hpath:substitute-dir (var-name rest-of-path) "\
Returns a dir for VAR-NAME using REST-OF-PATH to find match or triggers an error when no match.
VAR-NAME's value may be a directory or a list of directories.  If it is a
list, the first directory prepended to REST-OF-PATH which produces a valid
local pathname is returned." (byte-code "ÅÅ
;?ƒ ÇÈ
\"‚‡ É
!‰… Ê!?ƒ' ÇË
\"‚‡ J‰;ƒ< ÌÍ	\"!…9 	‚‡ 	<ƒƒ Å	…I ?…j 	@	A‰ˆÎ!…` ÏÍ\"!†f Å‰ˆ‚C ˆƒw ÌÐ!!‚ ÇÑÒ
ÓR\")‚‡ ÇÔ
\"*‡" [sym val var-name rest-of-path dir nil t error "(hpath:substitute-dir): VAR-NAME arg, '%s', must be a string" intern-soft boundp "(hpath:substitute-dir): VAR-NAME arg, \"%s\", is not a bound variable" hpath:validate expand-file-name file-name-absolute-p file-readable-p directory-file-name "(hpath:substitute-dir): Can't find match for \"%s\"" "${" "}/" "(hpath:substitute-dir): Value of VAR-NAME, \"%s\", must be a string or list"] 17))

(defun hpath:substitute-var-name (var-symbol var-dir-val path) "\
Replaces with VAR-SYMBOL any occurrences of VAR-DIR-VAL in PATH.
If PATH is modified, returns PATH, otherwise returns nil." (byte-code "ÆÇÈ	!!
ÉÊ!ËQÄ$Ì
\"ƒ Å‚ )‡" [new-path var-dir-val path var-symbol t nil hypb:replace-match-string regexp-quote file-name-as-directory "${" symbol-name "}/" equal] 9))

(provide (quote hpath))
