# PceEmacs and CHR

**URL:** <https://swi-prolog.discourse.group/t/pceemacs-and-chr/8653>\
**Category:** Tools\
**Tags:** bug\
**Created:** [December 7, 2024, 8:46pm UTC](https://swi-prolog.discourse.group/t/pceemacs-and-chr/8653 "2024-12-07T20:46:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![z5h](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/z5h/32/5445_2.png) [@z5h](https://swi-prolog.discourse.group/u/z5h)\
**Post date:** [December 7, 2024, 8:46pm UTC](https://swi-prolog.discourse.group/t/pceemacs-and-chr/8653/1 "2024-12-07T20:46:55Z")

</div>

CHR code is incorrectly highlighted in PceEmacs, and false errors are given.  
(chr does not resolve predicates, facing/1 is undefined, etc).

Some sweeprolog made me guess that adding `[library(chr)]` to my initialization in `~/.config/swi-prolog/init.pl` would help. But it doesn’t seem to make any difference.

 ![image](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/6/65ddf06959b5d6923f099cf9b4d2bdd2a8cfae63.png)

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [December 8, 2024, 9:49am UTC](https://swi-prolog.discourse.group/t/pceemacs-and-chr/8653/2 "2024-12-08T09:49:48Z")

</div>

Please include as text rather than image. No reason to let us type this …

---

<div class="post-metadata">

**Author:** ![z5h](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/z5h/32/5445_2.png) [@z5h](https://swi-prolog.discourse.group/u/z5h)\
**Post date:** [December 8, 2024, 4:43pm UTC](https://swi-prolog.discourse.group/t/pceemacs-and-chr/8653/3 "2024-12-08T16:43:04Z")

</div>

```prolog
:- use_module(library(chr)).

:- chr_type direction ---> up; right; down; left.
:- chr_constraint facing(+direction).
:- chr_constraint turn/0.

turn, facing(up) <=> facing(right).
turn, facing(right) <=> facing(down).
turn, facing(down) <=> facing(left).
turn, facing(left) <=> facing(up).

```

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [December 9, 2024, 10:33am UTC](https://swi-prolog.discourse.group/t/pceemacs-and-chr/8653/4 "2024-12-09T10:33:48Z")

</div>

Thanks. I’m not much of a CHR expert ☹ It seems that one can have a CHR constraint by defining the constraint using chr\_constraint/1 and not defining a rule for it. That is not handled by the cross-referencing extensions for CHR. Added a partial solution.

To refer to your other topic on a post you deleted: CHR maintenance is orphaned. That means there is no active support and issues need to be dealt with by the users or other incidental volunteers. Luckily, Tom is a very good programmer and only few issues came up over the years. Surely he is open to help a little, but I fear we cannot rely on his unlimited support. You can only rely that issues that result from bugs or incompatible changes to Prolog itself will be fixed.
