2

I have the following error every single time I press RET in org-mode : wrong-type-argument char-or-string-p nil. It's usually ok but it's bothering when it breaks a tag at the end of a line for example.

Here is the complete stack trace :

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
insert-before-markers-and-inherit(nil)
org-comment-line-break-function(t)
default-indent-new-line(t)
do-auto-fill()
self-insert-command(1)
newline()
org-return()
funcall-interactively(org-return)
call-interactively(org-return nil nil)
command-execute(org-return)

I'm using a GUI Emacs 25.2.1 (Org mode 8.2.10) on Windows 10

Any idea to fix it ? I've made several searchs on these functions in the doc but without success. Thanks for your insight.

1 Answer 1

3

org-comment-line-break-function unconditionally inserts fill-prefix at the beginning of a new line. The default value of fill-prefix is nil standing for "no prefix". That is not acceptable for insert-before-markers-and-inherit.

Customize the variable fill-prefix to the string "" instead of nil and the error will go away.

The variable fill-prefix is buffer-local. If the global initialization of fill-prefix with the empty string gives you any trouble you can also set it specifically for org files in org-mode-hook. Just copy the following text into your init file.

(defun org-config-fill-prefix ()
  "Set `fill-prefix' to the empty string."
  (setq fill-prefix ""))

(add-hook 'org-mode-hook #'org-config-fill-prefix)
3
  • 1
    Thanks for your reply but it doesn't change the problem unfortunately. It doesn't yield an error anymore but still not working (it breaks the tag at the end of line)
    – loukios
    Commented Feb 20, 2018 at 15:29
  • 1
    @loukios org-mode is at version 9.1.6 now. Could you update and look whether the problem persists?
    – Tobias
    Commented Feb 20, 2018 at 16:01
  • Shouldn't org-comment-line-break-function be modified so that if fill-prefix is nil it does TRT, rather than passing it on to a function that is expecting strings?
    – NickD
    Commented Mar 31, 2022 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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