Reputation: 4501
Some text editors can display changed line by default. But in Emacs, how?
Upvotes: 4
Views: 1347
Reputation: 906
The minor mode highlight-changes-mode
displays text changes.
ADDITION:
I wrote some code of fringe support for 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)
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))))))
Upvotes: 11
Reputation: 9417
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.
I also use diff-hl
mode, which shows changed lines of the saved file vs. the last commit in a version control system. It's available in 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 C-x v =
(current file) or C-x v D
(entire project).
Upvotes: 3