aboutsummaryrefslogtreecommitdiff
path: root/stack-filter.el
diff options
context:
space:
mode:
Diffstat (limited to 'stack-filter.el')
-rw-r--r--stack-filter.el24
1 files changed, 9 insertions, 15 deletions
diff --git a/stack-filter.el b/stack-filter.el
index e5fb54d..91c4875 100644
--- a/stack-filter.el
+++ b/stack-filter.el
@@ -74,9 +74,7 @@ or string."
(defun stack-filter-get (filter)
"Retrieve named FILTER from `stack-filter-cache-file'."
- (with-current-buffer (stack-cache-get-file stack-filter-cache-file)
- (or (cdr (ignore-errors (assoc filter (read (buffer-string)))))
- nil)))
+ (cdr (assoc filter (stack-cache-get stack-filter-cache-file))))
(defun stack-filter-store (name filter)
"Store NAME as FILTER in `stack-filter-cache-file'.
@@ -85,17 +83,12 @@ NAME should be a symbol and FILTER is a string as compiled by
`stack-filter-compile'."
(unless (symbolp name)
(error "Name must be a symbol: %S" name))
- (with-current-buffer (stack-cache-get-file stack-filter-cache-file)
- (let* ((dict (or (ignore-errors
- (read (buffer-string)))
- nil))
- (entry (assoc name dict)))
- (if entry (setf (cdr entry) filter)
- (setq dict (cons (cons name filter) dict)))
- (erase-buffer)
- (insert (prin1-to-string dict))
- (save-buffer)
- dict)))
+ (let* ((dict (stack-cache-get stack-filter-cache-file))
+ (entry (assoc name dict)))
+ (if entry (setcdr entry filter)
+ (setq dict (cons (cons name filter) dict)))
+
+ (stack-cache-set stack-filter-cache-file dict)))
;;; TODO tail recursion should be made more efficient for the
;;; byte-compiler
@@ -104,7 +97,8 @@ NAME should be a symbol and FILTER is a string as compiled by
(stack-filter-store
(caar name-filter-alist)
(cdar name-filter-alist))
- (stack-filter-store-all (cdr name-filter-alist))))
+ (stack-filter-store-all
+ (cdr name-filter-alist))))
(provide 'stack-filter)
;;; stack-filter.el ends here