unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Don't change default-directory in gud.el?
@ 2004-11-03  0:49 Nick Roberts
  2004-11-03  3:37 ` Stefan
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Roberts @ 2004-11-03  0:49 UTC (permalink / raw)



Currently, in gud.el, the default-directory of the GUD buffer gets set from
the pathname (if any) of the program to be debugged. This is not consistent
what happens if gdb is invoked from the command line, where the working
directory remains unchanged. As a general rule, I find it more annoying if
Emacs does something that I don't want than if it doesn't do something I do
want (Another example is Jan Nieuwenhuizen's grumble about M-x gdb guessing
the name of the executable).

As an example of where setting the default-directory doesn't really work. If
I have:

Run gdb (like this): gdb --annotate=3 ~/emacs/src/emacs core.1825

As Emacs sets default-directory to ~/emacs/src/, gdb sets the breakpoints in
~/emacs/src/.gdbinit that I don't want and can't find the core file.

So I'd like to remove the following from gud.el:

    (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)))

Any objections?

Nick

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Don't change default-directory in gud.el?
  2004-11-03  0:49 Don't change default-directory in gud.el? Nick Roberts
@ 2004-11-03  3:37 ` Stefan
  2004-11-03  7:29   ` Klaus Zeitler
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan @ 2004-11-03  3:37 UTC (permalink / raw)
  Cc: emacs-devel

> Currently, in gud.el, the default-directory of the GUD buffer gets set from
> the pathname (if any) of the program to be debugged. This is not consistent
> what happens if gdb is invoked from the command line, where the working
> directory remains unchanged. As a general rule, I find it more annoying if
> Emacs does something that I don't want than if it doesn't do something I do
> want (Another example is Jan Nieuwenhuizen's grumble about M-x gdb guessing
> the name of the executable).

I think the problem is not so much about whether Emacs does or doesn't do
something, but about how much work is needed to get the other behavior.
In the case of the chdir, it's actually surprisingly difficult to undo the
chdir, so I completely agree that it should be removed.


        Stefan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Don't change default-directory in gud.el?
  2004-11-03  3:37 ` Stefan
@ 2004-11-03  7:29   ` Klaus Zeitler
  0 siblings, 0 replies; 3+ messages in thread
From: Klaus Zeitler @ 2004-11-03  7:29 UTC (permalink / raw)
  Cc: Nick Roberts, emacs-devel

>>>>> "Stefan" == Stefan  <monnier@iro.umontreal.ca> writes:
    Stefan> 
    >> Currently, in gud.el, the default-directory of the GUD buffer gets set
    >> from the pathname (if any) of the program to be debugged. This is not
    >> consistent what happens if gdb is invoked from the command line, where
    >> the working directory remains unchanged.
    Stefan> 
    Stefan> I think the problem is not so much about whether Emacs does or
    Stefan> doesn't do something, but about how much work is needed to get the
    Stefan> other behavior.  In the case of the chdir, it's actually
    Stefan> surprisingly difficult to undo the chdir, so I completely agree
    Stefan> that it should be removed.

Actually I think in most cases it's what the user wants, but since this
behavior has bothered me every once in a while, I've been using the following
modification for gud-common-init:

;; Set the dir, in case the buffer already existed with a different dir.
;;  (setq default-directory dir)
    (setq default-directory (or gud-default-directory dir))


with the following definitions for gud-default-directory:

(defvar gud-default-directory nil
  "*Default directory for debugging process.
Note that the directory must end with a '/'.")


(defun gud-set-default-directory (dir)
  "*Set a new default directory for debugger process."
  (interactive
   (list (read-file-name "GUD default directory: " nil default-directory t)))
  (if (file-directory-p dir)
      (message "%s" (setq gud-default-directory
			  (expand-file-name (file-name-as-directory dir))))
    (message "Directory '%s' does not exist")))


(defun gud-show-default-directory ()
  "*Show default directory for debugger process."
  (interactive)
  (message "GUD default directory: %s" gud-default-directory))



-- 
 ------------------------------------------
|  Klaus Zeitler      Lucent Technologies  |
|  Email:             kzeitler@lucent.com  |
 ------------------------------------------
---
Subtlety is the art of saying what you think and
getting out of the way before it is understood.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-11-03  7:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-03  0:49 Don't change default-directory in gud.el? Nick Roberts
2004-11-03  3:37 ` Stefan
2004-11-03  7:29   ` Klaus Zeitler

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).