|Subject:||Re: comint shell buffers autosaved to a file?|
|Date:||Thu, 29 Mar 2018 16:34:49 -0400|
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-directorymy-shell-auto-save-file-name- prefixbase suffix)(format "%s%s%s.log" my-shell-auto-save-directorymy-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 <address@hidden> 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 <address@hidden> wrote:On Mär 27 2018, Kevin Layer <address@hidden> wrote:
> Any ideas on this? I'm willing to do some work to add it, if it's not too
Just enable auto-save-mode.
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
|[Prev in Thread]||Current Thread||[Next in Thread]|