Re: idlwave and emacs "empty input ring" [message #54090] |
Wed, 23 May 2007 11:02  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Wed, 23 May 2007 07:05:03 -0700, Rob wrote:
> That certainly helps in the case that I forget to C-d in the IDL session.
> There are two other situations that I regularly experience that you can
> perhaps help with.
> 1) Until I fixed a video card driver issue, iTool was crashing my xserver
> which caused a loss to changes in the IDL comint history. I suppose this
> could happen again.
> 2) I often leave an emacs/IDL open on my work computer. When I get home,
> I may do a bit more work by running emacs, etc across X; also a situation
> where I don't have access to the last comint history changes. This is not
> a big deal, just a "nice to have".
>
> For situation 2), is it possible to issue a HUP-like signal from a remote
> shell to kill the emacs running on my work computer in a way which invokes
> your save comint code above?
How about the following instead:
(add-hook 'idlwave-shell-mode-hook
(lambda ()
;; Auto-save buffer contents and input history
(add-hook
'auto-save-hook
(lambda ()
(let ((buf (idlwave-shell-buffer)))
(when (get-buffer buf)
(set-buffer buf)
(if (and idlwave-shell-save-command-history
(stringp idlwave-shell-command-history-file))
(condition-case nil
(comint-write-input-ring)
(error nil))))))
nil 'local)
(auto-save-mode t)
(add-hook 'idlwave-shell-sentinel-hook
(lambda ()
(delete-auto-save-file-if-necessary 'force)))))
This piggybacks on auto-save to write out the command history every time
an auto-save happens. It also auto-saves the contents of the *idl*
buffer (as some file name like #*idl*#28538NXc#), which might be useful if
you lost your session and wanted to see what was in it. If the process is
ended legitimately, this backup file is removed.
The only real issue here is if you have multiple Emacs + IDLWAVE Shell
sessions going at once, in which case they will step on each other's
toes writing to the same command history file (though that is more or
less true already). Let me know if this works well for you; I may
consider adding it as an option to a future version of IDLWAVE.
JD
|
|
|