Ensure idle timer for ‘recentf-save-list’ only gets created once
This commit is contained in:
parent
f90d13d9c3
commit
6e177aa3d3
2 changed files with 16 additions and 2 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
;; Keywords: local
|
;; Keywords: local
|
||||||
;; Version: 2020.0407.015402
|
;; Version: 2020.0407.212814
|
||||||
;; Package-Requires: (oni-data-dir expand-region multiple-cursors embrace helpful)
|
;; Package-Requires: (oni-data-dir expand-region multiple-cursors embrace helpful)
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -35,6 +35,9 @@
|
||||||
|
|
||||||
(defalias 'yes-or-no-p 'y-or-n-p)
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
||||||
|
|
||||||
|
(defvar oni-core--recentf-idle-timer nil
|
||||||
|
"Internal variable keeping track of a timer started for ‘recentf-save-list’.")
|
||||||
|
|
||||||
(defun oni-core--destroy-trailing-whitespace ()
|
(defun oni-core--destroy-trailing-whitespace ()
|
||||||
"Delete trailing whitespace everywhere, except in Markdown buffers."
|
"Delete trailing whitespace everywhere, except in Markdown buffers."
|
||||||
(if (not (eq major-mode 'markdown-mode))
|
(if (not (eq major-mode 'markdown-mode))
|
||||||
|
@ -144,7 +147,9 @@
|
||||||
(global-set-key (kbd "C-<left>") 'winner-undo)
|
(global-set-key (kbd "C-<left>") 'winner-undo)
|
||||||
(global-set-key (kbd "C-<right>") 'winner-redo)
|
(global-set-key (kbd "C-<right>") 'winner-redo)
|
||||||
|
|
||||||
(run-with-idle-timer 10 t 'recentf-save-list)
|
(unless oni-core--recentf-idle-timer
|
||||||
|
(setq oni-core--recentf-idle-timer
|
||||||
|
(run-with-idle-timer 10 t 'recentf-save-list)))
|
||||||
|
|
||||||
(electric-indent-mode -1)
|
(electric-indent-mode -1)
|
||||||
(winner-mode)
|
(winner-mode)
|
||||||
|
|
|
@ -59,3 +59,12 @@
|
||||||
(oni-core-move-end-of-dwim)
|
(oni-core-move-end-of-dwim)
|
||||||
(oni-core-move-end-of-dwim)
|
(oni-core-move-end-of-dwim)
|
||||||
(should (equal 21 (point)))))
|
(should (equal 21 (point)))))
|
||||||
|
|
||||||
|
(ert-deftest oni-core-loading-is-idempotent-recentf-idle-timer ()
|
||||||
|
"Test that loading ‘oni-core’ is idempotent in regards to an idle timer."
|
||||||
|
;; We already loaded it with the ‘require’ call above. We load it again so we
|
||||||
|
;; can check that the timer set up in it doesn’t appear twice.
|
||||||
|
(load-library "oni-core")
|
||||||
|
(let* ((pred (lambda (elt) (eq 'recentf-save-list (aref elt 5))))
|
||||||
|
(matches (delete nil (mapcar pred timer-idle-list))))
|
||||||
|
(should (eq 1 (length matches)))))
|
||||||
|
|
Loading…
Reference in a new issue