Making a Haskell plugin, request for advice

Hi. I’ve been using TeXmacs or a few months now, and I’ve switched to it for a number of documents I’m writing. Thanks for this amazing editor.

As the title states, I’ve created a very basic plugin to interact with Haskell’s REPL (ghci). I’m amazed as to how little I need to do (just forward wrapped text back and forth) for TeXmacs to do its thing. However, I’ve run into a wall.

In the init file, right after the plugin-configure entry, I do this:

;;  Add the help file to the Help->Plugins menu.
(when (and supports-ghci? ghci-doc-dir)
  (tm-menu (help-plugins-menu)
           ("GHCi" (load-help-article
                     (string-append ghci-doc-dir "/Help - The GHCi")))))

Which has the desired effect in Windows, but not in Linux, where nothing happens (if I run it in a Scheme session in TeXmacs, though, it works.) I’ve tried delaying tm-menu for a couple of seconds to no avail, and using menu-bind instead gave me an error message. Is there a workaround? Am I doing something wrong?

(In case you’re wondering, ghci-doc-dir resolves to $TEXMACS_HOME_PATH/plugins/ghci/doc, $TEXMACS_PATH/plugins/ghci/doc or #f if none of the former are available. I’ve tested its resolution in both OSs.)

Any help will be appreciated.

1 Like

This hack should not be necessary. The original definition of (help-plugins-menu) (in progs/doc/help-menu.scm reads

(define (plugin-documented? name)
  (and (url-exists-in-help? (string-append name ""))
       (url-exists-in-help? (string-append name ""))))

(tm-menu (help-plugins-menu)
  (for (name (list-filter (map symbol->string (plugin-list))
    (with menu-name `(verbatim ,(session-name name))
      ((eval menu-name)
       (load-help-article (string-append name))))))

so if the documentation is present, you should be able to see it automatically. Check how other plugins implement their documentation, or read the relevant parts of the online manual.

1 Like

Will do. Thanks bunches.