all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Highlighting a missing final newline?
@ 2016-03-22 11:30 egarrulo
  2016-03-22 11:50 ` Yuri Khan
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: egarrulo @ 2016-03-22 11:30 UTC (permalink / raw
  To: 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.

Thank you.


^ 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: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

* Re: Highlighting a missing final newline?
       [not found] ` <mailman.8110.1458654604.843.help-gnu-emacs@gnu.org>
@ 2016-03-22 13:54   ` egarrulo
  0 siblings, 0 replies; 8+ messages in thread
From: egarrulo @ 2016-03-22 13:54 UTC (permalink / raw
  To: help-gnu-emacs

On 22/03/16 14:49, Drew Adams wrote:
> I suppose you already know about option `require-final-newline',
> and you really want highlighting, not just a chance to add a final
> newline.

Yes, I do know about `require-final-newline'.  Thanks.


^ 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
                   ` (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

* Re: Highlighting a missing final newline?
       [not found] ` <mailman.8133.1458663736.843.help-gnu-emacs@gnu.org>
@ 2016-03-22 16:42   ` egarrulo
  0 siblings, 0 replies; 8+ messages in thread
From: egarrulo @ 2016-03-22 16:42 UTC (permalink / raw
  To: help-gnu-emacs

On 22/03/16 17:21, Eli Zaretskii wrote:
>> 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?

This.  Thanks.



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-03-22 16:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
     [not found] ` <mailman.8110.1458654604.843.help-gnu-emacs@gnu.org>
2016-03-22 13:54   ` egarrulo
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>
2016-03-22 16:42   ` egarrulo

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.