summaryrefslogtreecommitdiff
path: root/lisp/gud.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-10-29 11:14:05 +0000
committerRichard M. Stallman <rms@gnu.org>1994-10-29 11:14:05 +0000
commit256fc8d87ca5d238e5aba21df6ab3e902810e317 (patch)
tree7c4fcabfb5ef0c294e415c50cd5d0d0c8e766cf6 /lisp/gud.el
parent69b7802a1edc65074e2dbc190c7f429bef4086fb (diff)
downloademacs-256fc8d87ca5d238e5aba21df6ab3e902810e317.tar.gz
(gud-common-init): If file arg has no directory,
let the debugger search PATH, and don't set default-directory.
Diffstat (limited to 'lisp/gud.el')
-rw-r--r--lisp/gud.el21
1 files changed, 19 insertions, 2 deletions
diff --git a/lisp/gud.el b/lisp/gud.el
index 75e89821922..34e740bd50f 100644
--- a/lisp/gud.el
+++ b/lisp/gud.el
@@ -983,12 +983,29 @@ comint mode, which see."
(while (and w (= ?- (aref (car w) 0)))
(setq w (cdr w)))
(car w)))
+ (file-subst
+ (and file-word (substitute-in-file-name file-word)))
(args (delq file-word (cdr words)))
+ ;; If a directory was specified, expand the file name.
+ ;; Otherwise, don't expand it, so GDB can use the PATH.
+ ;; A file name without directory is literally valid
+ ;; only if the file exists in ., and in that case,
+ ;; omitting the expansion here has no visible effect.
(file (and file-word
- (expand-file-name (substitute-in-file-name file-word))))
+ (if (file-name-directory file-subst)
+ (expand-file-name file-subst)
+ file-subst)))
(filepart (and file-word (file-name-nondirectory file))))
(switch-to-buffer (concat "*gud-" filepart "*"))
- (and file-word (setq default-directory (file-name-directory file)))
+ ;; Set default-directory to the file's directory.
+ (and file-word
+ ;; Don't set default-directory if no directory was specified.
+ ;; In that case, either the file is found in the current directory,
+ ;; in which case this setq is a no-op,
+ ;; or it is found by searching PATH,
+ ;; in which case we don't know what directory it was found in.
+ (file-name-directory file)
+ (setq default-directory (file-name-directory file)))
(or (bolp) (newline))
(insert "Current directory is " default-directory "\n")
(apply 'make-comint (concat "gud-" filepart) program nil