1

I have the following code in my .emacs file. It's supposed to move the input focus to any newly created frame.

(defun foo-focus-new-frame (frame)
  (select-frame-set-input-focus (frame)))
(add-hook 'after-make-frame-functions 'foo-focus-new-frame t)

This works fine when I run emacs directly from the command line. However, if emacs is not started and I try and run the following:

emacsclient -c -a '' test.txt

I get the following error:

*ERROR*: Symbol's function definition is void: frame

Why is this? According to the documentation the after-make-frame-functions hook should only be run after a frame is newly created, so why can't my function find it?

FixMaker
  • 3,759
  • 3
  • 26
  • 44
  • 1
    I think you'll find that it fails in *exactly* the same way when you run Emacs normally (bearing in mind that the initial frame is created before your custom code is ever evaluated). Try `C-x 5 2` to create a *new* frame. – phils Jan 14 '15 at 10:57
  • @phils, you are indeed correct. My mistake. It was just more obvious when running emacsclient (since it refused to start at all) than when running Emacs normally (since the error was only displayed in the `*Messages*` buffer, but everything still ran as normal). – FixMaker Jan 14 '15 at 19:12

1 Answers1

3

The frame function doesn't exist, perhaps you intended to access the parameter instead of calling a function, i.e. you have extraneous parentheses in foo-focus-new-frame:

(defun foo-focus-new-frame (frame)
  (select-frame-set-input-focus frame))
acelent
  • 7,965
  • 21
  • 39