LPCIC / elpi

Embeddable Lambda Prolog Interpreter
GNU Lesser General Public License v2.1
273 stars 32 forks source link

Emacs mode #128

Open mikeshulman opened 2 years ago

mikeshulman commented 2 years ago

For Emacs users like myself, it would be nice to have an Emacs mode for elpi. In fact, I haven't been able to find an Emacs mode for any kind of lambda-prolog that works on a modern Emacs. Does anyone know of such a thing? If not, I could probably throw together a bare-bones Emacs mode myself with a little time, perhaps by deriving from an ordinary prolog mode; would anyone be willing to help me get the syntax regexps and keyword lists correct?

ThatDaleMiller commented 2 years ago

I've been using the emacs code located at https://kamal.aboulhosn.org/lp/tey-emacs.html with the Teyjus implementation of lambda Prolog. Given its age and its explicit use of Teyjus, it would need to be updated for Elpi.

mikeshulman commented 2 years ago

Thanks for the reply! I tried that, but wasn't able to get it to work in a modern Emacs. Any tips?

ThatDaleMiller commented 2 years ago

I use this code in Emacs 27.2 on a linux machine. I have the following lines in my .emacs file.

;;;;;;;;  Teyjus mode  ;;;;;;;
(setq auto-mode-alist
   (cons '("\\.mod\\'" . teyjus-edit-mode) 
    (cons '("\\.sig\\'" . teyjus-edit-mode)
     (cons '("\\.hc\\'" .  teyjus-edit-mode)
      (cons '("\\.def\\'" .  teyjus-edit-mode)
           auto-mode-alist)))))

(autoload 'teyjus           "~/emacs/teyjus"
          "Run an inferior Teyjus process." t)
(autoload 'teyjus-edit-mode "~/emacs/teyjus" 
          "Syntax Highlighting, etc. for Lambda Prolog" t)

The .hc and .def extensions not relevant to either Teyjus or Elpi. I am not, however, an expert in .el file contents so I don't have any additional tips. Hope this helps.

mikeshulman commented 2 years ago

Interesting. On Emacs 26.1 I get (void-function full-copy-sparse-keymap).

mikeshulman commented 2 years ago

Ah, interesting. I didn't find this before, but http://www.verycomputer.com/93_c0f1432ec52c4976_1.htm suggests just replacing full-copy-sparse-keymap with copy-keymap, and that seems to work.

Which of the differences between teyjus and elpi are relevant to an Emacs mode?

ThatDaleMiller commented 2 years ago

Most of my code compiles and runs on both Teyjus and Elpi. On these programs, syntax highlighting to the teyjus.el code works fine for me. Features related to compiling code, error messages, etc (such as M-x teyjus-compile) need to be updated if they are to be used with Elpi.

gares commented 2 years ago

I'd be happy to merge a PR adding setup instructions for emacs (eg in the README). I am no Emacs user, so I would not be confident to write them right myself.