@@ -138,6 +138,31 @@ BASE-DIR is the prefix dir to add to each autoload path."
138138
139139 autoloads))
140140
141+ (defun ede-php-autoload-composer--merge-autoload-paths (base-paths new-paths )
142+ " Merge two paths in a autoload file in one.
143+
144+ BASE-PATHS and NEW-PATHS are either string opr list of strings.
145+
146+ It will output a list of strings with each of base and new paths in it."
147+ (let ((list-base-path (if (stringp base-paths) (list base-paths) base-paths))
148+ (list-new-paths (if (stringp new-paths) (list new-paths) new-paths)))
149+ (append list-base-path list-new-paths)))
150+
151+ (defun ede-php-autoload-composer--merge-autoload-entries (base-entries new-entries )
152+ " Merge two autoload entries (right after the autoload entry).
153+
154+ BASE-ENTRIES and NEW-ENTRIES are the entries to merge."
155+ (let ((current-entries base-entries)
156+ pair
157+ pair-path)
158+ (cl-loop for (ns . paths) in new-entries do
159+ (setq pair (assoc ns current-entries)
160+ pair-path (cdr pair))
161+ (if pair
162+ (setf (cdr pair) (ede-php-autoload-composer--merge-autoload-paths pair-path paths))
163+ (setq current-entries (push (cons ns paths) current-entries))))
164+ current-entries))
165+
141166(defun ede-php-autoload-composer-merge-autoloads (base-autoloads new-autoloads )
142167 " Merge two internal autoload definitions in one.
143168
@@ -156,7 +181,7 @@ NEW-AUTOLOADS will be merged into BASE-AUTOLOADS. BASE-AUTOLOADS will be mutate
156181
157182 autoloads (plist-put autoloads
158183 key
159- (append
184+ (ede-php-autoload-composer--merge-autoload-entries
160185 (plist-get autoloads key)
161186 value))
162187
0 commit comments