33; ; Author: Bob Weiner
44; ;
55; ; Orig-Date: 1-Nov-91 at 00:44:23
6- ; ; Last-Mod: 30-Nov -25 at 19:58:24 by Mats Lidell
6+ ; ; Last-Mod: 6-Dec -25 at 22:57:33 by Bob Weiner
77; ;
88; ; SPDX-License-Identifier: GPL-3.0-or-later
99; ;
@@ -762,30 +762,29 @@ used."
762762 (lambda (path non-exist )
763763 (when (stringp path)
764764 (setq path (hpath:trim path)))
765- (cond ((not (and (stringp path)
766- (not (hypb:object-p path))
767- (setq path (hpath:expand path))
768- (not (get-buffer path))
769- (not (file-name-absolute-p path))
770- (hpath:is-p path nil non-exist)))
771- path)
772- ((not (cond ((null default-dirs)
773- (setq default-dirs (cons default-directory nil )))
774- ((stringp default-dirs)
775- (setq default-dirs (cons default-dirs nil )))
776- ((listp default-dirs))
777- (t nil )))
778- path)
779- (t
780- (let ((rtn) dir)
781- (while (and default-dirs (null rtn))
782- (setq dir (expand-file-name
783- (file-name-as-directory (car default-dirs)))
784- rtn (expand-file-name path dir)
785- default-dirs (cdr default-dirs))
786- (unless (file-exists-p rtn)
787- (setq rtn nil )))
788- (or rtn path)))))
765+ (let ((dirs default-dirs)
766+ dir
767+ expanded-path)
768+ (setq expanded-path
769+ (cond ((or (stringp dirs) (null dirs))
770+ (expand-file-name path dirs))
771+ ((listp dirs)
772+ (while (and dirs (null expanded-path))
773+ (setq dir (expand-file-name
774+ (file-name-as-directory (car dirs)))
775+ expanded-path (expand-file-name path dir)
776+ dirs (cdr dirs))
777+ (unless (file-exists-p expanded-path)
778+ (setq expanded-path nil )))
779+ (or expanded-path path))
780+ (t (error " (hpath:absolute-to): `default-dirs' must be a string or list, not `%s' " default-dirs))))
781+ (if (and (stringp expanded-path)
782+ (not (hypb:object-p expanded-path))
783+ (not (get-buffer expanded-path))
784+ (file-name-absolute-p expanded-path)
785+ (hpath:is-p expanded-path nil non-exist))
786+ expanded-path
787+ path)))
789788 path 'allow-spaces )))
790789
791790(defun hpath:tramp-file-name-regexp ()
@@ -1053,7 +1052,7 @@ Make any existing path within a file buffer absolute before returning."
10531052 ; ; Never expand paths with a prefix character, e.g. program
10541053 ; ; names which need to use exec-directory expansion.
10551054 (setq expanded-path (if prefix (hpath:resolve path) (hpath:expand path))
1056- path (funcall func expanded- path non-exist)))
1055+ path (funcall func path non-exist)))
10571056 ; ;
10581057 ; ; If path is just a local reference that begins with #,
10591058 ; ; in a file buffer, prepend the file name to it. If an HTML
@@ -1063,18 +1062,19 @@ Make any existing path within a file buffer absolute before returning."
10631062 " " )))
10641063 (if (and path
10651064 (not (string-empty-p path))
1066- ; ; If just a numeric suffix like ":40" by itself, ignore
1067- ; ; it, but if a markdown type suffix alone, like
1068- ; ; "#section", use it.
1069- (and suffix (not (string-empty-p suffix))
1070- (= ?# (aref suffix 0 ))))
1065+ (or (file-exists-p path)
1066+ ; ; If just a numeric suffix like ":40" by itself, ignore
1067+ ; ; it, but if a markdown type suffix alone, like
1068+ ; ; "#section", use it.
1069+ (and suffix (not (string-empty-p suffix))
1070+ (= ?# (aref suffix 0 )))))
10711071 (progn
10721072 (setq path (concat prefix path suffix))
10731073 (cond ((and (hypb:buffer-file-name)
1074- ; ; ignore HTML color strings
1075- (not (string-match " \\ `#[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]\\' " path))
10761074 ; ; match to in-file #anchor references
1077- (string-match " \\ `#[^+\'\"<>#]+\\' " path))
1075+ (string-match " \\ `#[^+\'\"<>#]+\\' " path)
1076+ ; ; ignore HTML color strings
1077+ (not (string-match " \\ `#[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]\\' " path)))
10781078 (setq path (concat mode-prefix (hypb:buffer-file-name) path)))
10791079 ((string-match " \\ `\\ ([^#]+\\ )\\ (#[^#+]*.*\\ )\\ '" path)
10801080 ; ; file and #anchor reference
@@ -1089,7 +1089,7 @@ Make any existing path within a file buffer absolute before returning."
10891089 (setq path (concat mode-prefix path suffix))))
10901090 (t
10911091 (when (or non-exist (file-exists-p path))
1092- path))))
1092+ ( setq path ( concat mode-prefix path)) ))))
10931093
10941094 (when (or (and (stringp suffix) (not (string-empty-p suffix))
10951095 (= ?# (aref suffix 0 )))
0 commit comments