Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
meedstrom committed Jul 11, 2024
1 parent f60a109 commit a95a997
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion doc/eva.info
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Eva’s User Manual

This manual is for Eva version 0.5-pre.

Copyright (C) 2020-2023 Martin Edström <meedstrom@teknik.io>
Copyright (C) 2020-2024 Martin Edström <meedstrom@teknik.io>

You can redistribute this document and/or modify it under the terms
of the GNU General Public License as published by the Free Software
Expand Down
12 changes: 8 additions & 4 deletions doc/eva.org
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:PREAMBLE:
#+AUTHOR: Martin Edström
#+EMAIL: meedstrom@teknik.io
#+DATE: 2020-2023
#+DATE: 2020-2024
#+LANGUAGE: en

#+TEXINFO_DIR_CATEGORY: Emacs
Expand All @@ -20,7 +20,7 @@
This manual is for Eva version 0.5-pre.

#+BEGIN_QUOTE
Copyright (C) 2020-2023 Martin Edström <meedstrom@teknik.io>
Copyright (C) 2020-2024 Martin Edström <meedstrom@teknik.io>

You can redistribute this document and/or modify it under the terms
of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -120,7 +120,11 @@ The arguments to =eva-item-create= are as follows:
- =:min-hours-wait= - the minimum amount of hours to wait before it is ok to query you for this info again
- =:max-entries-per-day= - max amount of entries to make in a given day; this makes sense for some kinds of info

It also has =:last-called= and =:dismissals= for internal use.
It also has =:last-called= and =:dismissals= for internal use---do not set these.

#+begin_quote
(ASIDE: There is also the boolean =:lookup-posted-time=, mainly existing for the special case of =eva-query-sleep= because that prompts about things that happened in the past instead of the now, recording sleep-timestamps that are in the past. I.e. it could be 3pm at the time it asks, but you woke up at 6am so 6am is the timestamp saved in the log. This affects the calculation of whether it's a good time to ask again.)
#+end_quote

The order in which the items come in this list reflects the order in which you will be asked. To disable one of them, it is not necessary to remove it from this list, just cancel the query a few times with C-g and the VA will ask you if (s)he should disable it, which is recorded separately in =eva-mem=. To reenable, try =M-x eva-reenable-fn= and enter the name of that function, or simply edit =eva-disabled-fns=.

Expand Down Expand Up @@ -239,7 +243,7 @@ If you do not use these in your =eva-items=, you can prevent the ESS initializat
#+end_src

** Notes
Note that when you re-eval =(setq eva-items ...)= seen in the previous section, it will reset the items' keys =:last-called= and =:dismissals=. This doesn't matter much while you are experimenting. but if you care about it, you can immediately eval =(eva--mem-restore-items-values)= before the reset values are written to disk (by a timer that runs every other minute).
Note that when you re-eval =(setq eva-items ...)= seen in the previous section, it will reset the items' keys =:last-called= and =:dismissals=. This doesn't matter much while you are experimenting, but if you care about it, you can immediately eval =(eva--mem-restore-items-values)= before the reset values are written to disk (by a timer that runs every other minute).

Bit of a tangent, but you could use the functions from both =org-journal= and the =org-roam= dailies if your =org-journal-file-format= is the same file name format as used by your =org-roam-dailies-capture-templates=. So your =org-journal-dir= can refer to the same location as =(concat org-roam-directory org-roam-dailies-directory)=. Just a tip. That's pretty much what you have to do now if you want =eva-present-diary= to scan your org-roam dailies, since it as yet doesn't scan them specifically. Although it's likely you /don't/ use org-journal, in which case you can simply set org-journal-dir to your =~/org-roam/daily/= equivalent.

Expand Down
2 changes: 1 addition & 1 deletion eva-activity.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; eva-activity.el --- activity tracking -*- lexical-binding: t; -*-

;; Copyright (C) 2021-2023 Martin Edström
;; Copyright (C) 2021-2024 Martin Edström

;; This file is not part of GNU Emacs.

Expand Down
27 changes: 12 additions & 15 deletions eva-builtin.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; eva-builtin.el --- Premade applications -*- lexical-binding: t; -*-

;; Copyright (C) 2021-2023 Martin Edström
;; Copyright (C) 2021-2024 Martin Edström

;; This file is not part of GNU Emacs.

Expand Down Expand Up @@ -122,16 +122,12 @@ Near equivalent to typing l v A after entering `org-agenda-list'."
(eva-stop-queue))

(eva-defun eva-present-org-agenda ()
"Send the user to an Org agenda with log and archives enabled.
Near equivalent to typing l v A after entering `org-agenda-list'."
(declare (obsolete eva-present-org-agenda-log-archive "2021-09-17"))
"Send the user to an Org agenda."
(require 'org-agenda)
(message (eva-emit "Here's the agenda archive as of now."))
(message (eva-emit "Here's the agenda as of now."))
;; (message (eva-emit "Sending you to the Org agenda log + archive."))
(sit-for eva-sit-short)
(org-agenda-list)
(org-agenda-log-mode t)
(org-agenda-archives-mode t)
(push (current-buffer) eva-excursion-buffers)
(eva-stop-queue))

Expand Down Expand Up @@ -475,10 +471,10 @@ of the month the last 12 months, and this date the last 50 years.
Optionally, the point of reference can be TS instead of today."
(let ((now (or ts (ts-now))))
(-uniq (append
(--iterate (ts-dec 'day 1 it) now 1) ;; yesterday
(--iterate (ts-dec 'woy 1 it) now 4)
(--iterate (ts-dec 'month 1 it) now 12)
(--iterate (ts-dec 'year 1 it) now 50)))))
(cdr (--iterate (ts-dec 'day 1 it) now 2)) ;; yesterday
(cdr (--iterate (ts-dec 'woy 1 it) now 5))
(cdr (--iterate (ts-dec 'month 1 it) now 13))
(cdr (--iterate (ts-dec 'year 1 it) now 51))))))

(defun eva-past-sample-casual (&optional ts)
"Return a list of ts objects.
Expand All @@ -487,9 +483,9 @@ months, and this date the last 50 years. Optionally, the point
of reference can be TS instead of today."
(let ((now (or ts (ts-now))))
(-uniq (append
(--iterate (ts-dec 'day 1 it) now 1)
(--iterate (ts-dec 'month 1 it) now 6)
(--iterate (ts-dec 'year 1 it) now 50)))))
(cdr (--iterate (ts-dec 'day 1 it) now 2))
(cdr (--iterate (ts-dec 'month 1 it) now 7))
(cdr (--iterate (ts-dec 'year 1 it) now 51))))))

;; TODO: Allow a list of datetrees
(defun eva--make-indirect-datetree (buffer dates)
Expand Down Expand Up @@ -586,7 +582,8 @@ Note that org-journal is not needed."
(push (current-buffer) eva-excursion-buffers))
(when (-non-nil discrete-files-found)
(dolist (x discrete-files-found)
(view-file x)
;; (view-file x) ;; surprising
(find-file x)
(push (current-buffer) eva-excursion-buffers)))
(eva-stop-queue))
(kill-buffer datetree-buf)))))
Expand Down
2 changes: 1 addition & 1 deletion eva-test.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; eva-test.el --- Unit tests -*- lexical-binding: t; -*-

;; Copyright (C) 2020-2023 Martin Edström
;; Copyright (C) 2020-2024 Martin Edström

;; This file is not part of GNU Emacs.

Expand Down
27 changes: 14 additions & 13 deletions eva.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; eva.el --- Emacs virtual assistant -*- lexical-binding: t; -*-

;; Copyright (C) 2020-2023 Martin Edström
;; Copyright (C) 2020-2024 Martin Edström

;; Author: Martin Edström <meedstrom91@gmail.com>
;; URL: https://github.com/meedstrom/eva
Expand Down Expand Up @@ -858,8 +858,8 @@ Digression: Should honestly be submitted to Emacs,
(defun eva--log-idle ()
"Log chunk of idle time to disk."
(eva-tsv-append eva-idle-log-path
(ts-format)
(number-to-string (/ (round eva-length-of-last-idle) 60))))
(ts-format)
(number-to-string (/ (round eva-length-of-last-idle) 60))))

;; This trio of functions handles many edge cases elegantly. Modify with care.
(defun eva--start-next-timer (&optional assume-idle)
Expand Down Expand Up @@ -928,6 +928,7 @@ separate function from `eva--user-is-present'."
;; NOTE: If you change the order of keys, eva--mem-recover will set the
;; wrong values henceforth! You'd better use `eva--mem-nuke-var' on
;; `eva-items' then.
;; TODO Put :fn first, easier inspection
(cl-defstruct (eva-item
(:constructor eva-item-create)
(:copier nil))
Expand Down Expand Up @@ -1110,9 +1111,9 @@ NEW is assumed to be a list of buffers\; most likely, it is
(when (null (eva-item-dataset
(eva-item-by-fn eva-curr-fn)))
(eva-tsv-append
(expand-file-name (concat "successes-"
(symbol-name eva-curr-fn))
eva-cache-dir-path)))
(expand-file-name (concat "successes-"
(symbol-name eva-curr-fn))
eva-cache-dir-path)))
(setq eva--queue (cl-remove eva-curr-fn eva--queue :count 1))
;; TODO: if a fn is called in isolation manually, don't resume
;; HACK Because the current-buffer is still active, wait to be sure the
Expand Down Expand Up @@ -1160,8 +1161,8 @@ Return t if there was no problem with setup, nil otherwise."
(setf (eva-item-dismissals eva-curr-item) 0)
;; Save timestamp of this successful run.
(eva-tsv-append
(expand-file-name (concat "successes-" (symbol-name eva-curr-fn))
eva-cache-dir-path))
(expand-file-name (concat "successes-" (symbol-name eva-curr-fn))
eva-cache-dir-path))
;; Clean up, because this wasn't an excursion.
(named-timer-cancel :eva-excursion)
(remove-hook 'kill-buffer-hook #'eva--if-excursion-complete-do-stuff))
Expand Down Expand Up @@ -1343,11 +1344,11 @@ Return a list looking like
(let ((print-level nil)
(print-length nil))
(eva-tsv-append eva-mem-history-path
(prin1-to-string (car cell))
(if (ts-p (cdr cell))
;; Convert ts structs because they're clunky to read
(ts-format "%s" (cdr cell))
(prin1-to-string (cdr cell)))))))))
(prin1-to-string (car cell))
(if (ts-p (cdr cell))
;; Convert ts structs because they're clunky to read
(ts-format "%s" (cdr cell))
(prin1-to-string (cdr cell)))))))))

(defun eva--mem-last-value-of-variable (var)
"Get the most recent stored value of VAR from disk."
Expand Down
2 changes: 1 addition & 1 deletion generate_an_ods.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# generate_an_ods.R
# Copyright (C) 2021-2023 Martin Edström
# Copyright (C) 2021-2024 Martin Edström

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion init.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2021-2023 Martin Edström
# Copyright (C) 2021-2024 Martin Edström

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion make_data_for_plots.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2020-2023 Martin Edström
# Copyright (C) 2020-2024 Martin Edström

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down

0 comments on commit a95a997

Please sign in to comment.