Org-mode mailing list
 help / color / mirror / Atom feed
From: Jeff Kowalski <>
To: Gustavo Barros <>
Subject: Re: Bug: Duplicate logbook entry for repeated tasks [9.4.6 (9.4.6-gab9f2a @ /home/gustavo/.emacs.d/elpa/org-9.4.6/)]
Date: Fri, 25 Jun 2021 20:13:18 -0700
Message-ID: <> (raw)
In-Reply-To: <>

[-- Attachment #1: Type: text/plain, Size: 3637 bytes --]

While I don't have a fix for the root issue, I did have a chance to create
a lint for LOGBOOK duplicates, as you suggested.
It can be found here:

Also below:

  (defun jeff/org-logbook-retrieve-timestamps (beg end)
    "Retrieve timestamp of all state-change entries between BEG and END."
      (let* ((reversed org-log-states-order-reversed)
             (search (if reversed 're-search-forward 're-search-backward))
             (limit (if reversed end (point)))
             (re (format
                  "^[ \t]*-[ \t]+\\(?:State \"%s\"\s+from\s+\"%s\".*%s%s\\)"
                  (let ((value (cdr (assq 'done org-log-note-headings))))
                    (if (not value) ""
                      (concat "\\|"
                               (regexp-quote value)
                               `(("%d" . ,org-ts-regexp-inactive)
                                 ("%D" . ,org-ts-regexp)
                                 ("%s" . "\"\\S-+\"")
                                 ("%S" . "\"\\S-+\"")
                                 ("%t" . ,org-ts-regexp-inactive)
                                 ("%T" . ,org-ts-regexp)
                                 ("%u" . ".*?")
                                 ("%U" . ".*?"))))))))
        (goto-char (if reversed beg end))
        (while (funcall search re limit t)
          (push (match-string-no-properties 3) log-entries))

  (defun org-lint-duplicate-logbook-timestamps (ast)
    "Report LOGBOOK entries with duplicate timestamp"
    (org-element-map ast 'drawer
      (lambda (d)
        (when (equal (org-element-property :drawer-name d) "LOGBOOK")
          (let* ((beg (org-element-property :contents-begin d))
                 (end (org-element-property :contents-end d))
                 (orig (jeff/org-logbook-retrieve-timestamps beg end))
                 (uniq (cl-remove-duplicates
                        :test (lambda (x y) (or (null y) (equal x y)))
                        :from-end t))
                 (diff (- (length orig) (length uniq))))
            (unless (zerop diff)
              (list (org-element-property :begin d)
                    (format "LOGBOOK has %d entries with duplicate
timestamp" diff))))))))

  (add-to-list 'org-lint--checkers
                :name 'duplicate-logbook-timestamps
                :description "Report LOGBOOK entries with duplicate
                :categories '(properties)))

On Thu, Jun 17, 2021 at 6:16 AM Gustavo Barros <>

> Thanks for confirming and for the habits info.  So that's what was
> happening with my consistency graphs.  I had indeed been noticing they
> felt "off", but I eventually reverted to 9.4.4 because of the duplicate
> entries and forgot about it.  It seems then that this got solved for me
> not by the reverting itself but by me removing the duplicate entries in
> the LOGBOOK.
> Would clocking reports be affected too? (I'm not personally an user of
> clocking, so I don't really know).
> Perhaps a "lint" for LOGBOOK duplicates would be a good idea alongside
> with the fix, so that people could go about fixing their data with a
> little more convenience?
> Best regards,
> Gustavo.

[-- Attachment #2: Type: text/html, Size: 5157 bytes --]

  reply	other threads:[~2021-06-26  3:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17  2:22 Jeff Kowalski
2021-06-17 13:16 ` Gustavo Barros
2021-06-26  3:13   ` Jeff Kowalski [this message]
2021-06-26 10:53     ` Gustavo Barros
2021-06-27  2:28     ` Gustavo Barros
2021-06-27  6:31       ` Bhavin Gandhi
2021-06-27 10:28         ` Gustavo Barros
2021-06-28 17:25           ` Bhavin Gandhi
  -- strict thread matches above, loose matches on Subject: below --
2021-06-14 13:39 Gustavo Barros
2021-06-14 18:01 ` Bhavin Gandhi
2021-06-14 18:41   ` Gustavo Barros

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='' \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ \
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:

AGPL code for this site: git clone