2

When read the org mode manual to provide support for the raised question.
The contents in read-only buffer is causally need to be copied as reference here.

Take the Org Capture Template as an example,

enter image description here

Tried to copy to the above region to this text area, to perform the following operations:

1, Ctrl + Shift + 2 set headline "org' as mark
2, Ctrl + N to mark to the end
3, C-w
It prompt it as read-only-buffer

If strike Ctrl + V in this text area, there are no text are pasted.

Is it possible to copy contents from read only buffer?

0

3 Answers 3

4

Use M-w, not C-w. You want to copy the text to the kill-ring, not kill it. Trying to kill the text raises an error in a read-only buffer. Copying the text does not modify the buffer.

C-h k M-w tells you:

M-w runs the command kill-ring-save (found in global-map), which is an interactive compiled Lisp function in simple.el.

It is bound to M-delete, C-insertchar, C-insert, M-w.

(kill-ring-save BEG END &optional REGION)

Save the region as if killed, but don’t kill it.

In Transient Mark mode, deactivate the mark.

If interprogram-cut-function is non-nil, also save the text for a window system cut and paste.

If you want to append the killed line to the last killed text, use C-M-w before M-w.

The copied text is filtered by filter-buffer-substring before it is saved in the kill ring, so the actual saved text might be different from what was in the buffer.

When called from Lisp, save in the kill ring the stretch of text between BEG and END, unless the optional argument REGION is non-nil, in which case ignore BEG and END, and save the current region instead.

This command is similar to copy-region-as-kill, except that it gives visual feedback indicating the extent of the region being copied.

2
  • I think C-x k M-w must be C-h k M-w
    – muffinmad
    Jan 14, 2019 at 7:37
  • @muffinmad: Indeed. Typo corrected - thanks.
    – Drew
    Jan 14, 2019 at 14:42
2

If strike Ctrl + V in this text area, there are no text are pasted.

The (default) key sequence to paste (or "yank", in the Emacs parlance) the copied text is C-y not C-v.

Your C-w to kill the text in a read-only buffer ought to have still copied it to the kill ring, even though it could not actually delete it from the buffer; so I think your bigger problem was using the wrong key to yank the copied text.

0

Yes, you can copy from read-only buffers. When you do, you will see the warning about the buffer being read only, and no text is removed. However, the text has been added to thw kill ring, and is available to be yanked into another buffer.

You can't yank any text into a read-only buffer of course.

2
  • In most cases, the king ring is empty, should tried multiple time and success by luck .
    – Alice
    Jan 13, 2019 at 16:39
  • I just tried your example and it works as expected - I select text from the help buffer for org-capture-templates, C-w to kill it (which gives the warning), then move to the scratch buffer and insert it with C-y, and I the text is inserted.
    – Tyler
    Jan 14, 2019 at 19:58

Your Answer

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

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