1

I'm trying to get org-capture and mu4e working together nicely. Org-capture is already correctly set up; I can capture links to source code files with the following template:

(setq org-capture-templates
          '(("t" "Todo" entry (file+headline "" "General To-Dos")
             "** TODO %?\n %i\n %A\n")))

I'd like to capture links to emails in mu4e. I have org-mu4e required, and org-capture-link works as expected in the mu4e message view. Great so far.

Now, I try to use the same template to use org capture an email. This always fails with the error, Capture abort: (args-out-of-range 99) (The number varies; I assume this is a code point, but cannot get it to render as anything other than a fairly opaque number).

Using the debugger, I've traced this error to the following code block in org-capture-fill-template:

  ;; Simple %-escapes
  (goto-char (point-min))
  (while (re-search-forward "%\\([tTuUaliAcxkKInfF]\\)" nil t)
(unless (org-capture-escaped-%)
  (when (and initial (equal (match-string 0) "%i"))
    (save-match-data
      (let* ((lead (buffer-substring
            (point-at-bol) (match-beginning 0))))
    (setq v-i (mapconcat 'identity
                 (org-split-string initial "\n")
                 (concat "\n" lead))))))
  (replace-match (or (eval (intern (concat "v-" (match-string 1)))) "")
         t t)))

As best as I can tell, everything up to replace-match is working perfectly. The error occurs when replace-match tries to replace a template character (using any of the link characters %a, %A, %l) with the captured link to the mu4e message. Instead of correctly doing the replace, args-out-of-range is thrown. Normally, I'd assume there was no correctly set match for replace-match to act on -- but match-string returns a correct match result, as does inspecting the match in the debugger.

I'm using Emacs 24.5.1, Org 8.3.4, and mu4e 0.9.16. I've tried this on two different Macs and a Fedora 22 machine; the behavior is absolutely consistent.

  • 99 is probably the character 'c' ((format "%c" 99)). Does that ring a bell ? I'm not sure why replace-match would throw such an error though. Can you get a backtrace (toggle-debug-on-error) ? – YoungFrog Apr 4 '16 at 21:43
3

To my overwhelming exasperation, the problem has turned out to be: emoji-cheat-sheet-plus-display-mode, and the order in which it was activated in org mode.

I had a hook like so:

(defun text-settings ()
  (emoji-cheat-sheet-plus-display-mode))

(add-hook 'org-mode-hook 'text-settings)

Somehow -- and I have no idea how -- this was causing the horrible args-out-of-range error above. Removing emoji-cheat-sheet-plus-display-mode from org has fixed everything.

In conclusion: how do computers even work?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.