Skip to content

Latest commit

 

History

History
911 lines (868 loc) · 32.2 KB

notes.org_archive

File metadata and controls

911 lines (868 loc) · 32.2 KB

Archived entries from file home/n.emacs.d/lisp/doct/notes.org

2020

2020-01 January

2020-01-18 Saturday

Update tests.

inline %doct expansion?

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…

Update documentation to reflect API changes, new features

group settings

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.

2020-01-19 Sunday

doct–validate-file substitute errors for warning where appropriate

doct–get only compute keyword once

add checks to prevent unnecessary merge deferral

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.

CANCELED doct–template warn if no file extension?

  • State “CANCELED” from “IDEA” [2020-01-19 Sun 13:15]
    Unnecessary. org-capture correctly changes file to Org mode and issues warning.

2020-01-26 Sunday

add proper autoloads

doct, other user-facing commands/procedures

[#B] Single pass recursion to compute all properties?

Is it possible without getting unwieldy?

finish defcustom specs

doct needs overview documentation

2020-02 February

2020-02-21 Friday

Go through and get all possible types for template components

Right now we have `doct–variable-p’ and `doct–should-warn-p’ etc. There’s probably an optimization to be made here. Will lead to simpler code.
Keywords
file-extension
KeywordTypesWarn?
:datetreeboolean
:functionsymbol functionx
:headlinestring
:regexpstring
:olp(string)
exclusive locations
KeywordTypesWarn?
:clockboolean
:filestring symbol functionx
:functionsymbol functionx
:idstring
hooks
KeywordTypesWarn?
:after-finalizefunction symbolx
:before-finalizex
:hookx
:prepare-finalizex
contexts
KeywordTypesWarn?
:in/unless-*stringp list
:functionfunction symbolx
:when/unlessfunction symbol listx
template
KeywordTypesWarn?
:templatestring list function symbolx
:template-filestring symbolx
doct words
KeywordTypes
childrenlist
contextslist
customplist
disabledboolean
doct-keysstring
keysstring
doct-warnboolean
typesymbol

2020-02-22 Saturday

design flaw? Are we able to override inheritance w nil values?

We don’t handle deprecated file+datetree syntax…

Use org-capture-upgrade-templates in doct or polyfill it?

:disable keyword which just creates a context blocking template from all buffers?

contexts

These are the rules for validating a key defined in org.el:
(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))
rough sketch
'(: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))))))))

2020-02-23 Sunday

type check custom options

e.g. :empty-lines* -> numberp :table-line-pos -> ? :tree-type warn if not valid type.
KeywordTypeCheck?
:clock-inboolean
:clock-keepboolean
:clock-resumeboolean
:unnarrowedboolean
:prependboolean
:immediate-finishboolean
:jump-to-capturedboolean
:kill-bufferboolean
:no-saveboolean
:time-promptboolean
:empty-linesintegerintegerp
:empty-lines-afterintegerintegerp
:empty-lines-beforeintegerintegerp
:table-line-posstringstringp
: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’).

2020-03 March

2020-03-03 Tuesday

rename doct-after-conversion-hook

Convention for -hook suffix denotes normal hook. This is an abnormal hook. Should be doct-after-conversion-functions.

2020-03-08 Sunday

CANCELED doct–target-file has duplicate logic. Function is long.

  • State “CANCELED” from “TODO” [2020-03-08 Sun 15:34]
    Not technically duplicate logic. I can live with function length.

doct-get should warn when keyword does not exist on declaration (custom, or otherwise)

This would help in diagnosing typos in template expansion strings e.g.
(:keyword val :template "%doct(keyward)")

should issue warning along the lines of:

"%doct(keyward), :keyward not found in declaration:
(:keyword val :template \"%doct(keyward)\")"

2020-03-12 Thursday

when template string is not deferred, check that it conforms to template entry type

  • 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.

any other errors we can catch for other types?
Entry typeWarn?values
entryyesempty string fine, string without leading stars fails
itemno+,-,digit.
checkitemnoany string
table-lineyesempty string, string w each line starting w pipe character
plainnoany string

refactor to get rid of letrec. Use an accumulator argument instead.

letrec allows locally defined recursive functions, but this is probably less idiomatic than having a formal accumlator argument:
(defun doct-flatten-lists-in (list &optional acc)
  ;;...
  )

2020-03-13 Friday

:hook isn’t run after filling function out. Fix documentation.

rename hyphenated local vars

Can cause uninteneded conflict with dynamic variables.

Simplify doct–keys logic

Do we really need to add :doct-keys as a separate property?

make :doct proper plist

just add description as :doct-name? You can rebuild without that property in errors/warnings if necessary. Then %doct(doct-name) would allow introspection of org-plist :description.

2020-03-17 Tuesday

tests for all code examples

People often test packages “by the examples”. Don’t scare them away.

2020-03-22 Sunday

fix inaccurate return value in Custom data

:doct-custom is now member of :doct

get rid of references to ‘capture time’ in tests

Should just be run time.

Do we still need this?

  • 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.

2020-03-24 Tuesday

warns for elisp cases

and file inclusion syntax e.g.
(:template "%()")
(:template "%[]")

need to finish custom spec

doct-warnings can be nil, t, or a list of pre-defined symbols

2020-03-26 Thursday

execute functions for custom metadata?

("example" :keys "e" :file ""
 :test (lambda () "returns a string")
 ;;doct--fill-template calls the function
 :template "%doct(test)")

2020-03-29 Sunday

use simpler syntax for keyword expansion

(:template "%{keyword}")

Would be compatible with org-roam

open rfc issue for current users
  • State “STARTED” from “TODO” [2020-03-22 Sun 14:55] It’s a breaking change.

2020-03-30 Monday

do we need to depend on org-capture?

Only using 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?

2020-03-31 Tuesday

warn if file does not exist during conversion

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.

2020-04 April

2020-04-04 Saturday

fix hook definition

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.
is there a way to push without ‘owning’ variable and not loading org-capture first?

unused lexical var ‘fn’

make use of doct–type-check here?

doct–type-check return value when check passes

doct–type-check return value when check passes

add doct-unload-function

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

doct expansion syntax escaping

  • State “STARTED” from “IDEA” [2020-04-04 Sat 20:09]
"%{interpreted} \%{verbatim}"

2020-04-05 Sunday

CANCELED doct expansion syntax back refs?

  • State “CANCELED” from “IDEA” [2020-04-05 Sun 13:38]
    Too complex for little benefit.
"%{data} %{\1}"

2020-05 May

2020-05-04 Monday

overlapping captures & doct-get?

  • 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.

CANCELED reliable test for overlapping 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]
Use hooks to simulate overlap
  • 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.

in-file context does not work for indirect buffers

Adopt semver [2/2]

bump major version number
drop support for old %doct(KEYWORD) syntax

CANCELED eliminate or reduce use of doct–fill-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…

CANCELED doct–type-check take pair as first arg? Returns pair if succesful

  • State “CANCELED” from “IDEA” [2020-05-04 Mon 18:42]

May reduce verbosity when using doct–first-in…

2020-08 August

2020-08-21 Friday

similar logic between doct–replace-template-strings and doct–validate-template-maybe

  • Note taken on [2020-08-21 Fri 23:37]
    abstracted common logic into a macro.

Can these be generalized into single function?