默认情况下,某些文本编辑器可以显示更改的行。但是在Emacs中,如何?
最佳答案
次要模式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))))))
(来源:gyazo.com)
加成:
要删除节省时间的要点,请尝试:
(add-hook 'after-save-hook
(lambda ()
(when highlight-changes-mode
(save-restriction
(widen)
(highlight-changes-remove-highlight (point-min) (point-max))))))