[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#34952: files with/out final newline look the same no matter what
From: |
Basil L. Contovounesios |
Subject: |
bug#34952: files with/out final newline look the same no matter what |
Date: |
Sun, 24 Mar 2019 01:07:26 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
積丹尼 Dan Jacobson <jidanni@jidanni.org> writes:
> indicate-empty-lines is great, but still doesn't show the user the difference
> between
> $ echo abcd > fileA
> $ echo -n abcd > fileB
> $ emacs file*
> Therefore some new variable is needed.
> No I'm not talking about writing files, I'm just talking about how they
> look when opened.
I know and make use of two different customisations to indicate missing
newlines at EOF.
The first is built-in and (probably) more subtle/elegant/efficient, but
relies on the fringe, so only works on graphical frames:
(setq-default indicate-buffer-boundaries t)
See (info "(emacs) Displaying Boundaries") and
(info "(elisp) Fringe Indicators") for details and
variations of this feature.
The second uses font-lock-mode via hi-lock-mode. You can configure
font-lock-mode to highlight missing EOF newlines directly, without
relying on hi-lock-mode, but the latter conveniently provides the global
minor mode global-hi-lock-mode and blacklist hi-lock-exclude-modes for
easy customisation. Here are the incantations:
(defun my-hi-lock-no-eof-nl ()
"Highlight missing trailing EOF newlines."
(setf (alist-get "^.+\\'" hi-lock-interactive-patterns nil nil #'equal)
'(0 'trailing-whitespace prepend)))
(add-hook 'hi-lock-mode-hook #'my-hi-lock-no-eof-nl)
(global-hi-lock-mode)
You can, of course, change trailing-whitespace to a face of your
choosing. See (info "(emacs) Highlight Interactively") for more
information on hi-lock-mode.
Having said all this, I still think it would be nice to add a
whitespace-style setting which visualised missing EOF newlines.
--
Basil