improvements
[distro-setup] / unsaved-buffers.el
diff --git a/unsaved-buffers.el b/unsaved-buffers.el
new file mode 100644 (file)
index 0000000..15f0f53
--- /dev/null
@@ -0,0 +1,20 @@
+;; print buffers unsaved, unless within "seconds" below
+
+;; run with
+;; emacsclient --eval "$(cat /a/bin/ds/unsaved-buffers.el)" | sed 's/^..//;s/..$//'
+
+
+(format "%s"
+        (-reduce-from
+         (lambda (acc buf)
+           (let ((seconds 60)
+                 (bpath (buffer-file-name buf)))
+             (if (and bpath
+                      (buffer-modified-p buf)
+                      (time-less-p
+                       (file-attribute-modification-time (file-attributes bpath))
+                       (time-add (current-time) (- seconds))))
+                 (cons bpath acc )
+               acc)))
+         nil (buffer-list))
+        )