From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: prettify-symbols-mode to handle "\alpha-\beta" ... Date: Wed, 03 Feb 2021 23:04:49 -0500 Message-ID: References: <87v9b8mvpb.fsf@telefonica.net> <87r1lwmrgc.fsf@telefonica.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4763"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: =?windows-1252?Q?=D3scar?= Fuentes Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Feb 04 05:06:32 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7Vua-00019l-J7 for ged-emacs-devel@m.gmane-mx.org; Thu, 04 Feb 2021 05:06:32 +0100 Original-Received: from localhost ([::1]:51118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7VuZ-0008Tu-LO for ged-emacs-devel@m.gmane-mx.org; Wed, 03 Feb 2021 23:06:31 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7Vt1-0007Y0-Uj for emacs-devel@gnu.org; Wed, 03 Feb 2021 23:04:55 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:1187) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7Vsz-0000ix-JW for emacs-devel@gnu.org; Wed, 03 Feb 2021 23:04:54 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 9BB39805B2; Wed, 3 Feb 2021 23:04:52 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 17B588070D; Wed, 3 Feb 2021 23:04:51 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1612411491; bh=YQiUnusfWmI1oiMhpyKToupf7n6fFeNZ3xHwi2pK87M=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=a2t2oHrATJnq9WB6UmVAxRN4So+FGbZ5q+sLTJMZ4HpLOmu0CLR2ijR0irY858pbk myY/Gn45qX+mo3B/z0/1p9yREbCG2fuE1BnCrNFIBFtC352gfB4Mz63XCM2JgxgEGU MmF4lu7tWitV1121Phb3MeGX5848EMOf2OIRX1NWvDsSwDU4aiIG99X85Ve0pUZq9J OB4m7WLQep3inM8IbjA3I3/FoCsaDlQjRqzq+Xp7jDQOCfhTTOC9GstH2nL9lzdmMp m6x/aKyq2O6mZDZqCUr0XeZihrbwdufJiJT4JwqJ9k79J8a9/dWw5Kb51tGP/m7kIj AdVO7P4VBWS7g== Original-Received: from alfajor (76-10-182-85.dsl.teksavvy.com [76.10.182.85]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B1A6C1200B7; Wed, 3 Feb 2021 23:04:50 -0500 (EST) In-Reply-To: <87r1lwmrgc.fsf@telefonica.net> (=?windows-1252?Q?=22=D3scar?= Fuentes"'s message of "Thu, 04 Feb 2021 04:39:47 +0100") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:263840 Archived-At: > Supporting what you want would require either changing what texinfo > considers a symbol or changing prettify-symbols-mode to work on > something else instead of symbols. The second can be done without changing the code of `prettify-symbols-mode`: you want to change `prettify-symbols-compose-predicate` which contains the function that decides whether a given occurrence should be prettified or not. E.g. the default is the function `prettify-symbols-default-compose-p` defined as follows: (defun prettify-symbols-default-compose-p (start end _match) "Return true iff the symbol MATCH should be composed. The symbol starts at position START and ends at position END. This is the default for `prettify-symbols-compose-predicate' which is suitable for most programming languages such as C or Lisp." ;; Check that the chars should really be composed into a symbol. (let* ((syntaxes-beg (if (memq (char-syntax (char-after start)) '(?w ?_)) '(?w ?_) '(?. ?\\))) (syntaxes-end (if (memq (char-syntax (char-before end)) '(?w ?_)) '(?w ?_) '(?. ?\\)))) (not (or (memq (char-syntax (or (char-before start) ?\s)) syntaxes-beg) (memq (char-syntax (or (char-after end) ?\s)) syntaxes-end) (nth 8 (syntax-ppss)))))) You'd presumably want to then define your own such function which does pretty much the same except that it doesn't accept the syntax `_`: (defun texinf-prettify-symbols-compose-p (start end _match) ;; We know the matches all start with a backslash and end with ;; a word-element. (not (or (memq (char-before start) '(?\\)) (memq (char-syntax (or (char-after end) ?\s)) '(?w)) (nth 8 (syntax-ppss))))) -- Stefan