help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Auto-saved files unexpectedly deleted


From: Kevin Rodgers
Subject: Re: Auto-saved files unexpectedly deleted
Date: Thu, 15 May 2014 23:32:36 -0600
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]