PT Emacs - SkycoinWikis/CX GitHub Wiki

CX HOME » CX » PROGRAMMING TOOLS » EMACS

Setup Emacs for CX

The most important thing in writing code is to easy identify the keywords of the language. In the next steps you get to know how to setup Emacs for writing CX code.

ATM we will use a golang mode to recognize .cx files, but hopefully we will see a cx-mode in the future.

Setup keyword highlighting

  1. Download the latest version of emacs from https://www.gnu.org/software/emacs/

  2. After the installation run your emacs version.

  3. Git clone or download the following repo: https://github.com/dominikh/go-mode.el and save it/unizip it to your prefered directory.

  4. Press Ctrl + x, then Ctrl + f and type ~/.emacs.d/init.el and press Enter
    emacs command syntax: C-x C-f ~/.emacs.d/init.el

  5. Now add the following lines:

(add-to-list 'load-path "directory/of/the/cloned/repository")
(autoload 'go-mode "go-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.cx\\'" . go-mode))
  1. Save and exit the file by pressing Ctrl + x and then Ctrl + s.

  2. Close emacs by pressing Ctrl + x and then Ctrl + c

  3. Now emacs will show all known keywords of golang when you edit cx-files.

Setup Terminal

To run your code directly from emacs you have to setup the Terminal depending on your operating system.

Windows

  1. Open the init file with by pressing Ctrl + x, then Ctrl + f and typing ~/.emacs.d/init.el and pressing Enter

  2. Add the following lines:

(defun run-cmdexe ()
      (interactive)
      (let ((shell-file-name "cmd.exe"))
            (shell "*cmd.exe*")))
  1. Save and exit the file by pressing Ctrl + x and then Ctrl + s.

  2. Close emacs by pressing Ctrl + x and then Ctrl + c

  3. Restart emacs

  4. Now you can run cmd.exe in emacs by pressing Alt + x and then typing run-cmdexe
    emacs command syntax: M-x run-cmdexe

hello-world.cx

  1. Open emacs and make a new file called hello-world.cx by pressing Ctrl + x, then Ctrl + f and typing ~/.emacs.d/hello-world.cx

  2. Type in the following code:

package main

func main(){
    str.print("Hello, World!")
}
  1. Save and exit the file by pressing Ctrl + x and then Ctrl + s.

  2. Start cmd.exe in emacs by pressing Alt + x and then typing run-cmdexe emacs command syntax: M-x run-cmdexe

  3. Run the file by changing into the file direction and then typing the cx command:

cd %USERPROFILE%/AppData/Roaming/.emacs.d
cx hello-world.cx

macOS

TODO

Linux

TODO

⚠️ **GitHub.com Fallback** ⚠️