Skip to content

hack for separate note piles #176

@hermanhel

Description

@hermanhel

Here is a hack to have separate note piles. I use this to make org-node-find wrapper commands that have different org-node-filter-fn, such as with a certain tag, under a directory, etc.

(defvar custom-org-node--candidate<>entry (make-hash-table :test 'equal)
  "1:1 table mapping minibuffer completion candidates to ID-nodes.
These candidates may or may not be pre-affixated, depending on
user option `org-node-alter-candidates'.")

(defvar custom-org-node--title<>affixations (make-hash-table :test 'equal)
  "1:1 table mapping titles or aliases to affixation triplets.
Even when the triplets are not used, this table serves double-duty such
that its keys constitute the subset of `org-mem--title<>id' that
passed `org-node-filter-fn'.")

(defmacro custom-with-tables (&rest form)
  `(let ((org-node--candidate<>entry custom-org-node--candidate<>entry)
         (org-node--title<>affixations custom-org-node--title<>affixations))
     ,@form))

(custom-with-tables
 (let ((org-node-filter-fn #'my-org-node-filter-fn))
   (org-node-find)))

These tables are not cached with org-node-cache-mode. I added prefix to the wrapper that does org-node-reset with the tables and do it manually. Works for me.

(defun custom-visit (arg)
  (interactive "P")
  (custom-with-tables
   (let ((org-node-filter-fn #'custom-org-node-filter))
     (when (= (car arg) 4)
       (org-node-reset))
       (org-mem-await "caching for custom candidates..." 60)
     (org-node-find))))

replace custom with something else for other candidate set.

It is reasonable that a more multiplexing version could be derived where one can select candidate sets, such as with (org-node-find-with-candidates CANDIDATES-SET-NAME), having an alist of CANDIDATES-SET-NAME and its associated 2 hashtables and possibly org-node-filter-fn and org-node-affixation-fn.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions