From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: Highlighting a missing final newline? Date: Tue, 22 Mar 2016 06:49:45 -0700 (PDT) Message-ID: <1049fd4f-1b77-414c-be02-c64e8d6bb7fb@default> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1458654802 30084 80.91.229.3 (22 Mar 2016 13:53:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Mar 2016 13:53:22 +0000 (UTC) To: egarrulo , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 22 14:53:10 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aiMkA-0006ob-37 for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Mar 2016 14:53:10 +0100 Original-Received: from localhost ([::1]:37064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiMk4-00014B-Lt for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Mar 2016 09:53:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiMh4-0004YQ-SC for help-gnu-emacs@gnu.org; Tue, 22 Mar 2016 09:50:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aiMgz-0005vn-Ou for help-gnu-emacs@gnu.org; Tue, 22 Mar 2016 09:49:58 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:40889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiMgz-0005uU-Ia for help-gnu-emacs@gnu.org; Tue, 22 Mar 2016 09:49:53 -0400 Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u2MDnlli006257 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 22 Mar 2016 13:49:48 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u2MDnlMv001520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 22 Mar 2016 13:49:47 GMT Original-Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u2MDnkEX023393; Tue, 22 Mar 2016 13:49:47 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6744.5000 (x86)] X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:109652 Archived-At: > 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. >=20 > 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 =E2=80=98files.el=E2=80=99. Its value is nil This variable is safe as a file local variable if its value satisfies the predicate =E2=80=98symbolp=E2=80=99. 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 =E2=80=98visit=E2=80=99 means do this right after the file is vi= sited. A value of =E2=80=98visit-save=E2=80=99 means do it at both of those times. Any other non-nil value means ask user whether to add a newline, when savin= g. A value of nil means don=E2=80=99t add newlines. Certain major modes set this locally to the value obtained from =E2=80=98mode-require-final-newline=E2=80=99. You can customize this variable.