* Auto-saved files unexpectedly deleted
@ 2014-05-15 5:29 dont.spam.earl
2014-05-15 9:55 ` Michael Heerdegen
[not found] ` <mailman.1389.1400147758.1147.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 6+ messages in thread
From: dont.spam.earl @ 2014-05-15 5:29 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
I'd like to save "transcripts" of my Shell and other comint sessions with all I/O, not just the command history. I've created a "comint transcript" major-mode by adapting auto-saving but I'm running into a problem.
When I kill a comint buffer with a process, its associated transcript file is deleted. This occurs even though I'm around-wrapping 'delete-auto-save-file-if-necessary in files.el which deletes auto-save files. In fact, even though I'm tracing both that function and also delete-file, there's no tracing output for the deletion. This only occurs when I "C-x k" to kill the buffer, then say "yes" to kill it in spite of the running process. Interestingly, the transcript file is not deleted when I quit emacs and kill all buffers with processes.
The relevant code is included below. Any suggestions on what is going on here, or what to try next?
Thanks!
Earl
;;
;; Auto-save Comint mode transcripts
;;
(defadvice auto-save-file-name-p (after yes-auto-save-comint-transcripts activate)
"Also auto-save comint transcript files (without hashmarks)."
(setq ad-return-value
(or ad-return-value
(derived-mode-p 'comint-mode))))
(defadvice make-auto-save-file-name (after auto-save-comint-transcript-path activate)
"Make name for auto-saved comint transcript file (without hashmarks)."
(setq ad-return-value
(if (derived-mode-p 'comint-mode)
buffer-auto-save-file-name
ad-return-value)))
(defadvice delete-auto-save-file-if-necessary (around keep-auto-saved-comint-transcripts activate)
"Keep auto-saved comint transcript files."
(unless (derived-mode-p 'comint-mode)
ad-do-it))
;;
;; Comint mode
;;
(require 'comint)
(add-hook
'comint-mode-hook
'(lambda ()
(setq buffer-auto-save-file-name (make-comint-transcript-path t))
(auto-save-mode t)
))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Auto-saved files unexpectedly deleted
2014-05-15 5:29 Auto-saved files unexpectedly deleted dont.spam.earl
@ 2014-05-15 9:55 ` Michael Heerdegen
[not found] ` <mailman.1389.1400147758.1147.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2014-05-15 9:55 UTC (permalink / raw)
To: help-gnu-emacs
dont.spam.earl@gmail.com writes:
> Hi all,
>
> I'd like to save "transcripts" of my Shell and other comint sessions
> with all I/O, not just the command history. I've created a "comint
> transcript" major-mode by adapting auto-saving but I'm running into a
> problem.
I think it would be better not to hack into auto-save-mode. Why don't
you just save the buffer contents to your own file, e.g. using
`write-region'?
Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <mailman.1389.1400147758.1147.help-gnu-emacs@gnu.org>]
* Re: Auto-saved files unexpectedly deleted
[not found] ` <mailman.1389.1400147758.1147.help-gnu-emacs@gnu.org>
@ 2014-05-15 17:40 ` dont.spam.earl
2014-05-16 5:32 ` Kevin Rodgers
[not found] ` <mailman.1440.1400218387.1147.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 6+ messages in thread
From: dont.spam.earl @ 2014-05-15 17:40 UTC (permalink / raw)
To: help-gnu-emacs
On Thursday, May 15, 2014 2:55:21 AM UTC-7, Michael Heerdegen wrote:
> dont.spam.earl@gmail.com writes:
>
>
>
> > Hi all,
>
> >
>
> > I'd like to save "transcripts" of my Shell and other comint sessions
>
> > with all I/O, not just the command history. I've created a "comint
>
> > transcript" major-mode by adapting auto-saving but I'm running into a
>
> > problem.
>
>
>
> I think it would be better not to hack into auto-save-mode. Why don't
>
> you just save the buffer contents to your own file, e.g. using
>
> `write-region'?
>
>
>
> Michael.
Yes, I'll admit that occurred to me ;) ...especially when I saw that it's part of files.el and not factored out.
I'm reluctant though because I want to do auto-saving of these buffers and I don't want to reimplement and maintain a lot of the auto-save functionality.
Earl
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Auto-saved files unexpectedly deleted
2014-05-15 17:40 ` dont.spam.earl
@ 2014-05-16 5:32 ` Kevin Rodgers
[not found] ` <mailman.1440.1400218387.1147.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2014-05-16 5:32 UTC (permalink / raw)
To: help-gnu-emacs
On 5/15/14 11:40 AM, dont.spam.earl@gmail.com wrote:
> On Thursday, May 15, 2014 2:55:21 AM UTC-7, Michael Heerdegen wrote:
>> dont.spam.earl@gmail.com writes:
>>> I'd like to save "transcripts" of my Shell and other comint sessions
>>> with all I/O, not just the command history. I've created a "comint
>>> transcript" major-mode by adapting auto-saving but I'm running into a
>>> problem.
>>
>> I think it would be better not to hack into auto-save-mode. Why don't
>> you just save the buffer contents to your own file, e.g. using
>> `write-region'?
>
> Yes, I'll admit that occurred to me ;) ...especially when I saw that it's part of files.el and not factored out.
>
> I'm reluctant though because I want to do auto-saving of these buffers and I don't want to reimplement and maintain a lot of the auto-save functionality.
I'd start with something minimal, like:
(defun set-comint-buffer-file-name ()
"Set `buffer-file-name' so that input and output are saved.
Also set `buffer-offer-save', but assume that `auto-save-default' is non-nil."
(setq buffer-file-name
(format "~/.emacs_comint_%d.txt"
;; TO DO: handle `network' and `serial' process-type, in
;; addition to `real'.
(process-id (get-buffer-process (current-buffer)))))
(setq buffer-offer-save t)) ; just in case
(add-hook 'comint-exec-hook 'set-comint-buffer-file-name)
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <mailman.1440.1400218387.1147.help-gnu-emacs@gnu.org>]
* Re: Auto-saved files unexpectedly deleted
[not found] ` <mailman.1440.1400218387.1147.help-gnu-emacs@gnu.org>
@ 2014-05-18 17:03 ` dont.spam.earl
2014-05-25 14:17 ` Jude DaShiell
0 siblings, 1 reply; 6+ messages in thread
From: dont.spam.earl @ 2014-05-18 17:03 UTC (permalink / raw)
To: help-gnu-emacs
On Thursday, May 15, 2014 10:32:36 PM UTC-7, Kevin Rodgers wrote:
> On 5/15/14 11:40 AM, dont.spam.earl@gmail.com wrote:
>
> > On Thursday, May 15, 2014 2:55:21 AM UTC-7, Michael Heerdegen wrote:
>
> >> dont.spam.earl@gmail.com writes:
>
> >>> I'd like to save "transcripts" of my Shell and other comint sessions
>
> >>> with all I/O, not just the command history. I've created a "comint
>
> >>> transcript" major-mode by adapting auto-saving but I'm running into a
>
> >>> problem.
>
> >>
>
> >> I think it would be better not to hack into auto-save-mode. Why don't
>
> >> you just save the buffer contents to your own file, e.g. using
>
> >> `write-region'?
>
> >
>
> > Yes, I'll admit that occurred to me ;) ...especially when I saw that it's part of files.el and not factored out.
>
> >
>
> > I'm reluctant though because I want to do auto-saving of these buffers and I don't want to reimplement and maintain a lot of the auto-save functionality.
>
>
>
> I'd start with something minimal, like:
>
>
>
> (defun set-comint-buffer-file-name ()
>
> "Set `buffer-file-name' so that input and output are saved.
>
> Also set `buffer-offer-save', but assume that `auto-save-default' is non-nil."
>
> (setq buffer-file-name
>
> (format "~/.emacs_comint_%d.txt"
>
> ;; TO DO: handle `network' and `serial' process-type, in
>
> ;; addition to `real'.
>
> (process-id (get-buffer-process (current-buffer)))))
>
> (setq buffer-offer-save t)) ; just in case
>
>
>
> (add-hook 'comint-exec-hook 'set-comint-buffer-file-name)
>
>
>
> --
>
> Kevin Rodgers
>
> Denver, Colorado, USA
Yes, that's a good idea to use 'comint-exec-hook. I hadn't thought of that. Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Auto-saved files unexpectedly deleted
2014-05-18 17:03 ` dont.spam.earl
@ 2014-05-25 14:17 ` Jude DaShiell
0 siblings, 0 replies; 6+ messages in thread
From: Jude DaShiell @ 2014-05-25 14:17 UTC (permalink / raw)
To: dont.spam.earl; +Cc: help-gnu-emacs
man script for some interesting reading. Emacs could run that for you
inside one of its shells and you catch everything that happens and can
if you like append to existing files. Afterwards, it may be necessary
to clean up the output file.
On Sun, 18 May 2014, dont.spam.earl@gmail.com wrote:
> On Thursday, May 15, 2014 10:32:36 PM UTC-7, Kevin Rodgers wrote:
> > On 5/15/14 11:40 AM, dont.spam.earl@gmail.com wrote:
> >
> > > On Thursday, May 15, 2014 2:55:21 AM UTC-7, Michael Heerdegen wrote:
> >
> > >> dont.spam.earl@gmail.com writes:
> >
> > >>> I'd like to save "transcripts" of my Shell and other comint sessions
> >
> > >>> with all I/O, not just the command history. I've created a "comint
> >
> > >>> transcript" major-mode by adapting auto-saving but I'm running into a
> >
> > >>> problem.
> >
> > >>
> >
> > >> I think it would be better not to hack into auto-save-mode. Why don't
> >
> > >> you just save the buffer contents to your own file, e.g. using
> >
> > >> `write-region'?
> >
> > >
> >
> > > Yes, I'll admit that occurred to me ;) ...especially when I saw that it's part of files.el and not factored out.
> >
> > >
> >
> > > I'm reluctant though because I want to do auto-saving of these buffers and I don't want to reimplement and maintain a lot of the auto-save functionality.
> >
> >
> >
> > I'd start with something minimal, like:
> >
> >
> >
> > (defun set-comint-buffer-file-name ()
> >
> > "Set `buffer-file-name' so that input and output are saved.
> >
> > Also set `buffer-offer-save', but assume that `auto-save-default' is non-nil."
> >
> > (setq buffer-file-name
> >
> > (format "~/.emacs_comint_%d.txt"
> >
> > ;; TO DO: handle `network' and `serial' process-type, in
> >
> > ;; addition to `real'.
> >
> > (process-id (get-buffer-process (current-buffer)))))
> >
> > (setq buffer-offer-save t)) ; just in case
> >
> >
> >
> > (add-hook 'comint-exec-hook 'set-comint-buffer-file-name)
> >
> >
> >
> > --
> >
> > Kevin Rodgers
> >
> > Denver, Colorado, USA
>
> Yes, that's a good idea to use 'comint-exec-hook. I hadn't thought of that. Thanks!
>
>
jude <jdashiel@shellworld.net>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-05-25 14:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-15 5:29 Auto-saved files unexpectedly deleted dont.spam.earl
2014-05-15 9:55 ` Michael Heerdegen
[not found] ` <mailman.1389.1400147758.1147.help-gnu-emacs@gnu.org>
2014-05-15 17:40 ` dont.spam.earl
2014-05-16 5:32 ` Kevin Rodgers
[not found] ` <mailman.1440.1400218387.1147.help-gnu-emacs@gnu.org>
2014-05-18 17:03 ` dont.spam.earl
2014-05-25 14:17 ` Jude DaShiell
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).