Skip to content

Allow recovering from when remote editing session closed unexpectedly (e.g. by backups or saving a history) #75

@meliache

Description

@meliache

So it happened a couple of times that my Firefox tab with some text input was accidentally closed and I was surprised that the associated atomic-chrome buffer closed as well. There was no backup as it's not a file-visiting buffer.

Is there a way so set up temporary backups or at least save a history? Today I added a history-saving function myself to atomic-chrome-edit-done-hook and with a defcustom this could be made opt in:

  (defvar atomic-chrome-history-dir
	(file-name-concat no-littering-var-directory "atomic-chrome" "history")
	"Directory where to save atomic chrome buffer contents.")

  (defun my-atomic-chrome-save-to-file ()
	"Save atomic chrome buffer contents to file."
	(let* ((timestamp (format-time-string "%F_%T"))
		   (escaped-buffer-name (file-name-base (make-auto-save-file-name)))
		   (atomic-chrome-save-file-name
			(file-name-concat atomic-chrome-history-dir
							  (format "%s_%s" escaped-buffer-name timestamp))))
	  (make-directory atomic-chrome-history-dir 'parents)
	  (write-region nil nil atomic-chrome-save-file-name nil nil nil 'mustbenew)
	  (message "Wrote backup to %s" atomic-chrome-save-file-name)))

  (add-hook 'atomic-chrome-edit-done-hook #'my-atomic-chrome-save-to-file)

It's not a backup as nothing is saved during editing. For that it would be nice somehow utilize Emacs' built-in backup/auto-save functions, but for most of my use-cases that's good enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions