interactively, include all files under the project root, except
for VCS directories listed in `vc-directory-exclusion-list'."
(interactive "P")
- (defvar project-file-history-behavior)
(let* ((pr (project-current t))
(dirs (cons
(project-root pr)
- (project-external-roots pr)))
- (project-file-history-behavior t))
+ (project-external-roots pr))))
(project-find-file-in
(delq nil (list (and buffer-file-name (project--find-default-from
buffer-file-name pr))
:group 'project
:version "27.1")
-(defcustom project-file-history-behavior t
- "If `relativize', entries in `file-name-history' are adjusted.
-
-History entries shown in `project-find-file', `project-find-dir',
-(from `file-name-history') are adjusted to be relative to the
-current project root, instead of the project which added those
-paths. This only affects history entries added by earlier calls
-to `project-find-file' or `project-find-dir'.
-
-This has the effect of sharing more history between projects."
- :type '(choice (const :tag "Default behavior" t)
- (const :tag "Adjust to be relative to current" relativize))
- :group 'project
- :version "30.1")
-
-(defun project--transplant-file-name (filename project)
- (when-let ((old-root (get-text-property 0 'project filename)))
- (expand-file-name
- (file-relative-name filename old-root)
- (project-root project))))
-
(defun project--read-file-cpd-relative (prompt
all-files &optional predicate
hist mb-default)
(defun project--read-file-name ( project prompt
all-files &optional predicate
hist mb-default)
- "Call `project-read-file-name-function' with appropriate history.
-
-Depending on `project-file-history-behavior', entries are made
-project-relative where possible."
+ "Call `project-read-file-name-function' with appropriate history."
(let ((file
- (cl-letf ((history-add-new-input nil)
- ((symbol-value hist)
- (if (eq project-file-history-behavior 'relativize)
- (mapcar
- (lambda (f)
- (or (project--transplant-file-name f project) f))
- (symbol-value hist))
- (symbol-value hist))))
+ (minibuffer-with-setup-hook
+ (lambda () (setq-local history-add-new-input nil))
(funcall project-read-file-name-function
prompt all-files predicate hist mb-default))))
(when (and hist history-add-new-input)
- (add-to-history hist
- (propertize file 'project (project-root project))))
+ (add-to-history hist (propertize file 'project (project-root project))))
file))
(defun project-find-file-in (suggested-filename dirs project &optional include-all)
(while (equal pr-dir "")
;; If the user simply pressed RET, do this again until they don't.
(setq pr-dir
- (let (history-add-new-input)
+ (minibuffer-with-setup-hook
+ (lambda () (setq-local history-add-new-input nil))
(completing-read (format-prompt (or prompt "Select project"))
choices nil t nil 'project--dir-history))))
(if (equal pr-dir dir-choice)
(while (equal pr-name "")
;; If the user simply pressed RET, do this again until they don't.
(setq pr-name
- (let (history-add-new-input)
+ (minibuffer-with-setup-hook
+ (lambda () (setq-local history-add-new-input nil))
(completing-read (format-prompt (or prompt "Select project"))
table nil t nil 'project--name-history))))
(if (equal pr-name dir-choice)