Function: hpath:at-p

hpath:at-p is a byte-compiled function defined in hpath.el.

Signature

(hpath:at-p &optional TYPE NON-EXIST)

Documentation

Return delimited path or non-delimited remote path at point, if any.

Path is expanded and normalized. See hpath:is-p for how the path is normalized.

World-Wide Web urls are ignored and therefore dealt with by other code. Delimiters may be: double quotes, open and close single quote, whitespace, 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. Nonexistent local paths may not contain whitespace unless they are delimited. Absolute pathnames must begin with a / or ~.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hpath.el
(defun hpath:at-p (&optional type non-exist)
  "Return delimited path or non-delimited remote path at point, if any.
Path is expanded and normalized.  See `hpath:is-p' for how the path
is normalized.

World-Wide Web urls are ignored and therefore dealt with by other
code.  Delimiters may be: double quotes, open and close single
quote, whitespace, 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.  Nonexistent local paths may not contain whitespace
unless they are delimited.  Absolute pathnames must begin with a `/'
or `~'."
  (let ((path (hpath:delimited-possible-path non-exist))
	prefix
	subpath)
    (when path
      (setq path (string-trim path)))
    (when (and path (not non-exist)
	       (string-match hpath:prefix-regexp path)
	       (setq prefix (substring path 0 1)
		     path (substring path 1))
	       (not (string-equal (match-string 0 path) path)))
      (setq non-exist t))
    (if (and path (not (string-empty-p path))
	     (or (and non-exist prefix)
		 (file-readable-p path)))
	(concat prefix path)
      (unless (and path (or (string-empty-p path)
			    (string-match "::" path)))
	(cond ((and path
		    ;; Don't allow more than one set of grouping chars
		    (not (string-match-p "\)\\s-*\(\\|\\]\\s-*\\[\\|\}\\s-*\{" path))
		    ;; With point inside a path variable, return the path that point is on or to the right of.
		    (setq subpath (or (and (setq subpath (hargs:delimited "[:\"\']\\|^\\s-*" "[:\"\']\\|\\s-*$" t t nil "[\t\n\r\f]\\|[;:] \\| [;:]"))
					   (not (string-match-p "[:;\t\n\r\f]" subpath))
					   subpath)
				      (and (setq subpath (hargs:delimited "[;\"\']\\|^\\s-*" "[;\"\']\\|\\s-*$"  t t nil "[\t\n\r\f]\\|[;:] \\| [;:]"))
					   (not (string-match-p "[;\t\n\r\f]\\|:[^:]*:" subpath))
					   subpath)))
		    ;; Handle anchored or action prefix char paths in the
		    ;; following clause; otherwise, might just be looking
		    ;; at part of the path
		    (and subpath (not (or (string-match-p "#" subpath)
					  (string-match-p hpath:prefix-regexp subpath))))
		    (setq subpath
			  (if subpath
			      (cond ((and (string-match "\\`\\s-*\\([^; \t]+\\)" subpath)
					  (executable-find (match-string 1 subpath)))
				     ;; Could be a shell command from a semicolon separated
				     ;; list; ignore if so
				     nil)
				    (t (or (hywiki-get-existing-page-file subpath)
                                           (expand-file-name subpath))))
			    ;; Only default to current path if know are within a PATH value
			    (when (string-match-p hpath:path-variable-value-regexp path)
			      ".")))
		    (hpath:is-p subpath type non-exist))
	       subpath)
	      ((hpath:is-p path type non-exist))
	      ;; Local file URLs
	      ;; ((hpath:is-p (hargs:delimited "file://" "[ \t\n\r\"\'\}]" nil t)))
	      ((hpath:remote-at-p))
	      ((hpath:www-at-p) nil))))))