From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Generalizing prettify-symbols-mode Date: Thu, 20 Aug 2015 10:15:08 -0400 Message-ID: References: <87oaia6ict.fsf@mat.ucm.es> <837foxor1t.fsf@gnu.org> <878u9d7vdg.fsf@mat.ucm.es> <87pp2pq2ht.fsf@gnu.org> <87wpwx68cn.fsf@mat.ucm.es> <87mvxqxtif.fsf@gnu.org> <838u9alzly.fsf@gnu.org> <874mjyaqm8.fsf@fencepost.gnu.org> <87d1yl2dq9.fsf@gnu.org> <87r3mz91h2.fsf@gnu.org> <877foqidkv.fsf_-_@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1440119593 2854 80.91.229.3 (21 Aug 2015 01:13:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Aug 2015 01:13:13 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 21 03:13:07 2015 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 1ZSatE-0008Ey-9J for ged-emacs-devel@m.gmane.org; Fri, 21 Aug 2015 03:13:04 +0200 Original-Received: from localhost ([::1]:38736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSatD-0005pF-FK for ged-emacs-devel@m.gmane.org; Thu, 20 Aug 2015 21:13:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSQce-0004iV-2n for emacs-devel@gnu.org; Thu, 20 Aug 2015 10:15:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZSQcY-0002GH-Ms for emacs-devel@gnu.org; Thu, 20 Aug 2015 10:15:15 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:39226) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSQcY-0002G4-Ii for emacs-devel@gnu.org; Thu, 20 Aug 2015 10:15:10 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ArEwA731xV/5P+d0tcgxCEAoVVuzcJh0sEAgKBPDkUAQEBAQEBAYEKQQWDXQEBAwFWKAsLNBIUGA2IWwjPIwErizqFDBaEFwWzP4FFI4QUIoJ4AQEB X-IPAS-Result: A0ArEwA731xV/5P+d0tcgxCEAoVVuzcJh0sEAgKBPDkUAQEBAQEBAYEKQQWDXQEBAwFWKAsLNBIUGA2IWwjPIwErizqFDBaEFwWzP4FFI4QUIoJ4AQEB X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="160823145" Original-Received: from 75-119-254-147.dsl.teksavvy.com (HELO pastel.home) ([75.119.254.147]) by ironport2-out.teksavvy.com with ESMTP; 20 Aug 2015 10:15:09 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 03539622CF; Thu, 20 Aug 2015 10:15:08 -0400 (EDT) In-Reply-To: <877foqidkv.fsf_-_@gnu.org> (Tassilo Horn's message of "Thu, 20 Aug 2015 10:11:44 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:189007 Archived-At: > Is the below what you are suggesting? Pretty much, yes. See nitpicks below. > (prettify-symbols-compose-predicate): New variable with default > value #'prettify-symbols-default-compose-p. You don't need to state its default value here. > (prettify-symbols--compose-symbol): Use > prettify-symbols-compose-predicate. I like to say "Use it" after reordering the entries so that the "used" thingy is the one mentioned in the previous entry. > +(defvar-local prettify-symbols-compose-predicate #'prettify-symbols-default-compose-p > + "A predicate deciding if the currently matched symbol is to be composed. > +The predicate has no arguments and is called by font-lock in the > +context where the regexp match data 0 points to an occurrence of > +a symbol in `prettify-symbols-alist'.") The fact that it uses font-lock should not be documented. We may want to change that in the future. > + (let ((start (match-beginning 0)) > + (end (match-end 0)) > + (match (match-string 0))) > + (if (funcall prettify-symbols-compose-predicate) The predicate will probably need to extract the boundary positions and the string as well, so I think we might as well pass start, end, and match to prettify-symbols-compose-predicate. That also means that prettify-symbols-compose-predicate doesn't need the match-data any more, which I think is a good side-effect (tho not an important one). E.g. it could be useful if we ever end up using a different search strategy where we either don't use a regexp, or use regexp where the matched string is not in "subgroup 0". Stefan