Archived entries from file home/n.emacs.d/lisp/doct/notes.org
we can’t do it yet. %doct:val%doct:another will fail… recursively parse the :keyword section? have to be mindful of prefix and postfix characters… Allow form’s name to be a symbol. Its children inherit its properties, but it is not included in the final list. This would allow ‘global’ settings for all templates or settings for groups of parents. If the values are atoms (not user defined) and constants, we shouldn’t have to defer merging them. A special case is a string utilizing the%doct
expansion syntax.
- State “CANCELED” from “IDEA” [2020-01-19 Sun 13:15]
Unnecessary. org-capture correctly changes file to Org mode and issues warning.
Keyword | Types | Warn? |
---|---|---|
:datetree | boolean | |
:function | symbol function | x |
:headline | string | |
:regexp | string | |
:olp | (string) |
Keyword | Types | Warn? |
---|---|---|
:clock | boolean | |
:file | string symbol function | x |
:function | symbol function | x |
:id | string |
Keyword | Types | Warn? |
---|---|---|
:after-finalize | function symbol | x |
:before-finalize | ” | x |
:hook | ” | x |
:prepare-finalize | ” | x |
Keyword | Types | Warn? |
---|---|---|
:in/unless-* | stringp list | |
:function | function symbol | x |
:when/unless | function symbol list | x |
Keyword | Types | Warn? |
---|---|---|
:template | string list function symbol | x |
:template-file | string symbol | x |
Keyword | Types |
---|---|
children | list |
contexts | list |
custom | plist |
disabled | boolean |
doct-keys | string |
keys | string |
doct-warn | boolean |
type | symbol |
(defun org-contextualize-validate-key (key contexts)
"Check CONTEXTS for agenda or capture KEY."
(let (res)
(dolist (r contexts)
(dolist (rr (car (last r)))
(when
(and (equal key (car r))
(if (functionp rr) (funcall rr)
(or (and (eq (car rr) 'in-file)
(buffer-file-name)
(string-match (cdr rr) (buffer-file-name)))
(and (eq (car rr) 'in-mode)
(string-match (cdr rr) (symbol-name major-mode)))
(and (eq (car rr) 'in-buffer)
(string-match (cdr rr) (buffer-name)))
(when (and (eq (car rr) 'not-in-file)
(buffer-file-name))
(not (string-match (cdr rr) (buffer-file-name))))
(when (eq (car rr) 'not-in-mode)
(not (string-match (cdr rr) (symbol-name major-mode))))
(when (eq (car rr) 'not-in-buffer)
(not (string-match (cdr rr) (buffer-name)))))))
(push r res))))
(delete-dups (delq nil res))))
("context" :keys "c"
:context ([:keys "w"]
:in-mode (one two three) | one
:not-in-mode (one two three) | one
:in-buffer ("one.org" "two.org") | "one.org"
:not-in-buffer ("one.org" "two.org") | "one.org"
:function (lambda () t) | (one two three)
(setq org-capture-templates-contexts
'(("n" "t" ((lambda () nil)))))
(plist-get '(:doct_ ("one" "two" "three") :keys "x") :doct_)
:in-mode ((major-mode "t")
(second-mode third-mode "x")
(fourth "z"))
:hide-in-mode
:hide-in-mode))
(defun doct-plist-p (list)
"Non-null if and only if LIST is a plist with keyword keys."
(while (consp list)
(setq list (if (and (keywordp (car list))
(consp (cdr list)))
(cddr list)
'not-plist)))
(null list))
'(:doct-keys "xp" :contexts ((:unless-file "one.org")
(:in-file ("one.org" "two.org") :keys "xp")))
(defvar doct-context-keywords '(:in-buffer
:in-file
:in-mode
:unless-buffer
:unless-file
:unless-mode
:function))
(pp
(doct--add-contexts properties))
(setq org-capture-templates-contexts '(("n" ((lambda () (not (member major-mode '(org-mode elisp-mode wikinforg))))))))
Keyword | Type | Check? |
---|---|---|
:clock-in | boolean | |
:clock-keep | boolean | |
:clock-resume | boolean | |
:unnarrowed | boolean | |
:prepend | boolean | |
:immediate-finish | boolean | |
:jump-to-captured | boolean | |
:kill-buffer | boolean | |
:no-save | boolean | |
:time-prompt | boolean | |
:empty-lines | integer | integerp |
:empty-lines-after | integer | integerp |
:empty-lines-before | integer | integerp |
:table-line-pos | string | stringp |
:tree-type | ‘week ‘month? | warn if not one of these, it’ll still work but may not be what user intended |
Skipping the booleans because they only need to be non-nil or nil (not strictly ‘t’).
Convention for -hook suffix denotes normal hook. This is an abnormal hook. Should bedoct-after-conversion-functions
.
- State “CANCELED” from “TODO” [2020-03-08 Sun 15:34]
Not technically duplicate logic. I can live with function length.
(:keyword val :template "%doct(keyward)")
should issue warning along the lines of:
"%doct(keyward), :keyward not found in declaration:
(:keyword val :template \"%doct(keyward)\")"
- State “STARTED” from “IDEA” [2020-03-12 Thu 12:13]
e.g.
(... :type entry :template "no leading star")
will throw at capture time because it is not a valid entry string We could catch this error at conversion time.
Entry type | Warn? | values |
---|---|---|
entry | yes | empty string fine, string without leading stars fails |
item | no | +,-,digit. |
checkitem | no | any string |
table-line | yes | empty string, string w each line starting w pipe character |
plain | no | any string |
(defun doct-flatten-lists-in (list &optional acc)
;;...
)
fix inaccurate return value in Custom data
- Note taken on [2020-03-22 Sun 14:16]
Removing it does not cause any test failures. We’re also copying declarations before operating on them. Should not be an issue.
We’re copying declarations before operating on them now.
and file inclusion syntax e.g.(:template "%()")
(:template "%[]")
doct-warnings can be nil, t, or a list of pre-defined symbols
("example" :keys "e" :file ""
:test (lambda () "returns a string")
;;doct--fill-template calls the function
:template "%doct(test)")
(:template "%{keyword}")
Would be compatible with org-roam
- State “STARTED” from “TODO” [2020-03-22 Sun 14:55] It’s a breaking change.
org-capture-plist
at runtime.
org-capture loaded by then.
we also add to: org-capture-hooks, org-capture-contexts
OK to defvar these before org-capture loaded?
Common case is for the file to exist during conversion.
Warn here if it does not. It’s possible to create the file after conversion, but before capture, but users can disable that particular warning when appropriate.
Since we’re not depending on org-capture, we defvar its hooks.
Can’t add to them when they’re void. Setting to nil (current solution)
works but makes doct claim ownership of those variables. e.g.
documentation claims variable is defined in doct.
remove installed hooks
https://www.gnu.org/software/emacs/manual/html_node/elisp/Coding-Conventions.html
https://www.gnu.org/software/emacs/manual/html_node/elisp/Unloading.html#Unloading
- State “STARTED” from “IDEA” [2020-04-04 Sat 20:09]
"%{interpreted} \%{verbatim}"
- State “CANCELED” from “IDEA” [2020-04-05 Sun 13:38]
Too complex for little benefit.
"%{data} %{\1}"
- State “DONE” from “CANCELED” [2020-04-05 Sun 13:37]
- State “STARTED” from “CANCELED” [2020-03-30 Mon 23:14]
From org-capture-current-plist
docstring:
"Local variable holding the plist in a capture buffer.
This is used to store the plist for use when finishing a capture process
because another such process might have changed the global variable by then.
Each time a new capture buffer has been set up, the global `org-capture-plist'
is copied to this variable, which is local in the indirect buffer.")
Use org-capture-plist
up to and before org-capture-mode-hook
Really, we should have access to orc-capture-current-plist
during org-capture-mode-hook
, but it’s not set until after.
Submitted a patch to change that: https://lists.gnu.org/archive/html/emacs-orgmode/2020-05/msg00047.html
org-capture-after-finalize-hook
does not have access to org-capture-current-plist
because the capture buffer is not the current buffer when it runs.
To solve this we set org-capture-plist
to org-capture-current-plist
during the org-capture-before-finalize-hook
.
This seems to cover most cases of overlapping capture templates.
- State “CANCELED” from “TODO” [2020-05-04 Mon 12:41]
- State “TODO” from “CANCELED” [2020-05-01 Fri 15:39]
- State “CANCELED” from “TODO” [2020-04-05 Sun 13:37]
- State “TODO” from “CANCELED” [2020-05-01 Fri 15:39]
- State “CANCELED” from “TODO” [2020-04-05 Sun 13:37]
- Call first template. It calls
doct-get
in a finalizing hook to add info to the template. - It calls second template in its
:hook
. - Second template set to fill and
:immediate-finish
. - It’s finalizing hook finalizes first template.
- State “CANCELED” from “IDEA” [2020-05-04 Mon 18:42]
vanilla syntax for elisp execution already exists. Would it be worth it to replace %{KEYWORD} during conversion and return a string?
"%{key}" -> "%((doct-get key))"
What do we gain? Template string is more transparent to user? doct-get can’t handle case where key’s value is a function…
- State “CANCELED” from “IDEA” [2020-05-04 Mon 18:42]
May reduce verbosity when using doct–first-in…
- Note taken on [2020-08-21 Fri 23:37]
abstracted common logic into a macro.
Can these be generalized into single function?