emacs save all buffers on gud debug command - emacs

I have (setq compilation-ask-about-save nil) in my init.el, so all buffers are saved before running compilation. I would like similar behavior when running gdb and pdb. Is it possible?

Related

Launching eshell when starting up emacs from terminal with cwd

I added a hook to my init.el to launch Emacs on eshell.
;;start on eshell
(add-hook 'emacs-startup-hook 'eshell)
The thing is, I often launch Emacs from the terminal and would love to have eshell working directory being the working directory of the terminal from which I launched Emacs.
Let's say I'm in a directory X, and launch Emacs
~/X $ emacs
I want this to happen
Welcome to the Emacs shell
~/X $
For now, I have added
(cd "~")
to my init.el, as a temporary solution (changes emacs path to home), but it's not good enough.
Edit
I want to run Emacs in its gui.
Edit 2
Chris's answer worked if not using open -a emacs to launch the application. But just with the executable path instead.
You can detect that Emacs is running in a terminal when the function display-graphic-p returns nil, and you can get the directory from which you invoked Emacs from the default-directory variable.
So something like
(when (not (display-graphic-p))
(cd default-directory)
(eshell))
in your init should change to the "current" directory and then launch eshell when Emacs is invoked from the terminal.
If you always wish to invoke eshell you should be able to remove (eshell) from the code and simply keep your emacs-startup-hook.
Edit: Replaced variable window-system with call to function display-graphic-p as recommended in this answer.
Edit 2: If you simply want to modify your emacs-startup-hook to change to whatever directory you invoke Emacs from and then launch eshell (regardless of the windowing system), you can use something like
(add-hook 'emacs-startup-hook
(lambda ()
(cd default-directory)
(eshell)))

What files Emacs load by default

I have weird error when I run Emacs it show u when I run Emacs normaly but not when I run emacs -q and then load .emacs by hand using load-file.
So my question is what other files Emacs may load on Init?
Documented in the manual at:
C-hig(emacs) Init File RET

stop emacs swapping windows when setting breakpoints

Context: This is GNU Emacs 23.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1) running on Debian 6.0.7.
When running pdb (M-x pdb), emacs switches which buffer is in which window when I set a breakpoint. I've searched the internet and here, and haven't yet found a way to stop this. Here's the scenario:
I'm using a wide window which is split hoirizontally for side-by-side working. Once I've started pdb (M-x pdb) with my python file, I have one window which has my debug session (indicating gud-pathfile.py). The other window has my pathfile.py source file. Each time I click on a line in the source and then click on the red "set breakpoint" button, the windows swap (if the .py file was in the right window, it's now in the left, etc.).
Thank you for your time and help.
Blessings,
Doug
Here's a standard solution. It makes it very easy to restore the
previous window configuration.
(winner-mode)
(global-set-key (kbd "<f7>") 'winner-undo)
(global-set-key (kbd "C-<f7>") 'winner-redo)

How do I control emacs from a terminal?

I'm trying to drive emacs on OSX using Dragon Naturally Speaking running inside a Windows VM. Rather than running emacs in the VM, I'd like to drive an emacs (built from the HEAD of the repository) already running on the mac side of things. So, after a hunt through the emacs lisp manual I came up with the following snippets of lisp (currently running from the scratch buffer while I work stuff out):
;; This part is run from an emacsclient -t session
(defvar slave-frame last-event-frame)
;; and this is run in a GUI frame
(defadvice handle-switch-frame (after update-slave-redirect-advice activate)
(unless (eq last-event-frame slave-frame)
(redirect-frame-focus slave-frame last-event-frame)))
And all is well. I type into the terminal window, displaying buffer A and my typing appears in the GUI frame busily dsplaying buffer B. Great. Until I do C-x C-f or any other command that needs the minibuffer, at which point I get the error Terminal 1 is locked, cannot read from it.
I'm I barking up the wrong tree here, or is there a way to make redirect-frame-focus work nicely with commands that use the minibuffer?
Piers,
What behavior do you want, redirection to a minibuffer on the (Windows) client or a minibuffer on the server? Also, what version/flavor of emacs are you using?

Emacs 23.1 and Mac OS X problem with files drag and drop

I've just compiled and installed emacs 23.1 on my mac. It's running Leopard 10.5.8. And I've noticed that dragging and dropping does not work correctly (as it used to work with emacs 22). Now when dragging a file to the emacs icon on the dock, Emacs will start with two windows (frames in its terminology), one showing the startup screen and the other with the contents of the file. I've tried to get rid of this behaviour and I've set 'inhibit-startup-screen' option to t. But that only helped with this problem.
The other problem that I have is that when dragging a file onto a running emacs window, it justs shows the contents of the file in the existing buffer, instead of opening a new buffer (named the same as the file).
Any help with that?
I've compiled emacs myself using guidlines from this page:
link text
Also I've noticed that this version of Emacs has been rather flaky - it crashed a few times. I do not remember such situations when using previous versions. Any help will be highly appreciated.
Just to have the information regarding this problem more complete - there's a whole page in emacs info dedicated to Mac OS X builds.
Here's the link to web version: emacs info about ns events
Also I've found that when using Emacs 23 as an external editor for XCode, each file gets opened in a different frame (window). To fix this, just add:
(setq ns-pop-up-frames nil)
to your .emacs file
Putting the following in your .emacs file will help. You will either have to restart Emacs or evaluate the code.
(define-key global-map [ns-drag-file] 'my-ns-open-files)
(defun my-ns-open-files ()
"Open files in the list `ns-input-file'."
(interactive)
(mapc 'find-file ns-input-file)
(setq ns-input-file nil))