Skip to content

Commit

Permalink
Add prescient-aggressive-file-save (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
takaxp authored and raxod502 committed Jul 12, 2019
1 parent 653ca4b commit a118a18
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog].

## Unreleased
### Enhancements
* New user option `prescient-aggressive-file-save` to enable
saving the cache data more aggressively according to the
discussions ([#17] and [#39]).

[#17]: https://github.com/raxod502/prescient.el/issues/17
[#39]: https://github.com/raxod502/prescient.el/pull/39

## 3.2 (released 2019-07-06)
### New features
* New user options `prescient-sort-length-enable` and
Expand Down
13 changes: 12 additions & 1 deletion prescient.el
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ usefully be sorted by length (presumably, the backend returns
these results in some already-sorted order)."
:type 'boolean)

(defcustom prescient-aggressive-file-save nil
"Whether to save the cache file aggressively.
If non-nil, then write the cache data to `prescient-save-file'
after the cache data is updated by `prescient-remember' when
`prescient-persist-mode' is activated."
:type 'boolean)

;;;; Caches

(defvar prescient--history (make-hash-table :test 'equal)
Expand Down Expand Up @@ -457,7 +464,11 @@ Return the sorted list. The original is modified destructively."
(puthash cand new-freq prescient--frequency))))
prescient--frequency)
;; Update serial number.
(cl-incf prescient--serial-number))
(cl-incf prescient--serial-number)
;; Save the cache data.
(when (and prescient-persist-mode
prescient-aggressive-file-save)
(prescient--save)))

;;;; Closing remarks

Expand Down

0 comments on commit a118a18

Please sign in to comment.