summaryrefslogtreecommitdiff
path: root/devdocs/elisp/mode-line-top.html
blob: d064416f65f7a1f632948ae84066e1b4fa59eaf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 <h4 class="subsection">The Top Level of Mode Line Control</h4> <p>The variable in overall control of the mode line is <code>mode-line-format</code>. </p> <dl> <dt id="mode-line-format">User Option: <strong>mode-line-format</strong>
</dt> <dd>
<p>The value of this variable is a mode line construct that controls the contents of the mode-line. It is always buffer-local in all buffers. </p> <p>If you set this variable to <code>nil</code> in a buffer, that buffer does not have a mode line. (A window that is just one line tall also does not display a mode line.) </p>
</dd>
</dl> <p>The default value of <code>mode-line-format</code> is designed to use the values of other variables such as <code>mode-line-position</code> and <code>mode-line-modes</code> (which in turn incorporates the values of the variables <code>mode-name</code> and <code>minor-mode-alist</code>). Very few modes need to alter <code>mode-line-format</code> itself. For most purposes, it is sufficient to alter some of the variables that <code>mode-line-format</code> either directly or indirectly refers to. </p> <p>If you do alter <code>mode-line-format</code> itself, the new value should use the same variables that appear in the default value (see <a href="mode-line-variables">Mode Line Variables</a>), rather than duplicating their contents or displaying the information in another fashion. This way, customizations made by the user or by Lisp programs (such as <code>display-time</code> and major modes) via changes to those variables remain effective. </p> <p>Here is a hypothetical example of a <code>mode-line-format</code> that might be useful for Shell mode (in reality, Shell mode does not set <code>mode-line-format</code>): </p> <div class="example"> <pre class="example">(setq mode-line-format
  (list "-"
   'mode-line-mule-info
   'mode-line-modified
   'mode-line-frame-identification
   "%b--"
</pre>
<pre class="example">   ;; <span class="roman">Note that this is evaluated while making the list.</span>
   ;; <span class="roman">It makes a mode line construct which is just a string.</span>
   (getenv "HOST")
</pre>
<pre class="example">   ":"
   'default-directory
   "   "
   'global-mode-string
   "   %[("
   '(:eval (format-time-string "%F"))
   'mode-line-process
   'minor-mode-alist
   "%n"
   ")%]--"
</pre>
<pre class="example">   '(which-function-mode ("" which-func-format "--"))
   '(line-number-mode "L%l--")
   '(column-number-mode "C%c--")
   '(-3 "%p")))
</pre>
</div> <p>(The variables <code>line-number-mode</code>, <code>column-number-mode</code> and <code>which-function-mode</code> enable particular minor modes; as usual, these variable names are also the minor mode command names.) </p><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
    <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Mode-Line-Top.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Mode-Line-Top.html</a>
  </p>
</div>