Hi, I initially noticed this using Vertico, since that package monitors
for errors during completion.  But after reporting it to Vertico's issue
tracker, I confirmed that it's actually an Org-mode bug.

When using `org-tags-view`, if a search query contains a "-" character,
Vertico reports an error whenever point is located before the hyphen.

Here are steps to reproduce:

 1.  Start Emacs with emacs -Q.

 2.  Assuming that your main configuration is stored in ~/.emacs.d (with
 Vertico installed), and you have some org files stored in ~/org, paste
 the following into the scratch buffer and execute `eval-buffer`.

(require 'vertico "~/.emacs.d/elpa/vertico-2.5/vertico.el")
(vertico-mode 1)
(keymap-global-set "C-c a" 'org-agenda)
(setopt org-agenda-files '("~/org"))

 3.  Enter C-c a m to execute org-tags-view.

 4.  Enter some query that contains one or more hyphens, for example
 TIMESTAMP_IA="<2025-09-18>"

 5.  Press C-a or otherwise place the cursor earlier in the minibuffer
 than a hyphen, and the error message appears.

It becomes most obvious when using the minibuffer history. If you have
done this search before and revisit it by entering C-c a m M-p, the
error message appears immediately.

Other than the error message, there is no immediately noticeable
problem.

After reporting the error to the Vertico project, Daniel advised that
this is a problem with `org-tags-completion-function` and provided steps
to confirm that.  It seems that `completing-read` expects the function
to return boundary positions, but when certain characters appear after
point, it instead returns a string for the ending position.
https://github.com/minad/vertico/issues/633#issuecomment-3446867835

So I looked into the code, and it appears that both
`org-tags-completion-function` and
`org-agenda-filter-completion-function` have this issue.

In each of the respective functions, the problem *seems* to be corrected
if I replace this line:

(match-string 0 suffix)

with this:

(match-end 0)

However, I'm not confident that I know enough about what's going on to
submit that change as a patch.

Thank you!

Martin

Emacs  : GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version
3.24.49, cairo version 1.18.4)
 of 2025-07-18, modified by Debian
Package: Org mode version 9.8-pre (release_9.7.25-275-g6daeb5 @
/home/martin/Projects/org-mode/lisp/)

Reply via email to