|
|
@@ -69,6 +69,15 @@ otherwise the path where the library installed." |
|
|
|
(locate-library lib)) |
|
|
|
locate-p))) |
|
|
|
|
|
|
|
;; (defmacro f-autoload (feature functions &rest form) |
|
|
|
;; `(,@(mapcar (lambda (f) |
|
|
|
;; `(autoload ,f ,(symbol-name feature))) |
|
|
|
;; functions) |
|
|
|
;; (eval-after-load ,feature |
|
|
|
;; ,@form))) |
|
|
|
|
|
|
|
;; (f-autoload autosave (a b) (ddd) (ccc)) |
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
|
|
;; start and quit |
|
|
|
|
|
|
@@ -464,7 +473,7 @@ otherwise the path where the library installed." |
|
|
|
(setq version-control 'never) |
|
|
|
(setq delete-old-versions t) |
|
|
|
|
|
|
|
(setq auto-save-list-file-prefix (expand-file-name "~/.emacs.d/autosave/")) |
|
|
|
(setq auto-save-list-file-prefix (expand-file-name "~/.emacs.d/auto-save/")) |
|
|
|
(setq delete-auto-save-files t) |
|
|
|
|
|
|
|
(add-to-list 'completion-ignored-extensions ".bak") |
|
|
@@ -488,6 +497,14 @@ otherwise the path where the library installed." |
|
|
|
(smart-revert-on) |
|
|
|
) |
|
|
|
|
|
|
|
;; autosave |
|
|
|
|
|
|
|
(and (fetch-library |
|
|
|
"https://raw.github.com/10sr/emacs-lisp/master/autosave.el" |
|
|
|
t) |
|
|
|
(require 'autosave nil t) |
|
|
|
(autosave-set 2)) |
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
|
|
;; editting |
|
|
|
|
|
|
@@ -1786,71 +1803,6 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer." |
|
|
|
(global-set-key (kbd "C-x C-c") 'my-delete-frame-or-kill-emacs) |
|
|
|
(define-key my-prefix-map (kbd "C-x C-c") 'save-buffers-kill-emacs) |
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
|
|
;; autosave |
|
|
|
|
|
|
|
(defun autosave-buffer-save-current-buffer () |
|
|
|
"Save current buffer. The variable `autosave-buffer-functions' decides if |
|
|
|
current buffer should be saved or not." |
|
|
|
(when (run-hook-with-args-until-failure 'autosave-buffer-functions) |
|
|
|
(save-buffer))) |
|
|
|
|
|
|
|
(defvar autosave-buffer-functions nil |
|
|
|
"A list of functions be called before autosave current buffer. |
|
|
|
Each function is called with no argument. Current buffer is the buffer to save |
|
|
|
while these functions are called. If any of these functions return nil, |
|
|
|
autosaving will not happen.") |
|
|
|
(defvar autosave-buffer nil "Autosave timer object.") |
|
|
|
(defun autosave-buffer (secs) |
|
|
|
"Register timer so that the buffer will be saved automatically each time |
|
|
|
when Emacs is idle for SECS. When SECS is 0 or nil, stop the timer and disable |
|
|
|
auto-saving." |
|
|
|
(interactive "nSeconds until autosaving (0 to disable autosaving.): ") |
|
|
|
(if (and secs |
|
|
|
(not (eq secs |
|
|
|
0))) |
|
|
|
(progn (when autosave-buffer |
|
|
|
(cancel-timer autosave-buffer) |
|
|
|
(setq autosave-buffer nil)) |
|
|
|
(setq autosave-buffer |
|
|
|
(run-with-idle-timer secs |
|
|
|
t |
|
|
|
'autosave-buffer-save-current-buffer))) |
|
|
|
(when autosave-buffer |
|
|
|
(cancel-timer autosave-buffer) |
|
|
|
(setq autosave-buffer nil)))) |
|
|
|
|
|
|
|
(defun autosave-buffer-buffer-file-name () |
|
|
|
"Return nil if current buffer is not visiting any file." |
|
|
|
buffer-file-name) |
|
|
|
|
|
|
|
(defun autosave-buffer-file-exists-p () |
|
|
|
"Return nil if the file current buffer is visiting is not exist." |
|
|
|
(file-exists-p buffer-file-name)) |
|
|
|
|
|
|
|
(defun autosave-buffer-buffer-writable-p () |
|
|
|
"Return nil if current buffer is read only." |
|
|
|
(not buffer-read-only)) |
|
|
|
|
|
|
|
(defun autosave-buffer-buffer-modified-p () |
|
|
|
"Return nil if current buffer is not modified yet since last save." |
|
|
|
(buffer-modified-p)) |
|
|
|
|
|
|
|
(defun autosave-buffer-buffer-file-writable-p () |
|
|
|
"Return nil if the file current buffer is visiting is not writable." |
|
|
|
(file-writable-p buffer-file-name)) |
|
|
|
|
|
|
|
(mapcar (lambda (f) |
|
|
|
(add-hook 'autosave-buffer-functions |
|
|
|
f)) |
|
|
|
'(autosave-buffer-buffer-file-name |
|
|
|
autosave-buffer-file-exists-p |
|
|
|
autosave-buffer-buffer-writable-p |
|
|
|
autosave-buffer-buffer-modified-p |
|
|
|
autosave-buffer-buffer-file-writable-p)) |
|
|
|
|
|
|
|
(autosave-buffer 2) |
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
|
|
;; x open |
|
|
|
|
|
|
|