@@ -64,15 +64,16 @@ DIR is the directory to search from."
6464(defun ede-php-autoload-project-file-for-dir (&optional dir )
6565 " Return a full file name to the project file stored in DIR."
6666 (let ((proj (ede-php-autoload-file-existing dir)))
67- (when proj (oref proj : file ))))
67+ (when proj (oref proj file))))
6868
6969;;;### autoload
70- (defun ede-php-autoload-project-root (&optional dir )
71- " Get the root directory for DIR."
72- (let ((projfile (ede-php-autoload-project-file-for-dir
73- (or dir default-directory))))
74- (when projfile
75- (file-name-directory projfile))))
70+ (defun ede-php-autoload-proj-root ()
71+ " Auto-detect composer project root.
72+
73+ Return the parent directory of the current buffer file that contains a composer.json file."
74+ (let ((dominating-file (locate-dominating-file (or (buffer-file-name ) default-directory) ede-php-autoload-composer-file)))
75+ (when dominating-file
76+ (file-name-directory dominating-file))))
7677
7778; ; Composer project detection
7879
@@ -99,7 +100,7 @@ intended to be a subproject, so this argument is ignored."
99100 :name " PHP AUTOLOAD"
100101 :file 'ede-php-autoload
101102 :proj-file " composer.json"
102- :proj-root 'ede-php-autoload-project -root
103+ :proj-root 'ede-php-autoload-proj -root
103104 :load-type 'ede-php-autoload-load
104105 :class-sym 'ede-php-autoload-project
105106 :new-p nil
@@ -163,7 +164,7 @@ to the associated directories."
163164 :class-loader (ede-php-autoload-create-class-loader class-autoloads)
164165 :include-path (plist-get (car fields) :include-path )
165166 :system-include-path (plist-get (car fields) :system-include-path ))))
166- (let ((f (expand-file-name (oref this : file ))))
167+ (let ((f (expand-file-name (oref this file))))
167168 ; ; Remove any previous entries from the main list.
168169 (let ((old (eieio-instance-tracker-find (file-name-directory f)
169170 :directory
0 commit comments