一些常用的mode-line包
了解mode-line
mode-line初始值:
1 | ("%e" mode-line-front-space mode-line-mule-info mode-line-client mode-line-modified mode-line-remote mode-line-frame-identification mode-line-buffer-identification " " mode-line-position |
mode-line变量
- mode-line-mule-info:显示当前语言环境、编码信息和输入法;
- mode-line-modified:显示当前内容是否被修改,
**
表示已经被修改,--
表示没有被修改,%%
表示只读,%*
表示只读但是被修改; - mode-line-frame-identification:用来标识当前窗口;
- mode-line-buffer-identification:用来表示当前buffer;
- mode-line-position:用来表示在buffer中的位置,可显示位置百分比、buffer大小、当前行号和列号;
- mode-line-percent-position:在
mode-line-position
中被使用; - vc-mode:显示版本管理信息;
- mode-line-modes:显示当前major和minor modes;
- mode-line-remote:用来显示当前buffer的default-directory是否是远程文件夹;
- mode-line-client:用来表示emacsclient窗口;
- mode-name: 显示当前buffer的major mode;
- mode-line-front-space:显示在mode-line最前面;
- mode-line-end-spaces:显示在mode-line最后面;
- mode-line-misc-info:显示杂项信息;
- minor-mode-alist:包含当前buffer激活的所有minor modes;
- global-mode-string:This variable holds a mode line construct that, by default, appears in the mode line just after the which-func-mode minor mode if set, else after mode-line-modes. The command display-time sets global-mode-string to refer to the variable display-time-string, which holds a string containing the time and load information. The ‘%M’ construct substitutes the value of global-mode-string, but that is obsolete, since the variable is included in the mode line from mode-line-format.
%-Constructs in the Mode Line
- %b:当前buffer名称;
- %c:当前列号,从最左边0开始计算;
- %C:当前列号,从最左边1开始计算;
- %e:When Emacs is nearly out of memory for Lisp objects, a brief message saying so. Otherwise, this is empty.
- %f:文件名;
- %F:窗口名称;
- %i:当前buffer大小;
- %I:Like ‘%i’, but the size is printed in a more readable way by using ‘k’ for 10^3, ‘M’ for 10^6, ‘G’ for 10^9, etc., to abbreviate.
- %l:当前行号;
- %n:‘Narrow’ when narrowing is in effect; nothing otherwise.
- %o:The degree of travel of the window through (the visible portion of) the buffer, i.e. the size of the text above the top of the window expressed as a percentage of all the text outside the window, or ‘Top’, ‘Bottom’ or ‘All’.
- %p:The percentage of the buffer text above the top of window, or ‘Top’, ‘Bottom’ or ‘All’. Note that the default mode line construct truncates this to three characters.
- %P:The percentage of the buffer text that is above the bottom of the window (which includes the text visible in the window, as well as the text above the top), plus ‘Top’ if the top of the buffer is visible on screen; or ‘Bottom’ or ‘All’.
- %q:The percentages of text above both the top and the bottom of the window, separated by ‘-’, or ‘All’.
- %s:The status of the subprocess belonging to the current buffer, obtained with process-status.
- %z:The mnemonics of keyboard, terminal, and buffer coding systems.
- %Z:Like ‘%z’, but including the end-of-line format.
- %*:‘%’ if the buffer is read only (see buffer-read-only); ‘*’ if the buffer is modified (see buffer-modified-p); ‘-’ otherwise.
- %+:‘*’ if the buffer is modified (see buffer-modified-p); ‘%’ if the buffer is read only (see buffer-read-only); ‘-’ otherwise. This differs from ‘%*’ only for a modified read-only buffer.
- %&:‘*’ if the buffer is modified, and ‘-’ otherwise.
- %[:An indication of the depth of recursive editing levels (not counting minibuffer levels): one ‘[’ for each editing level.
- %]:One ‘]’ for each recursive editing level (not counting minibuffer levels).
- %-:Dashes sufficient to fill the remainder of the mode line.
- %%:The character ‘%’—this is how to include a literal ‘%’ in a string in which %-constructs are allowed.
- %m:mode-name;
- %M:global-mode-string;
自定义mode-line
修改mode-line-format
的值:
1 | (defun dotemacs-mode-line-fill (face reserve) |
隐藏mode-line上的minor mode
使用diminish:
1 | (require 'diminish) |