|
From: | Stefan Monnier |
Subject: | Re: prettify-symbols-mode to handle "\alpha-\beta" ... |
Date: | Wed, 03 Feb 2021 23:04:49 -0500 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> 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
[Prev in Thread] | Current Thread | [Next in Thread] |