1

I've been able to do this before, but I can't remember the 'recipe' of sorts.

Say I've got the following function:

(defun fancy-stuff ()
  (with-current-buffer (get-crazy-process-output)
    (do-crazy-post-process)))

I want to debug the crazy post-processing and be able to see where/when it moves point in that buffer.

I've of course instrumented do-crazy-post-process with edebug-defun, but when I step through the code, I have no visual indication of how point is moving in the temporary buffer.

  • Did you try M-x debug-on-entry do-crazy-post-process? What did you try? The question might be clearer if you described what you tried. – Drew Jul 30 '17 at 14:52
  • @Drew See edit. – Sean Allred Jul 30 '17 at 21:31
  • 1
    In edebug, pressing p will temporarily select the current buff in a window and show where point is. – YoungFrog Jul 30 '17 at 22:12
1

True to form, I found the answer while asking the question. For anyone else who finds this useful:

(view-buffer-other-window (current-buffer))

If you place this form anywhere in the form that's being instrumented, you'll see point move in real-time as you step through the code. For example,

(defun fancy-stuff ()
  (with-current-buffer (get-crazy-process-output)
    (view-buffer-other-window (current-buffer))
    (do-crazy-post-process)))
  • Please consider showing how you use that in connection with the code in your question. – Drew Jul 30 '17 at 14:51
  • @Drew Good advice, thank you :-) See edit. It's been a while since I've been on SE – my habits are a little rusty. – Sean Allred Jul 30 '17 at 21:32
1

I found this question because I was having trouble debugging a function that used with-temp-buffer. Using edebug one can press p to temporarily switch to where point is, but this isn't much good because the temp buffer will be gone once edebug is finished.

The easy way in this case is to replace

(with-temp-buffer
  stuff)

with

(with-current-buffer (get-buffer-create "temp-buffer")
  stuff)

And then use the trick above, so:

(with-current-buffer (get-buffer-create "temp-buffer")
  (view-buffer-other-window (current-buffer))
  stuff)

Now the temp buffer will still be around afterwards for inspection.

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.