* bug#22980: Something looks fishy in prettify-symbols-default-compose-p (it depends on (point))
@ 2016-03-10 17:30 Clément Pit--Claudel
0 siblings, 0 replies; only message in thread
From: Clément Pit--Claudel @ 2016-03-10 17:30 UTC (permalink / raw)
To: 22980
[-- Attachment #1.1: Type: text/plain, Size: 2344 bytes --]
The docs of prettify-symbols-default-compose-p and prettify-symbols-compose-predicate don't suggest that the function should depend on the point, but it looks like it does:
(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.
(message "%S %S %S %S" (point) start end _match)
(print (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 (print (memq (char-syntax (or (char-before start) ?\s)) syntaxes-beg))
(print (memq (char-syntax (or (char-after end) ?\s)) syntaxes-end))
(print (nth 8 (syntax-ppss))))))))
^ here
(defvar-local prettify-symbols-compose-predicate
#'prettify-symbols-default-compose-p
"A predicate for deciding if the currently matched symbol is to be composed.
The matched symbol is the car of one entry in `prettify-symbols-alist'.
The predicate receives the match's start and end positions as well
as the match-string as arguments.")
This means that calling (prettify-symbols-default-compose-p 1 2 nil) returns nil or t in the following example returns nil or t depending on the point in the following example:
(* example *)
^ column 1 starts here
This makes it unreliable to prettify ‘*’ as ‘×’ in OCaml, for example.
Fixing this issue is not entirely trivial: calling syntax-ppss on end will work in some cases, and in other cases it would be better on beg. This is because for a two-characters comment starter, syntax-ppss is inconsistent in what it call the “inside” of the comment:
(* comment *)
^ outside ^ inside
This is a follow up to this ML thread: https://lists.gnu.org/archive/html/emacs-devel/2016-03/msg00415.html
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-03-10 17:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-10 17:30 bug#22980: Something looks fishy in prettify-symbols-default-compose-p (it depends on (point)) Clément Pit--Claudel
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.