unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: "積丹尼 Dan Jacobson" <jidanni@jidanni.org>
Cc: 34952@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	[thread overview]
Message-ID: <87zhpl13n5.fsf@tcd.ie> (raw)
In-Reply-To: <87zhpm18ll.fsf@jidanni.org> ("積丹尼 Dan Jacobson"'s message of "Sat, 23 Mar 2019 13:08:06 +0800")

積丹尼 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





  parent reply	other threads:[~2019-03-24  1:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-23  5:08 bug#34952: files with/out final newline look the same no matter what 積丹尼 Dan Jacobson
2019-03-23  7:34 ` Eli Zaretskii
2019-03-24  1:07 ` Basil L. Contovounesios [this message]
2019-03-24  1:23   ` Basil L. Contovounesios
2020-08-06 19:00   ` Lars Ingebrigtsen
2020-08-07  7:29     ` Lars Ingebrigtsen
2020-08-07 11:07       ` Eli Zaretskii
2020-08-07 11:20         ` Lars Ingebrigtsen
2020-08-07 12:02           ` Lars Ingebrigtsen
2020-08-07 12:11             ` Eli Zaretskii
2020-08-07 12:17               ` Lars Ingebrigtsen
2020-08-07 14:20               ` Stefan Monnier
2020-08-08  9:41                 ` Lars Ingebrigtsen
2020-08-08 13:14                   ` Stefan Monnier
2020-08-07 21:54             ` Basil L. Contovounesios
2020-08-08  9:47               ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zhpl13n5.fsf@tcd.ie \
    --to=contovob@tcd.ie \
    --cc=34952@debbugs.gnu.org \
    --cc=jidanni@jidanni.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).