|
|
@@ -3350,137 +3350,6 @@ I think I can do this with this code that's used for =org-todo-yesterday=: |
|
|
|
|
|
#+END_SRC |
|
|
|
|
|
#+BEGIN_SRC elisp |
|
|
;; Experimental |
|
|
|
|
|
(defun org-fitness-optimal-day (stat) |
|
|
"Return data for optimal day, optimized for STAT." |
|
|
(cl-macrolet ((compare-fn (a b) |
|
|
`(-lambda ((_ date _ calories protein price _)))))) |
|
|
(let* ((table-data (--remove (equal 'hline it) (org-with-wide-buffer |
|
|
(org-babel-goto-named-result table-name) |
|
|
(forward-line 2) |
|
|
(org-table-to-lisp)))) |
|
|
(header (car table-data)) |
|
|
(date-column-number (--find-index (string= "date" (downcase it)) header)) |
|
|
(compare-fn (lambda (a b) |
|
|
))))) |
|
|
|
|
|
;; I have ABSOLUTELY NO IDEA why this doesn't work. I get a "wrong argument type, sequencep binds" error, but binds is CLEARLY a list. It works fine when I actually insert the list, but when I use the variable, it fails. |
|
|
;; (setq-local binds `( |
|
|
;; ("C-l" |
|
|
;; (helm-org-in-buffer-headings) |
|
|
;; (recenter-top-bottom 1)) |
|
|
;; ("C-c C-f" |
|
|
;; (ap/capture-food) |
|
|
;; (org-fitness-call-src-blocks plot-all-in-one)) |
|
|
;; ("C-c C-p" |
|
|
;; (org-fitness-call-src-blocks plot-workouts plot-all-in-one)) |
|
|
;; ("C-c C-w" |
|
|
;; (ap/capture-workout-data) |
|
|
;; (org-fitness-call-src-blocks plot-workouts)) |
|
|
;; )) |
|
|
|
|
|
;; (cl-macrolet ((bind-kli (&rest forms) |
|
|
;; ;; This works because somehow splicing into the |
|
|
;; ;; explicit progn works, even though there's also |
|
|
;; ;; an implicit progn around the explicit progn |
|
|
;; (let ((res (-map |
|
|
;; (-lambda ((key . rest)) |
|
|
;; `(local-set-key (kbd ,key) |
|
|
;; (lambda () |
|
|
;; (interactive) |
|
|
;; ,@rest))) |
|
|
;; forms))) |
|
|
;; `(progn ,@res)))) |
|
|
;; (bind-kli binds) |
|
|
;; ) |
|
|
|
|
|
;; (cl-flet ((bind-kli (forms) |
|
|
;; ;; This works because somehow splicing into the |
|
|
;; ;; explicit progn works, even though there's also |
|
|
;; ;; an implicit progn around the explicit progn |
|
|
;; (-map |
|
|
;; (-lambda ((key . body)) |
|
|
;; (local-set-key (kbd key) |
|
|
;; (lambda () |
|
|
;; (interactive) |
|
|
;; `,@body))) |
|
|
;; forms))) |
|
|
;; (bind-kli binds)) |
|
|
|
|
|
;; (cl-macrolet ((bind (&rest forms) |
|
|
;; ;; This works because somehow splicing into the |
|
|
;; ;; explicit progn works, even though there's also |
|
|
;; ;; an implicit progn around the explicit progn |
|
|
;; (let ((res (-map |
|
|
;; (-lambda ((key plots &key fn)) ; &optional doesn't work, have to use &key |
|
|
;; `(local-set-key (kbd ,key) |
|
|
;; (lambda () |
|
|
;; (interactive) |
|
|
;; ,(when fn `(call-interactively ',fn)) |
|
|
;; (dolist (plot ',plots) |
|
|
;; (ap/org-call-src-block (symbol-name plot))) |
|
|
;; (org-redisplay-inline-images)))) |
|
|
;; forms))) |
|
|
;; `(progn ,@res)))) |
|
|
;; `(bind ,capture-binds)) |
|
|
|
|
|
(cl-macrolet ((bind (&rest forms) |
|
|
;; This works because somehow splicing into the |
|
|
;; explicit progn works, even though there's also |
|
|
;; an implicit progn around the explicit progn |
|
|
(let ((res (-map |
|
|
(-lambda ((key plots &key fn)) ; &optional doesn't work, have to use &key |
|
|
`(local-set-key (kbd ,key) |
|
|
(lambda () |
|
|
(interactive) |
|
|
,(when fn `(call-interactively ',fn)) |
|
|
(dolist (plot ',plots) |
|
|
(ap/org-call-src-block (symbol-name plot))) |
|
|
(org-redisplay-inline-images)))) |
|
|
forms))) |
|
|
`(progn ,@res)))) |
|
|
(bind |
|
|
("C-c C-f" (plot-all-in-one) :fn ap/capture-food) |
|
|
("C-c C-p" (plot-workouts plot-all-in-one)) |
|
|
("C-c C-w" (plot-workouts) :fn ap/capture-workout) |
|
|
)) |
|
|
|
|
|
|
|
|
(cl-macrolet ((bind (&rest forms) |
|
|
;; Doesn't work, can't figure out how to splice the result of -map into the implicit progn |
|
|
(-map (-lambda ((key plots &key fn)) |
|
|
`(local-set-key (kbd ,key) |
|
|
(lambda () |
|
|
(interactive) |
|
|
,(when fn `(call-interactively ',fn)) |
|
|
(dolist (plot ',plots) |
|
|
(ap/org-call-src-block (symbol-name plot))) |
|
|
(org-redisplay-inline-images)))) |
|
|
forms))) |
|
|
(bind |
|
|
("C-c C-f" (plot-all-in-one) :fn ap/capture-food) |
|
|
("C-c C-p" (plot-workouts plot-all-in-one)) |
|
|
)) |
|
|
|
|
|
(cl-flet ((bind (&rest forms) |
|
|
;; This works! But I have to quote each list... |
|
|
(-map (-lambda ((key plots &key fn)) |
|
|
(lexical-let ((key key) (plots plots) (fn fn)) |
|
|
(local-set-key (kbd key) (lambda () |
|
|
(interactive) |
|
|
(when fn (call-interactively fn)) |
|
|
(dolist (plot plots) |
|
|
(ap/org-call-src-block plot)) |
|
|
(org-redisplay-inline-images))))) |
|
|
forms))) |
|
|
(bind |
|
|
'("C-c C-f" (plot-all-in-one) :fn ap/capture-food) |
|
|
)) |
|
|
|
|
|
#+END_SRC |
|
|
|
|
|
# Local Variables: |
|
|
# eval: (setq-local org-confirm-babel-evaluate (lambda (lang body) (not (or (string= lang "python") (string= lang "emacs-lisp"))))) |
|
|
# eval: (ap/org-call-src-block "configure-fitness-buffer") |
|
|
|