1

I am trying to make an interactive toggle in emacs 27.0.90

When I eval-region no warnings or errors are shown.

However, when I do (helm/toggle-frame) in ielm it throws Symbol’s function definition is void: helm-in-frame-p

Here is the code,

(let ((helm-in-frame-p t))
  (defun helm/toggle-frame ()
    "Toggle helm in frame or in buffer.
    Default is buffer because it is faster on Xforwarding."
    (interactive)
    (setq helm-in-frame-p (not helm-in-frame-p))
    (if (helm-in-frame-p)
        (progn
          (global-set-key (kbd "M-x") 'helm-M-x-in-frame))
      (progn
        (global-set-key (kbd "M-x") 'helm-M-x)))
    (message "Helm in frame is now %s"
             (if helm-in-frame-p "Enabled" "Disabled"))))

Here is the ielm output

ELISP> helm/toggle-frame
*** Eval error ***  Symbol’s value as variable is void: helm/toggle-frame
ELISP> (helm/toggle-frame)
*** Eval error ***  Symbol’s function definition is void: helm-in-frame-p
  • I presume you've set lexical-binding for this library? – phils Jul 22 at 10:45
  • yes, in fact, I've tried turning off lexical scoping and using a separate setq statement without let binding; same errors – 546756ryd Jul 22 at 12:07
  • Yep; I was just asking in case that was going to be an additional problem once you'd solved the immediate one. – phils Jul 22 at 12:40
2

You define a local variable, then later call a non-existent function with the same name in the if:

(if (helm-in-frame-p)

Drop the surrounding parentheses and it should work again.

| improve this answer | |

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.