GNU bug report logs - #34952
files with/out final newline look the same no matter what

Previous Next

Package: emacs;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Sat, 23 Mar 2019 05:09:02 UTC

Severity: wishlist

Tags: fixed

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 34952 <at> debbugs.gnu.org
Subject: bug#34952: files with/out final newline look the same no matter what
Date: Sun, 24 Mar 2019 01:07:26 +0000
積丹尼 Dan Jacobson <jidanni <at> 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




This bug report was last modified 4 years and 288 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.