I have a function that opens a buffer in order to extract some information from it, then switches back to the original buffer and inserts some text:

  (find-file ThisFile)
  (setq results some-function))
(insert results)

The brief flash when emacs switches to the new buffer is disconcerting. Is it possible to suppress the buffer -- I guess, keep it at the bottom of the buffer stack?

  • 4
    You probably need find-file-noselect gnu.org/software/emacs/manual/html_node/eintr/Find-a-File.html Commented Nov 11, 2015 at 2:34
  • 3
    See also with-temp-buffer gnu.org/software/emacs/manual/html_node/elisp/… and insert-file-contents gnu.org/software/emacs/manual/html_node/elisp/…
    – lawlist
    Commented Nov 11, 2015 at 3:03
  • @kaushalmodi I tried this, but then the subsequent operations in the save-excursion block get carried out on the original buffer (from which to command is called), sort of defeating the purpose.
    – Matt
    Commented Nov 11, 2015 at 12:57
  • @lawlist that works! I'll rewrite as an answer.
    – Matt
    Commented Nov 11, 2015 at 12:59
  • Glad it worked. As to the other idea with find-file-noselect in the first comment, a common usage is in conjunction with the macro with-current-buffer -- but then the buffer either says around or needs to be killed. insert-file-contents won't automatically enable a major-mode, whereas find-file-noselect may trigger a major-mode. It just depends upon personal preference and the result desired.
    – lawlist
    Commented Nov 11, 2015 at 23:23

2 Answers 2


Thanks to @lawlist for this answer.

Instead of

   (find-file some-file)
   ... )

the solution is to use

  (insert-file-contents some-file)
  ... )

This keeps the temp buffer in the background, and also eliminates the problem of stray buffers being left behind after the operation is complete. Works perfectly!

  • 1
    You can accept your own answer. Commented Mar 14, 2016 at 12:37

I had a problem with visual-bell. Try this for gui Emacs:

(setq visible-bell nil)

or this for terminal Emacs

(setq visible-bell t)

One of these will fix it.

  • This had no effect for me.
    – Matt
    Commented Nov 11, 2015 at 12:54
  • Sorry it didn't work for you. I got that hint from someone else here on SX and it fixed the flicker for me.
    – Emacs User
    Commented Nov 11, 2015 at 17:24

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.