From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: feature request: text property to prevent font-locking Date: Thu, 28 Aug 2014 14:18:28 -0700 (PDT) Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1409260751 10830 80.91.229.3 (28 Aug 2014 21:19:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Aug 2014 21:19:11 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 28 23:19:05 2014 Return-path: Envelope-to: ged-emacs-devel@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 1XN75z-0004lM-SQ for ged-emacs-devel@m.gmane.org; Thu, 28 Aug 2014 23:19:04 +0200 Original-Received: from localhost ([::1]:39037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN75x-0004IX-5p for ged-emacs-devel@m.gmane.org; Thu, 28 Aug 2014 17:19:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN75c-0004HP-BE for emacs-devel@gnu.org; Thu, 28 Aug 2014 17:18:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XN75U-0007B8-OI for emacs-devel@gnu.org; Thu, 28 Aug 2014 17:18:40 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:49562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN75U-0007B0-Hn for emacs-devel@gnu.org; Thu, 28 Aug 2014 17:18:32 -0400 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s7SLIU81005393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Aug 2014 21:18:31 GMT Original-Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s7SLIT0s004380 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 28 Aug 2014 21:18:30 GMT Original-Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s7SLITbP004358 for ; Thu, 28 Aug 2014 21:18:29 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8.2 (807160) [OL 12.0.6691.5000 (x86)] X-Source-IP: ucsinet21.oracle.com [156.151.31.93] 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: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:173881 Archived-At: Excuse me if I'm missing something that is already available. And in that case, please let me know what it is, so I can use it. I want to apply some ad-hoc highlighting with text property `face' in a font-locked buffer (whether font-locking occurs before or after I apply `face' for this highlighting). I do not want font-lock to override this highlighting. I do not want to use `font-lock-keywords' (e.g. with KEEP) in order to create this highlighting. I just want to prevent font-lock from overriding it. I want to apply some other text property to the highlighted text, to tell font-lock not to fiddle with it ("hands off this text"). 1. Does this possibility already exist in Emacs? I looked but didn't find anything. 2. If not, can we please add it? Wrt #2: Years ago I added this feature to code that I use. It works for me, but I don't claim that the way I implemented it is the way to go. The code I use is here: http://www.emacswiki.org/emacs-en/download/font-lock%2b.el Essentially I did this: 1. Defined function `put-text-property-unless-ignore', which is the same as `put-text-property' but ignores text that has property `font-lock-ignore'. 2. Redefined function `font-lock-default-unfontify-region' to not unfontify text that has property `font-lock-ignore', =20 3. Redefined these functions to use `put-text-property-unless-ignore' instead of `put-text-property': font-lock-prepend-text-property font-lock-append-text-property font-lock-fillin-text-property font-lock-apply-syntactic-highlight font-lock-fontify-syntactically-region font-lock-apply-highlight font-lock-fontify-anchored-keywords font-lock-fontify-keywords-region That is, the change to each of these functions is ONLY to use `put-text-property-unless-ignore' instead of `put-text-property'. My implementation of `put-text-property-unless-ignore': (defun put-text-property-unless-ignore (start end property value &optional object) "`put-text-property', but ignore text with property `font-lock-ignore'." (let ((here (min start end)) (end1 (max start end)) chg) (while (< here end1) (setq chg (next-single-property-change here 'font-lock-ignore object end1)) (unless (get-text-property here 'font-lock-ignore object) (put-text-property here chg property value object)) (setq here chg)))) Perhaps there is a better way to do this. Dunno. In any case, my request is just for Emacs to have such a feature, however it might be implemented. Even better would be an answer that Emacs already has something like this that I'm unaware of. I use this feature for various highlighting (and unhighlighting) commands, so that the highlighting works for font-locked text too. This includes `facemenu-add-face' (my version).