diff --git a/zk-desktop.el b/zk-desktop.el index 9a468b1..bdd729b 100644 --- a/zk-desktop.el +++ b/zk-desktop.el @@ -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 @@ -264,7 +264,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 diff --git a/zk-index.el b/zk-index.el index 2a5581a..0763a60 100644 --- a/zk-index.el +++ b/zk-index.el @@ -603,13 +603,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." diff --git a/zk.el b/zk.el index 32cd9aa..6433c5a 100644 --- a/zk.el +++ b/zk.el @@ -124,10 +124,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]\\+" @@ -1023,8 +1027,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)))