From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: Idea: Be able to use text properties as face attributes Date: Sun, 26 Mar 2017 14:42:58 -0700 (PDT) Message-ID: <2c5fce4c-c79a-41f7-9162-e99148665be5@default> References: <7a902f7b-d808-4d0f-8ff9-b8f07eaddf83@default> <8800c317-f4c1-d1b2-a9cf-c871d6190c53@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1490564634 15587 195.159.176.226 (26 Mar 2017 21:43:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 26 Mar 2017 21:43:54 +0000 (UTC) To: =?utf-8?B?Q2zDqW1lbnQgUGl0LUNsYXVkZWw=?= , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 26 23:43:49 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csFwu-00033C-Vs for ged-emacs-devel@m.gmane.org; Sun, 26 Mar 2017 23:43:45 +0200 Original-Received: from localhost ([::1]:42996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csFx0-0006z7-NK for ged-emacs-devel@m.gmane.org; Sun, 26 Mar 2017 17:43:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csFwN-0006yu-MR for emacs-devel@gnu.org; Sun, 26 Mar 2017 17:43:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csFwI-0004g7-R0 for emacs-devel@gnu.org; Sun, 26 Mar 2017 17:43:11 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:50518) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csFwI-0004fi-Hw for emacs-devel@gnu.org; Sun, 26 Mar 2017 17:43:06 -0400 Original-Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v2QLh2Mw009205 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 26 Mar 2017 21:43:02 GMT Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v2QLh0bp016885 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sun, 26 Mar 2017 21:43:01 GMT Original-Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v2QLgxmp031450; Sun, 26 Mar 2017 21:43:00 GMT In-Reply-To: <8800c317-f4c1-d1b2-a9cf-c871d6190c53@gmail.com> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6753.5000 (x86)] X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 141.146.126.69 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:213394 Archived-At: > > WDOT? Is this something that would be useful? If so, would > > someone like to work on implementing it? >=20 > This sounds interesting, and the proposal is clear and nice. Can you > think of concrete examples where it would things much easier for > package developers (your example with 'invisible is nice)? I haven't thought much about uses, in particular for packages. I expect that others can come up with more possible uses. The main point, for me, is that it provides a way to change the properties of many stretches of text all at once, namely all text (or all text on a given frame) that has a given face. > I can think of one, if I understand correctly. Currently, if one want fo= nt- > lock to apply properties other tan face, then one must add these properti= es > to font-lock-extra-managed-props =E2=80=94 and then font-lock will remove= these > properties indiscriminately, regardless of where they came from. This ma= kes > things difficult sometimes. With your proposal, these attributes could be > tucked in a face. Yes, that's what I meant by saying that you can turn all uses of a given face from `face' uses to `font-lock-face' uses, i.e., hand its control over to font-lock. I like your expression "these attributes could be tucked in[to] a face". Which means that manipulating/using the face means also (indirectly) manipulating/using the other properties that the face carries on board. Wherever the face is used, so are the other properties used. And it means nothing beyond that. In particular, as you say, only the uses of that one face are affected. And to be clear, it's not about this feature _instead of_ some other approach. In particular, when it suits, which is probably most of the time, changing properties directly is fine. You don't _have_ to couple a face with properties that are not face-related. The point is only that you _can_ do that, so you can take advantage of bulk-applying (or bulk-removing) such non-face properties from a bunch of locations, all at once. The face that holds them acts as a _carrier_ for them. > I wonder if your suggestion could be generalized. Fundamentally, > is there a good reason to have a distinction between face > properties and text properties ? Well, the suggestion is to let most (all?) text properties _be_ face properties, in the sense that a face can hold them. (That doesn't mean that they all need to have an effect on the text that is related to the effect of the face on it.) Clearly there is a distinction between text properties that are related to faces and those that are not, where the latter are (also or instead) related to things other than the appearance of a face. And let's not forget that anyone can create any text property (e.g. `jkjkljkl'), with any value, and apply it to some text. Some text properties that are not really related to faces are built-in (`emacs -Q'). Others are created by user code that alone determines how they behave - what their effect is. But I guess you are suggesting the other direction: that all face attributes would be applicable to text as text properties on their own. E.g., you would be able to do: (put-text-property 30 42 :family "Palatino") That might be another possible enhancement. But I think that is already possible using an anonymous face (see (elisp) `Special Properties'): (put-text-property 30 42 'face '(:family "Palatino")) Is there something else you were thinking of here? > Then faces would work in a similar fashion to overlay > categories (a quick way to set consistent properties on > many chunks of text) Maybe you could elaborate, e.g., with a (fictitious) example? Maybe show what else you think is needed for that, beyond what I suggested. (BTW, I just noticed that the text property `category' and the overlay property `category' are apparently completely different beasts. Why did we choose to use the same name for them? Seems like the text property should instead be called `char-category' or some such.)