From: Kevin Layer <layer@known.net>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: Emacs-devel@gnu.org
Subject: Re: comint shell buffers autosaved to a file?
Date: Wed, 28 Mar 2018 11:05:01 -0700 [thread overview]
Message-ID: <CAGSZTjJvmWCju-4rpnxHrqeLN9N9cUd7OWhC1kHgSHagR1qDrA@mail.gmail.com> (raw)
In-Reply-To: <CAGSZTjK_iCx=tvmgoDCvNJsB-bWRiaNMf_iwdvcOgm=7atZ4=A@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2414 bytes --]
I don't know if it's cool to share this here, but I wanted to in case
someone else wanted to do the same, and have them save all in the same
place:
(defvar my-shell-auto-save-directory
(expand-file-name "~/tmp/shell-auto-saves/"))
;; Make sure it exists, this is an important directory:
(make-directory my-shell-auto-save-directory t)
(defvar my-shell-auto-save-file-name-prefix
(let ((s (system-name)))
(when (string-match "\\(.*\\)\\.franz\\.com$" s)
(setq s (substring s (match-beginning 1) (match-end 1))))
(format "%s-" s)))
(defun my-make-shell-auto-save-file-name ()
(interactive) ;; debugging only
(let* ((name (buffer-name))
base suffix)
(when (string-match "^\\*\\(.*\\)\\*\\(<\\(.*\\)>\\)?$" name)
(setq base (match-string 1 name))
(setq suffix (match-string 3 name))
(if suffix
(format "%s%s%s-%s.log" my-shell-auto-save-directory
my-shell-auto-save-file-name-prefix
base suffix)
(format "%s%s%s.log" my-shell-auto-save-directory
my-shell-auto-save-file-name-prefix base)))))
(defun my--around-advice--make-auto-save-file-name (orig-func)
(let (fn)
(cond
((and (null buffer-file-name)
(or (eq 'ssh-mode major-mode) (eq 'shell-mode major-mode))
(setq fn (my-make-shell-auto-save-file-name)))
fn)
(t (funcall orig-func)))))
(advice-add 'make-auto-save-file-name
:around
#'my--around-advice--make-auto-save-file-name)
;; Now, make sure auto-save-mode is on, for shell and ssh buffers:
(defun my-turn-on-auto-save-mode-hook ()
(auto-save-mode 1))
(add-hook 'shell-mode-hook 'my-turn-on-auto-save-mode-hook t)
(add-hook 'ssh-mode-hook 'my-turn-on-auto-save-mode-hook t)
On Tue, Mar 27, 2018 at 4:42 PM, Kevin Layer <layer@known.net> wrote:
> OK, the file was created after the auto-save-interval. Thanks, I'll think
> about whether this is good enough.
>
> On Tue, Mar 27, 2018 at 4:13 PM, Andreas Schwab <schwab@linux-m68k.org>
> wrote:
>
>> On Mär 27 2018, Kevin Layer <layer@known.net> wrote:
>>
>> > Any ideas on this? I'm willing to do some work to add it, if it's not
>> too
>> > hard.
>>
>> Just enable auto-save-mode.
>>
>> Andreas.
>>
>> --
>> Andreas Schwab, schwab@linux-m68k.org
>> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
>> "And now for something completely different."
>>
>
>
[-- Attachment #2: Type: text/html, Size: 4338 bytes --]
next prev parent reply other threads:[~2018-03-28 18:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-27 22:00 comint shell buffers autosaved to a file? Kevin Layer
2018-03-27 23:13 ` Andreas Schwab
2018-03-27 23:36 ` Kevin Layer
2018-03-27 23:39 ` Kevin Layer
2018-03-27 23:42 ` Kevin Layer
2018-03-28 18:05 ` Kevin Layer [this message]
2018-03-29 20:34 ` Kalman Reti
2018-04-02 20:10 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGSZTjJvmWCju-4rpnxHrqeLN9N9cUd7OWhC1kHgSHagR1qDrA@mail.gmail.com \
--to=layer@known.net \
--cc=Emacs-devel@gnu.org \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.