2

I want to setup a Journal entry template that prompts for a date/time, so that I can process current entries, as well as older ones.

This is what I have so far:

;;; Org-capture settings
(setq org-capture-templates
      '(("j" "Journal" entry (file+olp+datetree "~/org/journal.org")
         "* %U\n%?" :time-prompt t :empty-lines 1)))

;;; Set keyboard shortcut
(global-set-key (kbd "C-c c") 'org-capture)

The trouble is, when I run the capture template, any date I select that is earlier than what is already in the datetree produces the following error:

enter image description here

Any ideas?

Tobias
  • 32,569
  • 1
  • 34
  • 75
Adam
  • 1,857
  • 11
  • 32
  • Which versions of Emacs and org-mode are you using? I seem to recall that this was a problem in some version combinations a while back, but it seems to work OK now with Emacs 25.3 and Org 9.16. – Win Feb 15 '18 at 00:57
  • 1
    I found the culprit. I am using this code https://emacs.stackexchange.com/questions/38120/validate-internal-fuzzy-links-in-org-mode/38680 to font-lock broken fuzzy links in org-warning face. Something is incompatible between these two snippets... – Adam Feb 15 '18 at 23:57
  • Related: https://emacs.stackexchange.com/questions/36312/error-in-emacs-org-mode-table-match-data-clobbered-by-buffer-modification-hook I think that is what @Win referes to. – Tobias Feb 16 '18 at 12:58

1 Answers1

4

The error message

Match data clobbered by buffer modification hooks

is caused by functions in the hooks before-change-functions or after-change-functions modifying the match data. That may happen if these functions call search-forward and friends or looking-at and friends directly or indirectly through calling other functions.

Solve this problem by wrapping the body of these functions in (save-match-data ...).

The info manual says about that in Section 31.28 "Change Hooks":

The functions you use in these hooks should save and restore the match data if they do anything that uses regular expressions; otherwise, they will interfere in bizarre ways with the editing operations that call them.

Tobias
  • 32,569
  • 1
  • 34
  • 75
  • Hi, it turns out, this was related to the markup I was applying to broken fuzzy links https://emacs.stackexchange.com/questions/38120/validate-internal-fuzzy-links-in-org-mode/38680?noredirect=1#comment61316_38680 which you just fixed. So all good! – Adam Feb 16 '18 at 16:17
  • @Adam The edit of your question heading and my answer were my try to make the question and the answer more valuable to others with similar problems. – Tobias Feb 16 '18 at 16:20