Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix references to wrong match group in zk-id-regexp #66

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions zk-desktop.el
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ To quickly change this setting, call `zk-desktop-add-toggle'."
(replace-match ""))
(when (re-search-forward "]]" end t)
(replace-match "")))
(match-string-no-properties 1)))
(match-string-no-properties 0)))
(title (buffer-substring-no-properties beg (match-beginning 0)))
(new-title (when (member id ids)
(concat zk-desktop-prefix
Expand All @@ -265,7 +265,7 @@ To quickly change this setting, call `zk-desktop-add-toggle'."
(while (re-search-forward zk-id-regexp nil t)
(let* ((beg (line-beginning-position))
(end (line-end-position))
(id (match-string-no-properties 1)))
(id (match-string-no-properties 0)))
(if (member id ids)
(progn
(make-text-button beg end
Expand Down
9 changes: 4 additions & 5 deletions zk-index.el
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ example."
(save-excursion
(beginning-of-line)
(re-search-forward zk-id-regexp (line-end-position)))
(let ((zk-id (match-string-no-properties 1)))
(let ((zk-id (match-string-no-properties 0)))
`(zk-id ,zk-id . ,(cons (line-beginning-position) (line-end-position))))))

(defun zk-index-narrow (arg)
Expand Down Expand Up @@ -596,13 +596,12 @@ with query term STRING."
(defun zk-index--button-at-point-p (&optional pos)
"Return zk-id when `zk-index' button is at point.
Takes an option POS position argument."
(let ((button (or pos
(button-at (point)))))
(let ((button (button-at (or pos (point)))))
(when (and button
(button-has-type-p button 'zk-index))
(save-excursion
(re-search-forward zk-id-regexp)
(match-string-no-properties 1)))))
(when (re-search-forward zk-id-regexp)
(match-string-no-properties 0))))))

(defun zk-index-insert-link (&optional id)
"Insert zk-link in `other-window' for button ID at point."
Expand Down
12 changes: 8 additions & 4 deletions zk.el
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ If you change this value, set `zk-id-regexp' so that
the zk IDs can be found."
:type 'string)

(defcustom zk-id-regexp "\\([0-9]\\{12\\}\\)"
(defcustom zk-id-regexp "[0-9]\\{12\\}"
"The regular expression used to search for zk IDs.
Set it so that it matches strings generated with
`zk-id-format'."
`zk-id-format'. The expression should not capture any
explicitly numbered groups.

See `zk-file-name-regexp' and `zk-link-regexp' functions for
how this regexp is used."
:type 'regexp)

(defcustom zk-tag-regexp "\\s#[a-zA-Z0-9]\\+"
Expand Down Expand Up @@ -1010,8 +1014,8 @@ Select TAG, with completion, from list of all tags in zk notes."
(list (split-string files "\n" t))
(ids (mapcar
(lambda (x)
(string-match zk-id-regexp x)
(match-string 0 x))
(when (string-match zk-id-regexp x)
(match-string 0 x)))
list)))
(delete-dups ids)))

Expand Down