From 63a6e2e026e3d91471702f2c1652af9d24462bde Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 18 Feb 2025 09:38:23 +0100 Subject: [PATCH] Drop project-file-history-behavior --- lisp/progmodes/project.el | 49 +++++++-------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 1e85336bf6a..da6785d92b0 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1108,12 +1108,10 @@ If INCLUDE-ALL is non-nil, or with prefix argument when called 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)) @@ -1131,27 +1129,6 @@ For the arguments list, see `project--read-file-cpd-relative'." :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) @@ -1210,24 +1187,14 @@ by the user at will." (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) @@ -1915,7 +1882,8 @@ When PROMPT is non-nil, use it as the prompt string." (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) @@ -1952,7 +1920,8 @@ When PROMPT is non-nil, use it as the prompt string." (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) -- 2.39.5