I am essentially trying to build a list of strings, where each of those strings in turn are built by their own functions.
However, I get the following error when the code is evaluated:
Wrong type argument: stringp, nil
Here is the code:
(defun mode-line-segment-git-status ()
"Build the git status mode-line segment."
(let (branch-name '(substring-no-properties vc-mode 5)))
(list "Branch: " 'branch-name))
(defvar mode-line-segments nil)
(defun add-mode-line-segment (segment)
"Add a modeline segment to the modeline."
(setq mode-line-segments (append mode-line-segments (funcall segment))))
(add-mode-line-segment 'mode-line-segment-git-status)
(setq-default mode-line-format mode-line-segments)
What am I doing wrong?
let
in your first function a) should enclosed yourlet
-bound variable in its own set of parentheses, and b) should not quote the function whose value you want to bind to the variable.