I'm trying to edit a code snippet in org-mode. When I type C-c ' in org mode buffer, it opens up the editor window in R-mode, but it doesn't know about C-c ' and cannot be killed by C-x k since when I execute that command I get a message in the message buffer:

Wrong type argument: overlayp, nil

Is there a way to force kill a buffer? Right now I'm restarting Emacs. Is there a faster way? Why is this doing in the first place?

The elisp debugger gives:

Debugger entered--Lisp error: (wrong-type-argument overlayp nil)
  #[nil "\301!\207" [org-edit-src-overlay delete-overlay] 2]()
  kill-buffer("*Org Src notes.org<lec>[ R ]*")
  call-interactively(kill-buffer nil nil)

If I try to use org-edit-src-exit I get:

org-edit-src-exit: This is not a sub-editing buffer, something is wrong

  • 2
    This looks like R mode defines a hook that messes something up in the way it is started by Org. Wrt killing the buffer: Org adds a hook to kill-buffer-hook when you edit source code. To remove it: M-: (setq kill-buffer-hook nil) (while in the buffer with the source) then you can kill the buffer as usual.
    – wvxvw
    Dec 5 '14 at 5:48

Did you, by any chance, change the mode of the buffer you opened with C-c '? That's Emacs bug #19887: discussion, and is supposed to have been fixed in February 2015.

If you run into this problem again and are stuck with the editing buffer that doesn't want to close, @wvxvw's suggestion will let you close it.

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.