[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Highlighting a missing final newline?
From: |
Drew Adams |
Subject: |
RE: Highlighting a missing final newline? |
Date: |
Tue, 22 Mar 2016 06:49:45 -0700 (PDT) |
> How would you highlight a missing final newline? I mean: if a buffer
> lacks a final newline, then you would see a (customizable) character at
> the end of the buffer; otherwise, you would see nothing.
>
> AFAIK, `font-lock-add-keywords' can't help here because there is no
> character to highlight. I have looked into `whitespace-mode' for
> inspiration, but the code is too complex for me.
I suppose you already know about option `require-final-newline',
and you really want highlighting, not just a chance to add a final
newline. If not:
---
require-final-newline is a variable defined in ‘files.el’.
Its value is nil
This variable is safe as a file local variable if its value
satisfies the predicate ‘symbolp’.
Whether to add a newline automatically at the end of the file.
A value of t means do this only when the file is about to be saved.
A value of ‘visit’ means do this right after the file is visited.
A value of ‘visit-save’ means do it at both of those times.
Any other non-nil value means ask user whether to add a newline, when saving.
A value of nil means don’t add newlines.
Certain major modes set this locally to the value obtained
from ‘mode-require-final-newline’.
You can customize this variable.