-reindent-file -> -reindent-buffer; create -read-key-values
This commit is contained in:
parent
322556ee1c
commit
2b03f70a6e
|
@ -92,18 +92,53 @@ this time interval that should be recorded."
|
|||
(plist-pp it buffer)))
|
||||
(save-buffer))))
|
||||
|
||||
(defun chronometrist-reindent-file ()
|
||||
(defun chronometrist-reindent-buffer ()
|
||||
(interactive)
|
||||
(let ((buffer (find-file-noselect chronometrist-file))
|
||||
expr)
|
||||
(let (expr)
|
||||
(goto-char (point-min))
|
||||
(while (setq expr (ignore-errors (read (current-buffer))))
|
||||
(backward-list)
|
||||
(chronometrist-delete-list)
|
||||
(when (looking-at "\n*")
|
||||
(delete-region (match-beginning 0)
|
||||
(match-end 0)))
|
||||
(plist-pp expr (current-buffer))
|
||||
(insert "\n")
|
||||
(unless (eobp)
|
||||
(insert "\n")))))
|
||||
|
||||
(define-derived-mode chronometrist-read-key-values-mode emacs-lisp-mode "Key-Values"
|
||||
"Mode used by `chronometrist' to read key values from the user."
|
||||
(add-hook 'after-load-functions #'elisp--font-lock-flush-elisp-buffers)
|
||||
(insert ";; Use C-c C-c to accept, or C-c C-k to cancel\n")
|
||||
;; FIXME - font lock doesn't work in these buffers...
|
||||
;; (font-lock-fontify-buffer)
|
||||
)
|
||||
|
||||
;; TODO - C-c C-c/C-c C-k bindings
|
||||
(defun chronometrist-read-key-values ()
|
||||
(let ((buffer (get-buffer-create "*Chronometrist-Key-Values*")))
|
||||
(switch-to-buffer buffer)
|
||||
(with-current-buffer buffer
|
||||
(goto-char (point-min))
|
||||
(while (setq expr (ignore-errors (read buffer)))
|
||||
(backward-list)
|
||||
(chronometrist-delete-list)
|
||||
(when (looking-at-p "\n\n") (delete-char 2))
|
||||
(plist-pp expr buffer))
|
||||
(save-buffer))))
|
||||
(chronometrist-common-clear-buffer buffer)
|
||||
(emacs-lisp-mode)
|
||||
;; (chronometrist-read-key-values-mode)
|
||||
(unwind-protect
|
||||
(progn
|
||||
(insert "(")
|
||||
(while t
|
||||
(let (key value)
|
||||
;; can't query these within the let definitions,
|
||||
;; because that way KEY won't be inserted into the
|
||||
;; buffer until you enter VALUE
|
||||
(setq key (completing-read "Key (C-g to quit): " nil))
|
||||
(when key (insert ":" key))
|
||||
(setq value (completing-read "Value (C-g to quit): " nil))
|
||||
(when value (insert " " value "\n")))))
|
||||
(when (bolp)
|
||||
(backward-char 1))
|
||||
(insert ")")
|
||||
(chronometrist-reindent-buffer)))))
|
||||
|
||||
(provide 'chronometrist-sexp)
|
||||
|
||||
|
|
|
@ -346,6 +346,7 @@ is the clocked-out project.")
|
|||
|
||||
;; TODO - if clocked in and point not on a project, just clock out
|
||||
;; PROFILE
|
||||
;; TODO - implement `chronometrist-ask-tags-p' and `chronometrist-ask-key-values-p' (don't prompt for them if nil)
|
||||
(defun chronometrist-toggle-project (&optional prefix tags)
|
||||
"Start or stop the project at point.
|
||||
|
||||
|
|
|
@ -77,13 +77,15 @@ UI ideas
|
|||
(insert (completing-read "Key (C-g to quit): " nil) "=")
|
||||
(insert (completing-read "Value (C-g to quit): " nil) "\n"))
|
||||
```
|
||||
* Why not just use that to build an s-expression instead? Add : to keys (if they don't start with it) to make keywords, convert values to strings if they contain spaces and don't start with parens. `read` the buffer to get your plist.
|
||||
|
||||
What does this make the UX flow?
|
||||
1. `RET` - user clocks in/out
|
||||
2. prompt for tags - `RET`/enter values and `RET`
|
||||
3. buffer opens, prompt for key values - `C-c C-c`/edit key values and `C-c C-c`
|
||||
|
||||
That's `RET RET C-c C-c` to simply clock in/out with no bells and whistles. Maybe we can make `C-u RET` do that for short.
|
||||
That's `RET RET C-c C-c` to simply clock in/out, for someone who doesn't need the bells and whistles. Maybe we can make `C-u RET` do that for short.
|
||||
* Also, add two variables - `chronometrist-ask-tags-p` and `chronometrist-ask-key-values-p`. Don't prompt for them if these are nil.
|
||||
|
||||
## Populating history data
|
||||
When?
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
## Backend
|
||||
1. Timeclock-compatible CSV. May grow timeclock-project-list to large lengths, since timeclock will see every unique combination of tags as a new project.
|
||||
2. A new s-exp based format (see [new-format.md](new-format.md))
|
||||
3. Add an s-expression containing tags and other structured in the comment part of timeclock. Hacky, and the s-exp must be limited to one line (i.e. cannot be pretty printed), since the timeclock format is line-based.
|
||||
3. Add an s-expression containing tags and other structured data in the comment part of timeclock. Hacky, and the s-exp must be limited to one line (i.e. cannot be pretty printed), since the timeclock format is line-based.
|
||||
|
||||
## UI
|
||||
1. Something to suggest tags which are commonly used with a given tag. Probably store it as a hash table or such, with tags as keys and `((tag . score) ...)` as values, sorted in descending order of scores.
|
||||
|
|
Reference in New Issue