Ihor Radchenko <[email protected]> writes:

> Morgan Smith <[email protected]> writes:
>
>> @@ -12275,6 +12275,16 @@ org-tags-completion-function
>>      (confirm (lambda (x) (stringp (car x))))
>>      (prefix "")
>>          begin)
>> +    ;; Abort if the string has unbalanced quotes
>> +    (let ((quotes 0))
>> +      (mapc
>> +       (lambda (char)
>> +         (when (eq char ?\")
>> +           (setq quotes (1+ quotes))))
>> +       string)
>> +      (when (and (< 0 quotes)
>> +                 (not (eq (% quotes 2) 0)))
>> +        (setq flag 'invalid)))
>
> This does not look right. What is the reason behind the need to have a
> special case for unbalanced parenthesis? Which part of the completion
> function is failing and why?
>
So the comment I left to describe this is this:

#+begin_src diff
-  ;; Completes in unbalanced parenthesis.
-  ;; TIMESTAMP_IA="<2025- TAB adds a tag completion.
-  :expected-result :failed
#+end_src

In the first test case there is only one completion (the tag "test") so
whenever we press TAB to complete something at a boundry we will enter
the tag "test".  Boundaries happen at "[-+:&,|]".

So in the example we have

TIMESTAMP_IA="<2025-

Then we press TAB.  Then we have:

TIMESTAMP_IA="<2025-test

So I decided to add a bail out for unbalanced quotes as that seems like
the sane option to me.

Reply via email to