[英]How can I display changed line in Emacs?
Some text editors can display changed line by default. 默认情况下,某些文本编辑器可以显示更改的行。 But in Emacs, how? 但是在Emacs中,怎么样?
The minor mode highlight-changes-mode
displays text changes. 次要模式highlight-changes-mode
显示文本更改。
ADDITION: I wrote some code of fringe support for highlight-changes-mode
. 附加:我为highlight-changes-mode
编写了一些边缘支持代码。
(eval-after-load "hilit-chg"
'(progn
(defvar highlight-fringe-mark 'filled-square
"The fringe bitmap name marked at changed line.
Should be selected from `fringe-bitmaps'.")
(defadvice hilit-chg-make-ov (after hilit-chg-add-fringe activate)
(mapc (lambda (ov)
(if (overlay-get ov 'hilit-chg)
(let ((fringe-anchor (make-string 1 ?x)))
(put-text-property 0 1 'display
(list 'left-fringe highlight-fringe-mark)
fringe-anchor)
(overlay-put ov 'before-string fringe-anchor))
))
(overlays-at (ad-get-arg 1))))))
(source: gyazo.com ) (来源: gyazo.com )
ADDITION: To remove highlights on save time, try it: 附加:要删除节省时间的亮点,请尝试:
(add-hook 'after-save-hook
(lambda ()
(when highlight-changes-mode
(save-restriction
(widen)
(highlight-changes-remove-highlight (point-min) (point-max))))))
I assume you're interested in changes between the buffer and the saved file. 我假设您对缓冲区和保存文件之间的更改感兴趣。 I usually use diff-buffer-with-file
for that, because I don't need it too often. 我通常使用diff-buffer-with-file
,因为我不经常需要它。
I also use diff-hl
mode, which shows changed lines of the saved file vs. the last commit in a version control system. 我还使用diff-hl
模式,它显示已保存文件的更改行与版本控制系统中的最后一次提交。 It's available in Melpa. 它可以在Melpa中找到。
Here's my config, which changes the indicators to '+', '-', and '!': 这是我的配置,它将指标更改为“+”,“ - ”和“!”:
(setq diff-hl-fringe-bmp-function 'diff-hl-fringe-bmp-from-type)
(global-diff-hl-mode 1)
Though you didn't ask about it, I'll also mention that vc
can easily diff files that are under version control with Cx v =
(current file) or Cx v D
(entire project). 虽然你没有问过它,但我还要提到vc
可以很容易地使用Cx v =
(当前文件)或Cx v D
(整个项目)来Cx v =
受版本控制的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.