reddit / emacs

Emacs support for funny programming languages (like "EasyLanguage")

TurtleInTheSky · 2022-02-02 02:53
Just thought I'd ask... I've been doing a bit of coding in the TradeStation "EasyLanguage" in Text Mode and wondering what would be give me more. I've used C-mode with tags which is awesome. Auto indentation, syntax highlighting, ... Oooooooo! I'm sure I'm not up for writing a major mode. Here's a sample: method void UpdatePlaceOCOButton() variables: OrderTemplateInfo info; begin if IncludeOCO() and AppStorage[OCO_TEMPLATE_KEY] astype string <> "" and PlaceOCOButton <> NULL and OCOOrderTemplateInfo <> NULL then begin info = OCOOrderTemplateInfo.Find( AppStorage[OCO_TEMPLATE_KEY] astype string ); PlaceOCOButton.BackColor = OCOButtonBackColor; PlaceOCOButton.Text = !( "Place OCO Order" ); if info <> NULL then begin switch( info.Action ) begin case OrderTemplateAction.exit: if PositionsProvider1.State = DataState.loaded then PlaceOCOButton.Enabled = PositionsProvider1.Count > 0 else PlaceOCOButton.Enabled = false; if PreviewOrdersCheckbox.Checked and OrderPreviewAllowed and PlaceOCOButton.Enabled then begin if LongPositionExists() then PlaceOCOButton.BackColor = SellButtonBackColor else PlaceOCOButton.BackColor = BuyButtonBackColor; if OCOExitPreviewInProgress = false then PlaceOCOButton.Text = !( "Preview OCO Order" ); end; case OrderTemplateAction.entry: PlaceOCOButton.Enabled = true; default: PlaceOCOButton.Enabled = false; end; end else begin PlaceOCOButton.Enabled = false; end; end; end;
[deleted] · 2022-02-02 03:47
Could you rephrase your question?
TurtleInTheSky · 2022-02-02 04:27
Oh, sorry. Is there a better mode than text for this language? That would provide indentation based on syntax for example? Or autocompletion of identifiers?
[deleted] · 2022-02-02 05:00
Ah I see now. I'm not familiar with enough languages to tell. But due to the other effects of the Emacs environment, I doubt that that would be a very pleasant experience. Writing a mode for Emacs doesn't need to be overly complicated. (If it was, nobody would ever do it!) Here's a single page on Emacs Wiki that explains step by step how to create an emacs mode: [https://www.emacswiki.org/emacs/ModeTutorial](https://www.emacswiki.org/emacs/ModeTutorial) Autocompletion for identifiers might be crudely possible just with the default backend of company mode. There's a setting that preserves capitalization somewhere if it by default tries to autocomplete `MyIdent` to `Myident`. A context-aware autocompletion mode would require compiler/interpreter interaction, or a language server.
7890yuiop · 2022-02-02 05:26
That code looks very similar to Pascal, so maybe take `pascal.el` as your starting point? You may be able to `(define-derived-mode easylanguage-mode pascal-mode ...)` if the two have enough in common. Otherwise you could always just copy+rename+hack until you have what you want.
Mercerenies · 2022-02-02 06:05
I have written several major modes in Emacs for various things. It's really no more than fifty or so lines of code to get the bare basics down. Then it's up to you how much indentation-sensitivity and keymapping you want to support.
deaddyfreddy · 2022-02-02 10:12
pascal, maybe?
TurtleInTheSky · 2022-02-03 12:42
LOL. How diplomatic. Thanks all the great help! You all are knowledgeable and generous. This is a very back burner project so, the delay isn't that I'm not working at it.