首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将值固定在modeline的右侧?

如何将值固定在modeline的右侧?
EN

Stack Overflow用户
提问于 2013-05-27 23:00:52
回答 2查看 1.7K关注 0票数 7

有没有办法把一个值放在modeline的右端?

根据我目前的理解,如果值的大小增加,modeline会将其值“推”得更靠右。如果一些值从右边开始并扩展到中间,我会更喜欢它。

我已经尝试过像powerline这样的解决方案,但它们看起来相当分散注意力,而且在设置上更加复杂,以显示与标准modeline相同的信息量。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 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以了解详细信息。除此之外,您还必须使用一些第三方包。

票数 2
EN

Stack Overflow用户

发布于 2014-04-10 02:50:28

这里有一种方法可以做到。技巧是添加空格,直到行尾减去显示文本所需的位置(从emacs wiki上的powerline代码中提取):

代码语言:javascript
复制
(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"
   )
)
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16775855

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档