windows 10, emacs 26.1

  1. M-x occur
  2. Some text to find
  3. Result show in Occur buffer.

Nice. How I can save content of this buffer in the file?

1 Answer 1


You can use write-file (C-x C-w), then specify a filename.

C-x C-w runs the command write-file (found in global-map), which is an interactive compiled Lisp function in ‘files.el’.

Note however this does not preserve the metadata of the buffer : if you save the buffer to a file, kill the buffer and re-open the file you just saved, you only get the text, no hyperlinks.

  • Another way is (in Occur buffer): 1. Press "e", 2. "C-x C-s" to save to the file. As result it save content an metadata (e.g. hyperlinks) Dec 13, 2018 at 9:11
  • @Alexei what do you mean you save with hyperlinks? In what format are you saving it? I get the same result in both cases.
    – andrej
    Dec 13, 2018 at 15:27
  • @andrej After save in file I can click on hyperlinks and it's work. Dec 13, 2018 at 15:32
  • @Alexei: Please consider posting your comment as another answer.
    – Drew
    Dec 13, 2018 at 15:35

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.