Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8053511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:52:13+00:00 2026-06-05T07:52:13+00:00

I use with-output-to-temp-buffer function, redirect the standard output to it, save it to a

  • 0

I use with-output-to-temp-buffer function, redirect the standard output to it, save it to a file, switch back to previous buffer, then kill the temp buffer.

(require 'find-lisp)
(with-output-to-temp-buffer "*my output*" 
  (mapc 'print (find-lisp-find-files "~/project/clisp" "\\.lisp$"))
  (setq prev-buffer (buffer-name))
  (switch-to-buffer "*my output*")
  (write-region nil nil "test")
  (switch-to-buffer prev-buffer)
  (kill-buffer "*my output*")
  )

But error below occur. I don’t know why.

Debugger entered--Lisp error: (error "Selecting deleted buffer")

PS: Is there more elegant way to achieve this in elsip(redirect standard output to a file). Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:52:14+00:00Added an answer on June 5, 2026 at 7:52 am

    This error occurs because with-output-to-temp-buffer tries to display the buffer after evaluating its body, but at that point you have already deleted the buffer. I think with-temp-file is the macro you’re looking for. Its docstring says:

    (with-temp-file FILE &rest BODY)

    Create a new buffer, evaluate BODY there, and write the buffer to FILE.

    You can then bind standard-output to the new buffer, something like:

    (with-temp-file "test.txt"
      (let ((standard-output (current-buffer)))
        (mapc 'print (find-lisp-find-files "~/project/clisp" "\\.lisp$"))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use XSLT text output to generate a file (in a file
I use object buffering to buffer the output of my php pages using ob_start('ob_gzhandler');
Trying to redirect a subprocess' output to a file. server.py: while 1: print Count
I use Intent intent = new Intent(android.media.action.IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(getSomePath()+temp.jpg))); //intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); startActivityForResult(intent, 0);
How use output parameter from procedure?
How can I use output caching with a .ashx handler? In this case I'm
I am trying to use a XslCompiledTransform, and use the output as a XPathDocument.
What is better to use for Exception output message dynamic generation String or StringBuilder
As everybody knows, you have limited precision when you use printf to output the
I use sprintf() on my program to output some tabs and newlines. I noticed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.