[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to analyze the value of `mode-line-misc-info'?
From: |
Yuri Khan |
Subject: |
Re: How to analyze the value of `mode-line-misc-info'? |
Date: |
Tue, 15 Feb 2022 17:45:56 +0700 |
On Mon, 14 Feb 2022 at 23:46, Kevin Vigouroux via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> #+begin_src emacs-lisp
> ELISP> mode-line-misc-info
> ((global-mode-string
> ("" global-mode-string " ")))
> #+end_src
>
> I don’t understand why there are two nested lists. I thought the second
> list was used as a conditional statement (e.g. `global-mode-string'
> returns non-`nil') to finally concatenate several strings.
>
> • Emacs Lisp Ref. manual — 23.4.2 “The Data Structure of the Mode Line”
> -
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Mode-Line-Data.html
Let’s apply the documented behavior to the data structure you have.
> ((global-mode-string
> ("" global-mode-string " ")))
This is a list and its first (and only) element is a list, so we
process it recursively and concatenate the only result.
> (global-mode-string
> ("" global-mode-string " "))
This is a list whose first element is a symbol, so it’s a conditional.
We take the value of ‘global-mode-string’ as a variable. If it’s nil,
the result is nil; if non-nil, we interpret the ‘then’ part:
> ("" global-mode-string " ")
This is a list whose first element is an empty string, so we
concatenate the results of processing each element.
As for your question:
> I don’t understand why there are two nested lists.
Probably so that modes could plug their own mode line constructs into
the outer list. For me, ‘mode-line-misc-info’ has this value:
((which-function-mode
(which-func-mode
(#1="" which-func-format " ")))
(global-mode-string
(#1# global-mode-string " ")))
so, two independent conditionals, whose results are to be
concatenated. (The first conditional has another conditional inside
it, so the display in fact depends on non-nilness of two variables.)