在emacs窗口中居中文本 [英] Centering text in emacs window

查看:161
本文介绍了在emacs窗口中居中文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个孤独的emacs框架内,我经常在编辑70列文本文件(LaTeX)和120列程序(.h / .cpp文件)之间进行切换。我想继续使用一个emacs框架,而不需要调整大小或创建其他框架。



这是问题。我的窗口的宽度是编辑120列程序的权利,但在扩展文本编辑会话期间,70列出现在窗口的左侧。在笔记本电脑前一天结束时,我的脖子似乎已经在左边获得了半永久的倾斜。



你是否知道一个方法来做文本显示为中心,同时仍然使文本文件在右侧保持锯齿状。

解决方案

您可以尝试通过增加缩小框架边缘大小。例如:

 (set-fringe-style'(200。200))

将在主文本区域的每一边刮掉200个像素,使工作区域的像素更窄,但仍然居中。要返回常规视图,

 (set-fringe-style'default)

将边缘恢复到正常大小。



你可以把它包起来一些建议,如果你坚持使用一个窗口,这可能对你很有帮助:

 (defadvice switch-to-buffer (开关到缓冲区调整边缘激活)
取决于主模式,切换条纹样式
(if(memq major-mode'(latex-mode))
set-fringe-style'(200,200))
(set-fringe-style'default)))

注意:更新列表(latex-mode)以包含任何想要拥有大条纹的模式。 p>

Inside just one lonely emacs frame I switch frequently between editting 70-column text files (LaTeX) and 120-column programs (.h/.cpp files). I'd like to continue to use just one emacs frame, without resizing it or creating additional frames.

Here is the problem. The width of my window is about right for editting the 120-column programs, but during the extended text editting sessions, the 70 columns appear on the left side of the window. At the end of the day in front of a laptop, my neck seems to have acquired a semi-permanent tilt to the left.

Are you aware of a method to make the text appear centered, while still making the text files remain jagged on the right?

解决方案

You could try narrowing the frame by increasing the fringe size. For example:

(set-fringe-style '(200 . 200))

would shave 200 pixels off each side of the main text area, leaving the work area 400 pixels narrower but still centered. To return to the regular view,

(set-fringe-style 'default)

will revert the fringe to the normal size.

And you can wrap that up inside some advice, which might work well for you if you stick to using just a single window:

(defadvice switch-to-buffer (after switch-to-buffer-adjust-fringe activate)
  "depending on major mode, switch fringe style"
  (if (memq major-mode '(latex-mode))
  (set-fringe-style '(200 . 200))
(set-fringe-style 'default)))

Note: Update the list (latex-mode) to contain whatever modes you want to have the large fringes.

这篇关于在emacs窗口中居中文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆