* Re: Highlighting a missing final newline?
2016-03-22 11:30 Highlighting a missing final newline? egarrulo
@ 2016-03-22 11:50 ` Yuri Khan
2016-03-22 13:37 ` egarrulo
2016-03-22 13:49 ` Drew Adams
` (4 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Yuri Khan @ 2016-03-22 11:50 UTC (permalink / raw)
To: egarrulo; +Cc: help-gnu-emacs@gnu.org
On Tue, Mar 22, 2016 at 5:30 PM, egarrulo <egarrulo@gmail.com> wrote:
> 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.
>
> Thank you.
Maybe highlight the last character which is not newline and is
immediately followed by the end of buffer, by regexp ".\'"?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Highlighting a missing final newline?
2016-03-22 11:50 ` Yuri Khan
@ 2016-03-22 13:37 ` egarrulo
0 siblings, 0 replies; 8+ messages in thread
From: egarrulo @ 2016-03-22 13:37 UTC (permalink / raw)
To: Yuri Khan; +Cc: help-gnu-emacs@gnu.org
On 22/03/16 12:50, Yuri Khan wrote:
> Maybe highlight the last character which is not newline and is
> immediately followed by the end of buffer, by regexp ".\'"?
I had considered this solution, but this way it seems that there is
something wrong with the last printable character. Thanks anyway.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Highlighting a missing final newline?
2016-03-22 11:30 Highlighting a missing final newline? egarrulo
2016-03-22 11:50 ` Yuri Khan
@ 2016-03-22 13:49 ` Drew Adams
[not found] ` <mailman.8110.1458654604.843.help-gnu-emacs@gnu.org>
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2016-03-22 13:49 UTC (permalink / raw)
To: egarrulo, help-gnu-emacs
> 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.
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <mailman.8110.1458654604.843.help-gnu-emacs@gnu.org>]
* Re: Highlighting a missing final newline?
2016-03-22 11:30 Highlighting a missing final newline? egarrulo
` (2 preceding siblings ...)
[not found] ` <mailman.8110.1458654604.843.help-gnu-emacs@gnu.org>
@ 2016-03-22 13:57 ` Óscar Fuentes
2016-03-22 16:21 ` Eli Zaretskii
[not found] ` <mailman.8133.1458663736.843.help-gnu-emacs@gnu.org>
5 siblings, 0 replies; 8+ messages in thread
From: Óscar Fuentes @ 2016-03-22 13:57 UTC (permalink / raw)
To: help-gnu-emacs
egarrulo <egarrulo@gmail.com> writes:
> 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.
If your problem consists on editing files that require to end with a
newline, set `require-final-newline' on the mode hook and forget about
that.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Highlighting a missing final newline?
2016-03-22 11:30 Highlighting a missing final newline? egarrulo
` (3 preceding siblings ...)
2016-03-22 13:57 ` Óscar Fuentes
@ 2016-03-22 16:21 ` Eli Zaretskii
[not found] ` <mailman.8133.1458663736.843.help-gnu-emacs@gnu.org>
5 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2016-03-22 16:21 UTC (permalink / raw)
To: help-gnu-emacs
> From: egarrulo <egarrulo@gmail.com>
> Date: Tue, 22 Mar 2016 12:30:45 +0100
>
> 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.
Did you try to enable the indicate-buffer-boundaries feature?
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <mailman.8133.1458663736.843.help-gnu-emacs@gnu.org>]