zk icon indicating copy to clipboard operation
zk copied to clipboard

Tag-search and tag-insert have zero tags

Open kchousos opened this issue 7 months ago • 3 comments

First of all, thank you for this great package. I was looking for a program that imitates The Archive in functionality, and it being an Emacs package was an awesome bonus!

Even though when I first installed the package tag search and insertion worked, now they do not list any tags whatsoever. I can't pinpoint a specific change that relates to the before and after.

https://github.com/user-attachments/assets/47111119-9b88-49af-848f-ea4bcfeb755b

My relevant configuration is the following:

(use-package zk
  :init
  (add-hook 'completion-at-point-functions #'zk-completion-at-point 'append)
  (defun zk-new-note-header (title new-id &optional orig-id)
    "Insert header in new notes with args TITLE and NEW-ID.
Optionally use ORIG-ID for backlink."
    (insert (format "# %s %s\n\n#inbox\n\n" new-id title)))
  :custom
  (zk-directory "~/Documents/02 Areas/Slipbox")
  (zk-file-extension "md")
  (zk-id-time-string-format "%Y%m%d%H%M%S")
  (zk-id-regexp "\\([0-9]\\{14\\}\\)")
  :config
  (zk-setup-auto-link-buttons))

(use-package zk-index
  :after zk)
(defvar zk-index-mode-map
  (let ((map (make-sparse-keymap)))
    (define-key map (kbd "n") #'zk-index-next-line)
    (define-key map (kbd "p") #'zk-index-previous-line)
    (define-key map (kbd "v") #'zk-index-view-note)
    (define-key map (kbd "o") #'other-window)
    (define-key map (kbd "f") #'zk-index-focus)
    (define-key map (kbd "s") #'zk-index-search)
    (define-key map (kbd "g") #'zk-index-query-refresh)
    (define-key map (kbd "c") #'zk-index-current-notes)
    (define-key map (kbd "i") #'zk-index-refresh)
    (define-key map (kbd "S") #'zk-index-sort-size)
    (define-key map (kbd "M") #'zk-index-sort-modified)
    (define-key map (kbd "C") #'zk-index-sort-created)
    (define-key map (kbd "RET") #'zk-index-open-note)
    (define-key map (kbd "q") #'delete-window)
    (make-composed-keymap map tabulated-list-mode-map))
  "Keymap for ZK-Index buffer.")

(use-package citar
  :custom
  (citar-bibliography '("~/HDD/Library/References/biblio.bib"))
  (citar-format-reference-function 'citar-citeproc-format-reference)
  (citar-markdown-prompt-for-extra-arguments nil)
  (citar-file-open-functions '(("html" . citar-file-open-external) ("pdf" . citar-file-open-external) (t . find-file)))
  (citar-citeproc-csl-styles-dir "~/HDD/Library/Zotero data/styles/")
  :hook
  (markdown-mode . citar-capf-setup))

(with-eval-after-load 'citar
  (with-eval-after-load 'zk
    (require 'zk-citar)))

(setq citar-notes-source 'zk)

(setq zk-citar-citekey-regexp "^[0-9]+[[:space:]]+L1[[:space:]]+\\(\\S-+\\)[[:space:]]+-.*")
(setq zk-citar-title-template "L1 ${=key=} - ${title}")

I've included my citar config as well because I use the integration between your package and citar.

kchousos avatar May 31 '25 11:05 kchousos

Hmm, nothing has changed related to tag functionality in quite some time.

From your gif, it seems that zk--grep-tag-list is returning nil. Is it possible the zk-tag-regexp is not set properly?

Note that the default tag regexp will not find tags at the beginning of a line --- there must be a space before the #.

(I see in your header function that the #inbox tag is at the start of a new line, so the tag search function wouldn't find that.)

localauthor avatar Jun 02 '25 07:06 localauthor

zk-tag-regexp had the default value, but the same behavior persists when setting it to just #[a-zA-Z]. Irregardless, in many notes I have multiple tags that are not at the start of a line.

kchousos avatar Jun 02 '25 20:06 kchousos

Turns out that the problem was the space in the filepath. Is there some way to bypass that?

kchousos avatar Jun 03 '25 16:06 kchousos