Closed jluttine closed 8 years ago
I may have totally misunderstood something.
Yes, you are.
The hooks is a list of functions. And add-hook
is like add-to-list
.
when you run this code
(add-hook 'persp-activated-hook (message (safe-persp-name (get-frame-persp))))
the (message (safe-persp-name (get-frame-persp)))
expression is evaluated inplace and it's value then added to the persp-activated-hook
list.
To do what you want in a right way you must write a function and pass it's name to the add-hook
.
Or you can use lambdas(anonymous functions):
(add-hook 'persp-activated-hook (lambda () (message (safe-persp-name (get-frame-persp)))))
Yep, now I understand. Thanks a lot. :)
How can I get the name of the activated perspective? I'd like to add some code which depends on the name of the perspective. For debugging, I've added the following hook:
But it always prints "Default". Actually, I get
run-hooks: Invalid function: "Default"
. But it's always "Default" and not the name of the layout I'm switching to (or from, for that matter). Am I doing something wrong? If I just runM-:
and(message (safe-persp-name (get-frame-persp)))
, it prints the currently active perspective name correctly. I'm new to Lisp (and configuring Emacs), so I may have totally misunderstood something.