PceEmacs feature -- full documentation?

I know this might sound stupid and it might well be documented but I can’t recall seeing it. I was in the PceEmacs and ran make with C-c m and a list of errors popped up and without thikning, and never having tried it before, I clicked on the error in the list and lo, the source file and line was shown in the editor.

I had no idea this was even possible. One of the (small) downsides of Xpce is that it sometimes doesn’t look “fully integrated” with the host OS, and I fully appreciate why, it’s pretty impressive as it is.

My life just got a little more pleasant now I know I can do this…but is is fully documented anywhere? I found the Xpce class docs online, I created a simple window and buttons etc.

Also, is there a full set of documentation for the configurable editor parameters, specifically the font naming scheme as I’d love to be using my fave IBM 3270 font today.

Thanks,
Sean.

1 Like

The status of xpce is rather unclear. It is there (now) mostly to support the IDE as we don’t have anything better. It has a lot of good ideas, but the code is old, the binding to the GUI primitives ancient and the GUI style is Windows 95 :slight_smile:

It is very unclear where things need to go. Fully web-based? Rebase on GTK? Rebase on https://www.electronjs.org/? Wait for a really rich language API so anyone can use the IDE of choice? Revive xpce? The main issue is that any of alternatives require resources that are not obviously available.

Anyway, the fonts can be tweaked using Edit/Editor preferences (edit and restart). The font()
declaration takes an optional 4th argument that allows you to specify the physical font using FontConfig based attributes (X11) or Windows logical font attributes (Windows). That is documented somewhere, but too long ago to tell you where. Some Googling may find it.

1 Like

LOL!! Thank you Jan… it will give me an excuse to pour over source code. I have learned so much reading the source code for SWI, not just about prolog but how a code base looks after long term maintenance too.

Fascinating captain!

Thanks again,
Sean.

I’d argue going for the “language server”/“editor plugin” architecture might be a better/best go at it? I know Eclipse.org is working on a new editor based on vscode (without the things people don’t like about it) that is going to retain “plugin API compatibility” with vscode.

I’ve also seen mention of a prolog plugin for the Eclipse IDE itself, what’s stopping us from leveraging something like that (other than being an external dependency)?

Judging by the behavior of the IDE it seems that it is using the toplevel as a language server already?

I’d love to see some super easy/modern ways to interact with prolog code! (SWISH is arguably “nicer” from a UI standpoint than what comes with the binaries), which might also be advantageous in a atom/vscode/theia system?

Theia link:
https://theia-ide.org/

Thanks for your insights. I still wonder whether it is possible to reach the level of interactivity and precision of the built-in PceEmacs. It gets this by regularly analyzing the complete file and analyze the current clause on each key stroke. This can work because the editor and Prolog are in the same process and the xpce editor provides an API that allows Prolog to open the editor data as a stream.

Prolog is relatively unique in its need for this because it has no keywords and (thus) every token only gets its meaning from the context. For example is can be arithmetic evaluation, but only if it is a term of arity two that is used on a goal position in a clause body. A second problem are dynamic operators and various other dynamic syntax properties that imply we cannot use a fixed grammar in the editor.

So it sounds like what a language server does for other languages?

There have been several discussions about the language server protocol here as well as an announcement of an implementation for SWI-Prolog. See e.g., Get line numbers from `xref_called/3` started by @jamesnvc. I think the state was this does not cover syntax highlighting and there is an initiative to extend the API to cover syntax highlighting but this isn’t final and there are no implementations (yet, and this is a year ago). Did the situation change?

It looks like the LSP spec is getting closer to having server-side syntax highlighting; some PRs in flight that look like they might get merged soon. Hopefully that will land soon & then I can try integrating that with the Prolog LSP implementation.

1 Like

that would be absolutely fantastic. making swi an even more pleasant user experience would greatly help it take over the world!

1 Like