super-save-0.3.0/0000755000175000017500000000000013353626657013456 5ustar dogslegdogslegsuper-save-0.3.0/CONTRIBUTING.md0000644000175000017500000000270113353626657015707 0ustar dogslegdogsleg# Contributing If you discover issues, have ideas for improvements or new features, or want to contribute a new module, please report them to the [issue tracker][1] of the repository or submit a pull request. Please, try to follow these guidelines when you do so. ## Issue reporting * Check that the issue has not already been reported. * Check that the issue has not already been fixed in the latest code (a.k.a. `master`). * Be clear, concise and precise in your description of the problem. * Open an issue with a descriptive title and a summary in grammatically correct, complete sentences. * Include any relevant code to the issue summary. ## Pull requests * Read [how to properly contribute to open source projects on Github][2]. * Use a topic branch to easily amend a pull request later, if necessary. * Write [good commit messages][3]. * Mention related tickets in the commit messages (e.g. `[Fix #N] Add missing autoload cookies`) * Use the same coding conventions as the rest of the project. * Verify your Emacs Lisp code with `checkdoc` (C-c ? d). * Open a [pull request][4] that relates to *only* one subject with a clear title and description in grammatically correct, complete sentences. [1]: https://github.com/bbatsov/super-save/issues [2]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request [3]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html [4]: https://help.github.com/articles/using-pull-requests super-save-0.3.0/README.md0000644000175000017500000000575713353626657014753 0ustar dogslegdogsleg[![License GPL 3][badge-license]][copying] [![MELPA][melpa-badge]][melpa-package] [![MELPA Stable][melpa-stable-badge]][melpa-stable-package] # super-save super-save auto-saves your buffers, when certain events happen - e.g. you switch between buffers, an Emacs frame loses focus, etc. You can think of it as both something that augments and replaces the standard `auto-save-mode`. ## Installation Available on all major `package.el` community maintained repos - [MELPA Stable][] and [MELPA][] repos. MELPA Stable is recommended as it has the latest stable version. MELPA has a development snapshot for users who don't mind breakage but don't want to run from a git checkout. You can install `super-save` using the following command: M-x package-install [RET] super-save [RET] or if you'd rather keep it in your dotfiles: ```el (unless (package-installed-p 'super-save) (package-refresh-contents) (package-install 'super-save)) ``` If the installation doesn't work try refreshing the package list: M-x package-refresh-contents ### use-package If you're into `use-package` you can use the following snippet: ```el (use-package super-save :ensure t :config (super-save-mode +1)) ``` ### Emacs Prelude super-save started its life as the extraction of a similar functionality I had originally developed for [Emacs Prelude](https://github.com/bbatsov/prelude) and the package is bundled with Prelude. ## Usage Add the following to your Emacs config to enable `super-save`: ```el (super-save-mode +1) ``` If you want to enable the additional feature of auto-saving buffers when Emacs is idle, add the following as well: ```el (setq super-save-auto-save-when-idle t) ``` At this point you can probably switch off the built-in `auto-save-mode` (unless you really care about its backups): ```el (setq auto-save-default nil) ``` ## Configuration super-save will save files on command (e.g. `switch-to-buffer`) and hook triggers (e.g. `focus-out-hook`). Both of those are configurable via `super-save-triggers` and `super-save-hook-triggers`. Here's a couple of examples: ```el ;; add integration with ace-window (add-to-list 'super-save-triggers 'ace-window) ;; save on find-file (add-to-list 'super-save-hook-triggers 'find-file-hook) ``` You can turn off `super-save` for remote files like this: ``` el (setq super-save-remote-files nil) ``` ## License Copyright © 2015-2018 Bozhidar Batsov and [contributors][]. Distributed under the GNU General Public License; type C-h C-c to view it. [badge-license]: https://img.shields.io/badge/license-GPL_3-green.svg [melpa-badge]: http://melpa.org/packages/super-save-badge.svg [melpa-stable-badge]: http://stable.melpa.org/packages/super-save-badge.svg [melpa-package]: http://melpa.org/#/super-save [melpa-stable-package]: http://stable.melpa.org/#/super-save [COPYING]: http://www.gnu.org/copyleft/gpl.html [contributors]: https://github.com/bbatsov/super-save/contributors [melpa]: http://melpa.org [melpa stable]: http://stable.melpa.org super-save-0.3.0/changelog.md0000644000175000017500000000162013353626657015726 0ustar dogslegdogsleg# Changelog ## 0.3.0 (2018-09-29) ### New features * [#16](https://github.com/bbatsov/crux/issues/16): Make this of hook triggers customizable (see `super-save-hook-triggers`). * [#18](https://github.com/bbatsov/crux/issues/18): Make it possible to disable super-save for remote files (see `super-save-remote-files`). ### Changes * Make `super-save-triggers` a list of symbols (it used to be a list of strings). * Trigger super-save on `next-buffer` and `previous-buffer`. ## 0.2.0 (2016-02-21) ### New features * [#3](https://github.com/bbatsov/crux/issues/3): Turn super-save into a global minor-mode (`super-save-mode`). * Add some functionality for auto-saving buffers when Emacs is idle (disabled by default). ## 0.1.0 (2016-02-11) Initial release. Most of super-save was an extraction of a similar functionality I had originally developed for [Emacs Prelude](https://github.com/bbatsov/prelude). super-save-0.3.0/super-save.el0000644000175000017500000001122613353626657016074 0ustar dogslegdogsleg;;; super-save.el --- Auto-save buffers, based on your activity. -*- lexical-binding: t -*- ;; Copyright © 2015-2018 Bozhidar Batsov ;; Author: Bozhidar Batsov ;; URL: https://github.com/bbatsov/super-save ;; Keywords: convenience ;; Version: 0.3.0 ;; Package-Requires: ((emacs "24.4")) ;; This file is NOT part of GNU Emacs. ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; ;; super-save saves buffers when they lose focus. ;; ;;; Code: (defgroup super-save nil "Smart-saving of buffers." :group 'tools :group 'convenience) (defvar super-save-mode-map (make-sparse-keymap) "super-save mode's keymap.") (defcustom super-save-triggers '(switch-to-buffer other-window windmove-up windmove-down windmove-left windmove-right next-buffer previous-buffer) "A list of commands which would trigger `super-save-command'." :group 'super-save :type '(repeat symbol) :package-version '(super-save . "0.1.0")) (defcustom super-save-hook-triggers '(mouse-leave-buffer-hook focus-out-hook) "A list of hooks which would trigger `super-save-command'." :group 'super-save :type '(repeat symbol) :package-version '(super-save . "0.3.0")) (defcustom super-save-auto-save-when-idle nil "Save current buffer automatically when Emacs is idle." :group 'super-save :type 'boolean :package-version '(super-save . "0.2.0")) (defcustom super-save-idle-duration 5 "The number of seconds Emacs has to be idle, before auto-saving the current buffer. See `super-save-auto-save-when-idle'." :group 'super-save :type 'integer :package-version '(super-save . "0.2.0")) (defcustom super-save-remote-files t "Save remote files when t, ignore them otherwise." :group 'super-save :type 'boolean :package-version '(super-save . "0.3.0")) (defun super-save-command () "Save the current buffer if needed." (when (and buffer-file-name (buffer-modified-p (current-buffer)) (file-writable-p buffer-file-name) (if (file-remote-p buffer-file-name) super-save-remote-files t)) (save-buffer))) (defvar super-save-idle-timer) (defun super-save-command-advice (&rest _args) "A simple wrapper around `super-save-command' that's advice-friendly." (super-save-command)) (defun super-save-advise-trigger-commands () "Apply super-save advice to the commands listed in `super-save-triggers'." (mapc (lambda (command) (advice-add command :before #'super-save-command-advice)) super-save-triggers)) (defun super-save-remove-advice-from-trigger-commands () "Remove super-save advice from to the commands listed in `super-save-triggers'." (mapc (lambda (command) (advice-remove command #'super-save-command-advice)) super-save-triggers)) (defun super-save-initialize-idle-timer () "Initialize super-save idle timer if `super-save-auto-save-when-idle' is true." (setq super-save-idle-timer (when super-save-auto-save-when-idle (run-with-idle-timer super-save-idle-duration t #'super-save-command)))) (defun super-save-stop-idle-timer () "Stop super-save idle timer if `super-save-idle-timer' is set." (when super-save-idle-timer (cancel-timer super-save-idle-timer))) (defun super-save-initialize () "Setup super-save's advices and hooks." (super-save-advise-trigger-commands) (super-save-initialize-idle-timer) (dolist (hook super-save-hook-triggers) (add-hook hook #'super-save-command))) (defun super-save-stop () "Cleanup super-save's advices and hooks." (super-save-remove-advice-from-trigger-commands) (super-save-stop-idle-timer) (dolist (hook super-save-hook-triggers) (remove-hook hook #'super-save-command))) ;;;###autoload (define-minor-mode super-save-mode "A minor mode that saves your Emacs buffers when they lose focus." :lighter " super-save" :keymap super-save-mode-map :group 'super-save :global t (cond (super-save-mode (super-save-initialize)) (t (super-save-stop)))) (provide 'super-save) ;;; super-save.el ends here