What’s happening here is that Emacs never sees your (ws-name …) as a binding in your let*—it sees it as the first body form, i.e. “call the function ws-name with this argument.” Since you haven’t defined any function called ws-name, you get
void-function ws-name
Why? A little parenthesis-hygiene
In Emacs-Lisp, a let* must look like
(let* ( ;; ← open binding list
(var1 init1)
(var2 init2)
…)
;; ← close binding list, now the body forms start
body-form1
body-form2
…)
But if you accidentally close the binding list too early (or never open it around your binding), then Emacs thinks your “bindings” are actually body forms (function calls).
Your snippet as parsed
You showed:
(defun bh/modeline-workspace-project ()
…
(let* (;; 1. comment
;; (no real binding here because you closed it too soon)
(ws-name
(when (fboundp 'ws-current-name)
(ws-current-name))) ; ← THIS is now a body form → tries to CALL `ws-name`
;; 2. …
;; 3. …
)
;; … rest of fn …
)
That stray ) after the comment block ends the binding‐list. Everything from (ws-name …) onwards is body, so Emacs tries to treat ws-name as a function.
The fix
Make sure you wrap all your bindings in the same list:
(defun bh/modeline-workspace-project ()
"Return a string with the current workspace.el and project name.
Shows W:workspace|P:project. Displays 'nada' if a value is not found."
(let* (
;; 1. workspace name
(ws-name
(when (fboundp 'ws-current-name)
(ws-current-name)))
;; 2. project name (projectile.el → project.el)
(proj-name
(or (when (fboundp 'projectile-project-name)
(projectile-project-name))
(when-let (proj (project-current))
(project-name proj))))
;; 3. display strings
(ws-display (or ws-name "nada"))
(proj-display (if proj-name
(file-name-nondirectory
(directory-file-name proj-name))
"nada")))
;; 4. final output
(format "W:%s|P:%s" ws-display proj-display)))
Key points:
- The very first
( after let* opens the binding list.
- You then list all your
(var init) pairs.
- You close that list just before your body—which is your
(format …) call.
- No stray
) in between!
Now Emacs will correctly bind the variable ws-name instead of trying to call it as a function. 😄