> > Seems like after extracting the <blabla> arg and substituting the values
> > of any referenced environment variables (already implemented by the
> > current hack), you could pass the result to file-expand-wildcards. Then
> > check that there is only a single directory in the result, and pass that
> > directory to `cd'.
>
> Indeed. Could you take care of it?
Sure, sorry for the delay:
**** compile.el~ Fri Jan 21 18:08:13 2011
--- compile.el Wed Oct 2 07:25:47 2013
***************
*** 1217,1223 ****
;; sh -c "cd ..; make"
(cd (if (string-match "^\\s *cd\\(?:\\s +\\(\\S +?\\)\\)?\\s *[;&\n]" command)
(if (match-end 1)
! (substitute-env-vars (match-string 1 command))
"~")
default-directory))
(erase-buffer)
--- 1217,1229 ----
;; sh -c "cd ..; make"
(cd (if (string-match "^\\s *cd\\(?:\\s +\\(\\S +?\\)\\)?\\s *[;&\n]" command)
(if (match-end 1)
! (let* ((substituted-dir
! (substitute-env-vars (match-string 1 command)))
! (expanded-dir
! (file-expand-wildcards substituted-dir)))
! (if (= (length expanded-dir) 1)
! (car expanded-dir)
! substituted-dir))
"~")
default-directory))
(erase-buffer)