1

I want to manipulate a frame after it's created. I thought that I could do this with an 'after-make-frame-functions hook as a callback but it seems to return too early.

This is the sample code that demonstrates the issue:

(defvar test-frame nil)

(defun finish-frame-setup( frame )
  (message "test frame is %s" (frame-live-p test-frame)))

(defun test-frame-callback()
  (interactive)
  (add-hook 'after-make-frame-functions 'finish-frame-setup t nil)
  (setq test-frame (make-frame)))  

and

M-x eval-buffer
M-x test-frame-callback

results in

test frame is nil

I'd appreciate any assistance. Emacs 24.4 on win32

4
  • 1
    You're checking test-frame instead of frame ?
    – phils
    Dec 16, 2014 at 5:05
  • I want to act only on test-frame. frame is valid but (eq test-frame frame) is still nil.
    – eatloaf
    Dec 16, 2014 at 5:10
  • Ohhh. the setq only happens after the frame is made and the hook is called before test-frame is assigned to the resulting frame. How would I act on this specific frame?
    – eatloaf
    Dec 16, 2014 at 5:11
  • Well... act on frame? That's the very reason why this argument is passed to the hook functions iiuc.
    – T. Verron
    Dec 16, 2014 at 8:25

1 Answer 1

1

The issue is that after-make-frame-functions is called before the frame is assigned to test-frame.

The solution is to simplify and avoid the callback

(defun test-frame-callback()
  (interactive)
  (setq test-frame (make-frame))
  (message "test frame is %s" (frame-live-p test-frame))))  

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.