From ef881e059bc5573ceceb40fe757940dd1fc83733 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Thu, 9 Jan 2020 13:38:51 +0000 Subject: [PATCH] Prefer struct/set! to setf I originally tried using `struct/set` instead of `setf`, which I had forgotten was the *immutable* version of `struct/set!`. When this didn't work, I reverted to `setf`. After a good night's sleep and with a fresh set of eyes, I dug into the issue and discovered that `struct/set!` was what I wanted the whole. I am curious now about `struct/update` versus `struct/update!`; shouldn't the former be immutable and the latter be mutable? I'll save that investigation for a later date. --- configs/shared/.emacs.d/wpc/buffer.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/configs/shared/.emacs.d/wpc/buffer.el b/configs/shared/.emacs.d/wpc/buffer.el index ea2c5945a..bd1019230 100644 --- a/configs/shared/.emacs.d/wpc/buffer.el +++ b/configs/shared/.emacs.d/wpc/buffer.el @@ -27,6 +27,7 @@ (require 'maybe) (require 'set) (require 'cycle) +(require 'struct) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Library @@ -112,14 +113,18 @@ Return a reference to that buffer." (if (> (ts-diff (ts-now) last-called) buffer/source-code-timeout) (progn - (setf (source-code-cycle-cycle buffer/source-code-cycle-state) - (cycle/from-list (buffer/source-code-buffers))) + (struct/set! source-code-cycle + cycle + (cycle/from-list (buffer/source-code-buffers)) + buffer/source-code-cycle-state) (let ((cycle (source-code-cycle-cycle buffer/source-code-cycle-state))) (funcall cycle-fn cycle) (switch-to-buffer (cycle/current cycle))) - (setf (source-code-cycle-last-called buffer/source-code-cycle-state) - (ts-now))) + (struct/set! source-code-cycle + last-called + (ts-now) + buffer/source-code-cycle-state)) (progn (funcall cycle-fn cycle) (switch-to-buffer (cycle/current cycle))))))