From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Kalman Reti Newsgroups: gmane.emacs.devel Subject: Re: comint shell buffers autosaved to a file? Date: Thu, 29 Mar 2018 16:34:49 -0400 Message-ID: References: <87k1tx9ko8.fsf@linux-m68k.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000001f8bac0568930e87" X-Trace: blaine.gmane.org 1522355614 7499 195.159.176.226 (29 Mar 2018 20:33:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 29 Mar 2018 20:33:34 +0000 (UTC) Cc: Andreas Schwab , emacs-devel@gnu.org To: Kevin Layer Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 29 22:33:30 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f1eEj-0001qn-1O for ged-emacs-devel@m.gmane.org; Thu, 29 Mar 2018 22:33:29 +0200 Original-Received: from localhost ([::1]:55913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1eGm-0004wb-Ie for ged-emacs-devel@m.gmane.org; Thu, 29 Mar 2018 16:35:36 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1eG5-0004vr-8n for emacs-devel@gnu.org; Thu, 29 Mar 2018 16:34:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1eG3-0000Xn-CK for emacs-devel@gnu.org; Thu, 29 Mar 2018 16:34:53 -0400 Original-Received: from mail-ot0-x231.google.com ([2607:f8b0:4003:c0f::231]:45756) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1eG3-0000XA-5H for emacs-devel@gnu.org; Thu, 29 Mar 2018 16:34:51 -0400 Original-Received: by mail-ot0-x231.google.com with SMTP id h26-v6so7698782otj.12 for ; Thu, 29 Mar 2018 13:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=pCIE635ccjGzX/UGWhFFg8qyNsUByJb2p8zcxaAeKx8=; b=fRHv4I6MGo53pxbZ0UPGXNrwhZtXD/JuLqyfpod6SR4SyuHiS3atRfpY+cXsZAngZY IHC27lQGKV8QVYPWXe37IkBnU78CvN0umYZW+1Q6nmYG/iWWDoR83wbDYyjvlI67di83 JROyTu4mPjiVir4Fi7yXTm8nXr4rwTiwGzmjkpMy8fh5kSpui2yQAkcf2GoTcbgRPY9i F/9XLmdCuMHtz97e/mknMqhfzrBMLY/xLqiALni1bNiQlYm8XBNosnb5VimWJzGLTDIt hrX3EOnIiOihWVuIq8+mVcEpPPSoV007Jg4mzUM0n44DG5KwSbLcUo+/u0NO+/2wBFhD xYZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=pCIE635ccjGzX/UGWhFFg8qyNsUByJb2p8zcxaAeKx8=; b=RfpD47CgL6aUQfFqZT0t6FgSHb8SVDVJSMDS65Q4Q4q3NK1qfb+pdFWQMXPo/4zbz6 tQ9bBlCANut17M+ViJr9HmPcsrL9FwGLvcBjwr46qDK/tpruDP3Swk6VWX5M6/zASfpJ /F4s/+6zisYmu44RhpaDa2tC/w9yFXHpADeGXPb4/JuPr2y/uYAGlQzGslPZU2skeTDX yeuRhMjtBnDUiHi+/hd3hZxp85z2A+tr2krNhIELbfnoDH80hHDvM/QHeYaG5NbUJdgE 1uAIawT0ILHIxLQBEVuDLoFZtKw2i6CeXmmpHCfrB1TZGltLwMpXM9/7moTR4m3YO5TR Evig== X-Gm-Message-State: ALQs6tDmRBaZUJz69TlOndt6sAuKh8uOh4Hd/hODM3HZIR1ucsT+0X1O Vw9Tea2v9B80jI/tQ690/bErstJoEpzJbYwrUmg= X-Google-Smtp-Source: AIpwx4+9FOoSGuu2NIti/ZTBhZb8Dctdcnb+wFjoRlWHetZ1KxMDX7RU1yv1E0VZtiRWWXgt0kCHHERtxnNlfJMUFtE= X-Received: by 2002:a9d:4d12:: with SMTP id n18-v6mr6083770otf.170.1522355689981; Thu, 29 Mar 2018 13:34:49 -0700 (PDT) Original-Received: by 10.201.66.131 with HTTP; Thu, 29 Mar 2018 13:34:49 -0700 (PDT) Original-Received: by 10.201.66.131 with HTTP; Thu, 29 Mar 2018 13:34:49 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c0f::231 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:224167 Archived-At: --0000000000001f8bac0568930e87 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I just c-x c-w to a filename of my own choosing. Autosaves are then ##. This has worked for many years in both shell and rlogin buffers. On Mar 28, 2018 2:05 PM, "Kevin Layer" wrote: 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 wrote: > OK, the file was created after the auto-save-interval. Thanks, I'll thin= k > about whether this is good enough. > > On Tue, Mar 27, 2018 at 4:13 PM, Andreas Schwab > wrote: > >> On M=C3=A4r 27 2018, Kevin Layer 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 =3D 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4E= D5 >> "And now for something completely different." >> > > --0000000000001f8bac0568930e87 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I just c-x c-w to a filename of my own choosing. Aut= osaves are then #<myfilename>#. This has worked for many years in bot= h shell and rlogin buffers.

On Mar 28, 2018 2:05 PM, "Kevin Layer" <layer@known.net> wrote:
I don't know if it= 9;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
=C2=A0 =C2=A0 (expand-f= ile-name "~/tmp/shell-auto-saves/"))

;; = Make sure it exists, this is an important directory:
(make-direct= ory my-shell-auto-save-directory t)

(defvar my-she= ll-auto-save-file-name-prefix
=C2=A0 =C2=A0 (let ((s (system= -name)))
=C2=A0 =C2=A0 =C2=A0 (when (string-match "\\(.*\\)\= \.franz\\.com$" s)
(setq s (substring s (match-beginning 1) (match-end 1))))
=C2= =A0 =C2=A0 =C2=A0 (format "%s-" s)))

(de= fun my-make-shell-auto-save-file-name ()
=C2=A0 (interactive= ) ;; debugging only
=C2=A0 (let* ((name (buffer-name))
= base suffix)
=C2=A0= =C2=A0 (when (string-match "^\\*\\(.*\\)\\*\\(<\\(.*\\)>\\= )?$" name)
=C2=A0 =C2=A0 =C2=A0 (setq base (match-string 1 n= ame))
=C2=A0 =C2=A0 =C2=A0 (setq suffix (match-string 3 name))
=C2=A0 =C2=A0 =C2=A0 (if suffix
=C2=A0 (format "%s%s%s-%s.log" my-shell-auto-= save-directory
=C2= =A0 =C2=A0my-shell-auto-save-file-name-prefix
=C2=A0 =C2=A0base suffix)
(format "%s%s%s.log" my-she= ll-auto-save-directory
my-shell-auto-save-file-name-prefix base)))))

(defun my--around-advice--make-auto-save-file-name (orig-func)
=C2=A0 (let (fn)
=C2=A0 =C2=A0 (cond
=C2=A0 = =C2=A0 =C2=A0((and (null buffer-file-name)
=C2=A0 =C2=A0(or (eq 'ssh-mode major-mode) (eq &= #39;shell-mode major-mode))
= =C2=A0 =C2=A0(setq fn (my-make-shell-auto-save-file-name)))
=C2=A0 =C2=A0 =C2=A0 fn)
=C2=A0 =C2=A0 =C2=A0(t (funcall = orig-func)))))

(advice-add 'make-auto-save-fil= e-name
=C2=A0 =C2=A0= :around
=C2=A0 =C2= =A0 #'my--around-advice--make-auto-save-file-name)

<= /div>
;; Now, make sure auto-save-mode is on, for shell and ssh buffers= :

(defun my-turn-on-auto-save-mode-hook ()
=C2=A0 (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)
<= div>
<= br>
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.=C2=A0 = 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=C3=A4r 27 2018, Kevin Layer <layer@known.net> wrote:

> Any ideas on this?=C2=A0 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 =3D 58CA 54C7 6D53 942B 1756=C2=A0 01D3 44D5 214B 8276 = 4ED5
"And now for something completely different."



--0000000000001f8bac0568930e87--