有没有办法把一个值放在modeline的右端?
根据我目前的理解,如果值的大小增加,modeline会将其值“推”得更靠右。如果一些值从右边开始并扩展到中间,我会更喜欢它。
我已经尝试过像powerline这样的解决方案,但它们看起来相当分散注意力,而且在设置上更加复杂,以显示与标准modeline相同的信息量。
发布于 2013-05-28 06:07:39
据我所知,这不可能通过普通模式行的直接定制来实现。您可以修改mode-line-format变量以在一定程度上改变其外观和内容,但就文本对齐的内置结构而言,我敢肯定您只能通过填充或截断来控制模式行组件的宽度。不过,在mode-line-format变量中使用一些巧妙的技巧(使用(:eval ...)和/或(list ...)表单)来实现所需的结果可能是可行的。您可以咨询Emacs Lisp Reference Manual page on the mode-line-format variable以了解详细信息。除此之外,您还必须使用一些第三方包。
发布于 2014-04-10 02:50:28
这里有一种方法可以做到。技巧是添加空格,直到行尾减去显示文本所需的位置(从emacs wiki上的powerline代码中提取):
(defun mode-line-fill (face reserve)
"Return empty space using FACE and leaving RESERVE space on the right."
(unless reserve
(setq reserve 20))
(when (and window-system (eq 'right (get-scroll-bar-mode)))
(setq reserve (- reserve 3)))
(propertize " "
'display `((space :align-to (- (+ right right-fringe right-margin) ,reserve)))
'face face))
;; Set the modeline to tell me the filename, hostname, etc..
(setq-default mode-line-format (list
" "
mode-line-mule-info
'mode-line-modified
"- "
'mode-line-buffer-identification
" (%l, %c) "
'mode-line-modes
" -- "
`(vc-mode vc-mode)
;; Fill until the end of line but 10 characters
(mode-line-fill 'mode-line 10)
"Some text"
)
)https://stackoverflow.com/questions/16775855
复制相似问题