Karl Voit <[email protected]> writes:

> Hi,
>
> Org mode version 9.8.6 (9.8.6-dcb8f00 @ ~/.emacs.d/elpa/org-9.8.6/)
>
> In my complex setup[1], I've got occasional bugs that show
> non-recurring tasks on my agenda as if they were repeated:
>
>    business:   Rept .+1w:  TODO foo bar
>
> ... instead of this one which I'd expect:
>
>    business:   Scheduled:  TODO foo bar
>
> [1] https://github.com/novoid/dot-emacs/blob/master/config.org

The section of your config.org titled "show repeater of recurring tasks
in agenda" seems to be of interest.  I image the issue is there.

#+BEGIN_SRC emacs-lisp
(defun my/org-agenda-update-repeated-entry ()
  (save-excursion
    (let* ((org-repeat (and t (my/org-agenda-entry-get-repeat)))
           (rept-str (and org-repeat (format "Rept %4s: " org-repeat)))
           (scheduled-leader (and rept-str (car org-agenda-scheduled-leaders))))
      (when scheduled-leader
        (condition-case nil
            (progn
              (search-backward scheduled-leader)
              (delete-forward-char (length scheduled-leader))
              (insert-and-inherit rept-str))
          (search-failed nil))))))  ; Silently handle when text not found
#+END_SRC

Of particular interest to me is your search and replace here.  The
search-backward seems to be unbounded.  If it missed its target for any
reason then it could just go modify something randomly.  Might I suggest
adding a bound?  Perhaps something like this:

#+BEGIN_SRC emacs-lisp
(search-backward scheduled-leader (pos-bol))
#+END_SRC

Reply via email to