2

I am diabetic and I have to take my blood glucose three times a day (morning, noon, evening) I can do in three separate tables, and I create a table to group the daily records. How could I capture all three readings in one table with org-capture?

The type 'table-line' create a new table line but I want to complete an existing line for the midday and evening values.

   |      date         |matin|midi|soir|
   |-------------------|-----|----|----||
   | [2019-03-27 mer.] | 120 |    |    |  

1 Answer 1

0

I'm not sure how this is done from org-caputure, maybe someone else can help you with that, but here's a command that does something similar. You have to change the file name and add #+name: mytable to the table.

(defun log-glucose ()
  (interactive)
  (let ((file "~/yourfile.org"))
    (with-current-buffer
        (pop-to-buffer (or (find-buffer-visiting file)
                           (find-file-noselect file)))
      (let ((input (read-string "Input: ")))
        (goto-char (point-min))
        (when (re-search-forward "#\\+name: \\(mytable\\)" nil t)
          (goto-char (org-table-end))
          (let ((line (org-table-current-line)))
            (org-table-goto-line line)
            (cond ((string= (org-table-get line 2) "")
                   (org-table-put line 2 input t))
                  ((string= (org-table-get line 3) "")
                   (org-table-put line 3 input t))
                  ((string= (org-table-get line 4) "")
                   (org-table-put line 4 input t))
                  (t
                   (org-table-insert-row t)
                   (org-table-put (1+ line) 1 (format-time-string "[%F %a]") t)
                   (org-table-put (1+ line) 2 input t)))))))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.