Install Emacs and set up racket environment

I am reading the book sicp recently , and the code in the book is schemeimplemented using. When I read it before, I used Dr.Racketit to complete the writing exercise, but I think it is better to do it in one step and use the emacs+lispinterpreter to do it faster.

install emacs

Just click on the official tutorial and click me to view it. The above explanation is very clear. Basically, the installation methods of different systems are similar. After downloading, click to run, it is still very simple.

Install the lisp interpreter

There are countless versions of lisp. I use it here Racket, because I have it on my computer before, Dr.Racketso I don't need to download it. If you don't have it, you can click the Racket download address and select the version of the appropriate system to download. Of course, you can also choose other The implementation version of the lisp dialect, such as the Petite Chez Scheme download address . After downloading, unzip it.

After downloading, you can get some programs like this

Racket Basic Program

Then set the folder path where the above interpreter is located to the system path (windows=environment variable, mac/linux= $path), and then click on the terminal racket --versionto check whether the setting is successful. If the following message appears, you are successful.

Check if Racket is successfully setup

Install some necessary and effective plugins

We need to install a few simple plugins to help us write and run code efficiently.

Set plugin source

Similar to linux installation software, here we set MELPAthe installation source, so that we can install the code with one click, which is very convenient.
In view of the slow speed of foreign access, we use domestic mirror sources here, and we would like to thank those who have been maintaining free software, otherwise the setting and configuration of these tools would be so easy and convenient :)

emacsAll the configuration in ~/.emacsthis file is in this file. For Windows, it is in the personal directory folder of the C drive. We can make some custom configurations for emacs by editing this file. Open the .emacs file and add the following configuration to the end of the file to set up our plugin installation source.

 ;; melpa 安装源
(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://elpa.emacs-china.org/melpa/")
             t)
(package-initialize)

This makes it easy to install plugins.

Install Racket-mode

Racket-modeIt's very easy to use, execute the code, highlight, prompt, anyway, I think everything is OK, so I'll install it below.
Use the following command M-x package-install <ret> racket-mode, M represents altthe meaning of the key combination, which retrepresents the carriage return, so the command is actually

  • alt+xOpen command mode
  • Enter package-install(you can use the space bar/tab to prompt), press Enter
  • Then enter the name of the plugin to be installed racket-mode, press Enter to confirm, and wait for the installation to complete.

Plugin installation

Well, it's simple.

After the installation is complete, .emacsadd the configuration of the following code to the configuration file configuration file

;;racket配置,设置解释器,自动补全,代码执行等
(require 'racket-mode)
(setq racket-racket-program "racket")
(setq racket-raco-program "raco")
(add-hook 'racket-mode-hook
          (lambda ()
            (define-key racket-mode-map (kbd "C-x C-j") 'racket-run)))
(setq tab-always-indent 'complete) 

Install ParEdit

ParEditIt is a plugin that allows you to edit lisp semi-structured, such as automatic completion of parentheses, transfer of s-expressions, extraction, etc. It is still very convenient.
You can also use M-x package-install <ret> paredit-modeto install.

The specific usage method is not the focus of this article, you can refer to the following articles

Hello World

After all settings are completed, we create a new file ( ctrl+x 回车 i 回车 输入文件名) and enter the following code

#! /usr/bin/env racket

#lang racket

(displayln "Hello World!")

Then use to F5execute the S-expression, and successfully print out Hello World

Hello World

At this point, the installation Emacsand setting racketof the environment are completed.

References

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325459982&siteId=291194637