Function: smart-dired-pathname-up-to-point

smart-dired-pathname-up-to-point is an interactive and byte-compiled function defined in hui-mouse.el.

Signature

(smart-dired-pathname-up-to-point &optional NO-DEFAULT)

Documentation

Return the part of the pathname up through point, else current directory.

Use for direct selection of an ancestor directory of the Dired directory at point, if any.

With optional NO-DEFAULT, do not default to current directory path; instead return nil.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui-mouse.el
;;; ************************************************************************
;;; smart-dired functions
;;; ************************************************************************

(defun smart-dired-pathname-up-to-point (&optional no-default)
  "Return the part of the pathname up through point, else current directory.
Use for direct selection of an ancestor directory of the
Dired directory at point, if any.

With optional NO-DEFAULT, do not default to current directory
path; instead return nil."
  (interactive)
  (when (not (derived-mode-p 'dired-mode))
    (error "(smart-dired-pathname-up-to-point): Called from non-dired buffer, '%s'"
	   (buffer-name)))
  (if (dired-get-subdir) ;; On a dired directory line
      (save-excursion
	(re-search-forward "[/:\n\r\t\f]" (line-end-position) t)
	(buffer-substring-no-properties
	  (if (and (not (bobp)) (= (preceding-char) ?/))
	      (point)
	    (1- (point)))
	  (progn (beginning-of-line)
		 (skip-syntax-forward "-")
		 (point))))
    (unless no-default
      (expand-file-name default-directory))))