Skip to content

Have citar list all file containing citekey in name as candidates #867

@oatmealm

Description

@oatmealm

Is your feature request related to a problem? Please describe.
I'd like citar to list all note files containing the citekey

Describe the solution you'd like

I had an example code which I can no longer find here, which does this:

  (defun my-notes-items (citekeys)
    "Return a hash table mapping each CITEKEY to its note files."
    (let* ((all-files
            (apply #'append
                   (mapcar (lambda (dir)
                             (directory-files-recursively dir "\\.org\\'"))
                           citar-notes-paths)))
           (result (make-hash-table :test #'equal)))
      (dolist (key citekeys)
        (puthash key
                 (seq-filter (lambda (f) (string-match-p (regexp-quote key) f))
                             all-files)
                 result))
      result))
  (defun my-notes-has-p ()
    "Return a predicate that tests whether a key has note files."
    (lambda (citekey)
      (hash-table-p (gethash citekey (my-notes-items (list citekey))))))

  (citar-register-notes-source
   'my-notes
   '(:name "Notes"
     :category file
     :items my-notes-items
     :hasitems my-notes-has-p
     :open find-file
     :create citar-file--create-note))

  (setq citar-notes-source 'my-notes)

Describe alternatives you've considered
Would be nice to have citar enable something like this by default: any file with citekey not just base name, is a a note candidate.

Additional context
This works well though only been using it for a while.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions