aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-10-23 15:07:44 -0400
committerStefan Monnier2012-10-23 15:07:44 -0400
commitc79825bd22f07399351d626fbc8060941aba36a5 (patch)
tree6747ae533b3ebb8d7a3f3250bcfa215f7166e4f7
parent9c3e39f3ff724fdd0e622a8fde608e6346991346 (diff)
downloademacs-c79825bd22f07399351d626fbc8060941aba36a5.tar.gz
emacs-c79825bd22f07399351d626fbc8060941aba36a5.zip
* lisp/progmodes/compile.el (compilation-start): Try to handle common
quoting of `cd' argument. Fixes: debbugs:12640
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/progmodes/compile.el20
2 files changed, 17 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 05b7cfc176e..df7420c30a3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12012-10-23 Stefan Monnier <monnier@iro.umontreal.ca> 12012-10-23 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * progmodes/compile.el (compilation-start): Try to handle common
4 quoting of `cd' argument (bug#12640).
5
3 * vc/diff-mode.el (diff-hunk): `save-excursion' while refining 6 * vc/diff-mode.el (diff-hunk): `save-excursion' while refining
4 (bug#12671). 7 (bug#12671).
5 8
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 10fd7a75eaa..06525b354b1 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1568,12 +1568,20 @@ Returns the compilation buffer created."
1568 ;; Then evaluate a cd command if any, but don't perform it yet, else 1568 ;; Then evaluate a cd command if any, but don't perform it yet, else
1569 ;; start-command would do it again through the shell: (cd "..") AND 1569 ;; start-command would do it again through the shell: (cd "..") AND
1570 ;; sh -c "cd ..; make" 1570 ;; sh -c "cd ..; make"
1571 (cd (if (string-match "\\`\\s *cd\\(?:\\s +\\(\\S +?\\)\\)?\\s *[;&\n]" 1571 (cd (cond
1572 command) 1572 ((not (string-match "\\`\\s *cd\\(?:\\s +\\(\\S +?\\|'[^']*'\\|\"\\(?:[^\"`$\\]\\|\\\\.\\)*\"\\)\\)?\\s *[;&\n]"
1573 (if (match-end 1) 1573 command))
1574 (substitute-env-vars (match-string 1 command)) 1574 default-directory)
1575 "~") 1575 ((not (match-end 1)) "~")
1576 default-directory)) 1576 ((eq (aref command (match-beginning 1)) ?\')
1577 (substring command (1+ (match-beginning 1))
1578 (1- (match-end 1))))
1579 ((eq (aref command (match-beginning 1)) ?\")
1580 (replace-regexp-in-string
1581 "\\\\\\(.\\)" "\\1"
1582 (substring command (1+ (match-beginning 1))
1583 (1- (match-end 1)))))
1584 (t (substitute-env-vars (match-string 1 command)))))
1577 (erase-buffer) 1585 (erase-buffer)
1578 ;; Select the desired mode. 1586 ;; Select the desired mode.
1579 (if (not (eq mode t)) 1587 (if (not (eq mode t))