(set-buffer buffer)
(if (save-excursion
(goto-char (point-max))
- (beginning-of-line)
+ (forward-line 0)
(not (looking-at comint-prompt-regexp)))
nil
;; Much of this copied from GDB complete, but I'm grabbing the stack
(setq seen-e t))
(funcall shift))
- (when (not seen-e)
+ (unless seen-e
(if (or (not args)
(string-match "^-" (car args)))
(error "Can't use stdin as the script to debug."))
;; as -e macs.
(if (and args (equal "--" (car args)))
(funcall shift)
- (and seen-e (setq new-args (cons "--" new-args))))
+ (and seen-e (push "--" new-args)))
- (setq new-args (cons "-emacs" new-args))
+ (push "-emacs" new-args)
(while args
(funcall shift))
;; in the selected window.
;;;###autoload (add-hook 'same-window-regexps "\\*gud-.*\\*\\(\\|<[0-9]+>\\)")
+(defcustom gud-chdir-before-run t
+ "Non-nil if GUD should `cd' to the debugged executable."
+ :group 'gud
+ :type 'boolean)
+
;; Perform initializations common to all debuggers.
;; The first arg is the specified command line,
;; which starts with the program to debug.
;; The other three args specify the values to use
;; for local variables in the debugger buffer.
-(defun gud-common-init (command-line massage-args marker-filter find-file)
+(defun gud-common-init (command-line massage-args marker-filter &optional find-file)
(let* ((words (split-string command-line))
(program (car words))
;; Extract the file name from WORDS
(pop-to-buffer (concat "*gud" filepart "*"))
;; Set default-directory to the file's directory.
(and file-word
+ gud-chdir-before-run
;; 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,
(gud-mode)
(make-local-variable 'gud-marker-filter)
(setq gud-marker-filter marker-filter)
- (make-local-variable 'gud-find-file)
- (setq gud-find-file find-file)
+ (if find-file (set (make-local-variable 'gud-find-file) find-file))
(set-process-filter (get-buffer-process (current-buffer)) 'gud-filter)
(set-process-sentinel (get-buffer-process (current-buffer)) 'gud-sentinel)