我成功使用以下代码导致emacs保存每个文件的许多版本。但我无法弄清楚你在emacs中使用哪些命令来将这些文件实际加载到缓冲区中。
我期待某种历史查看器命令!我什么都找不到。
(setq backup-directory-alist '(("." . "~/auto-saves")))
(setq version-control t
kept-old-versions 2 kept-new-versions 200
delete-old-versions t backup-by-copying t)
答案 0 :(得分:2)
您只需打开要保存的目录中的文件(- hosts: host2
become: yes
tasks:
- command: ipa host-add "{{ hostvars['host1']['public_dns'] }}" --password=xxxxx
)即可。但是backup-walker包更好。
更新:强烈建议您使用~/autosaves
包来保持no-littering
(和~/.emacs.d
)的清洁。这是我的备份配置(假设您已设置$HOME
并设置了melpa):
use-package
如果您不想使用(use-package no-littering)
(setq make-backup-files t
vc-make-backup-files t
version-control t
kept-new-versions 128
kept-old-versions 0
delete-old-versions t
backup-by-copying t)
(defun force-backup-of-buffer ()
(setq buffer-backed-up nil))
(add-hook 'before-save-hook #'force-backup-of-buffer)
(use-package backup-walker)
(let ((dir (no-littering-expand-var-file-name "auto-save/")))
(make-directory dir t)
(add-to-list 'auto-save-file-name-transforms `(".*" ,dir t) 'append))
,请设置no-littering
,backup-directory-alist
,tramp-persistency-file-name
和tramp-backup-directory-alist
。
tramp-auto-save-directory
附注:自动保存功能与备份功能不同。每次明确保存((setq emacs-persistence-directory
(expand-file-name "var" user-emacs-directory))
(let ((dir (expand-file-name "backup" emacs-persistence-directory)))
(unless (file-directory-p dir)
(make-directory dir t))
(setq backup-directory-alist `(("." . ,dir))))
(let ((backup-dir (concat emacs-persistence-directory "tramp-backup/")))
(setq tramp-persistency-file-name (concat emacs-persistence-directory
"tramp")
tramp-backup-directory-alist `(("." . ,backup-dir))
tramp-auto-save-directory (concat emacs-persistence-directory
"tramp-auto-save/"))
(dolist (d (list tramp-auto-save-directory backup-dir))
(unless (file-exists-p d)
(make-directory d t))))
或C-x C-s
)文件时,备份都会保存副本。每次进行一定数量的编辑时,自动保存都会保存副本。对于给定的文件,可以有许多备份,但只有一个自动保存。
答案 1 :(得分:0)
我将jpkotta的答案作为选定的答案,因为备用助行器似乎适用于其他人。对于我的OSX盒子,我无法使备份模式工作,备份walker更专注于DIFFS,而不仅仅是提供对备份文件的访问。
这是我的黑客解决方案,它有点严重,但它对我有用。 您需要编辑环境的路径名。 (原件见https://www.emacswiki.org/emacs/ForceBackups) 我尝试过,备份模式和备份目录https://www.emacswiki.org/emacs/BackupDirectory,但这是第一件有用的东西。)
这是做什么的: - 它修复了emacs,所以总是进行自动保存(令人惊讶的是这不是默认设置) - 它添加了命令``M-x历史''打开备份目录。
原油,但它确实有效。所以遗憾地看到Emacs的死!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; FORCE-BACKUP-OF-BUFFER
;;; (See https://www.emacswiki.org/emacs/ForceBackups)
(defun dao-setup-force-backup-of-buffer()
(setq vc-make-backup-files t) ; Do backups even for version controlled files!
(setq version-control t ; Use version numbers for backups.
kept-new-versions 10 ; Number of newest versions to keep.
kept-old-versions 0 ; Number of oldest versions to keep.
delete-old-versions t ; Don't ask to delete excess backup versions.
backup-by-copying t) ; Copy all files, don't rename them.
(add-hook 'before-save-hook 'force-backup-of-buffer)
)
(defun force-backup-of-buffer ()
;; Make a special "per session" backup at the first save of each
;; emacs session.
(when (not buffer-backed-up)
;; Override the default parameters for per-session backups.
'(let ((backup-directory-alist '(("." . "~/emacs-backups")))
(kept-new-versions 3))
(backup-buffer)))
(backup-buffer)
;; Make a "per save" backup on each save. The first save results in
;; both a per-session and a per-save backup, to keep the numbering
;; of per-save backups consistent.
(let ((buffer-backed-up nil))
(backup-buffer)))
(defun history ()
(interactive)
(dired-find-file "/User/oblinger/emacs-backups")
)