日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

windows系统下scheme语言编程环境的搭建

發(fā)布時(shí)間:2023/12/18 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 windows系统下scheme语言编程环境的搭建 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

WIN下scheme語(yǔ)言編程環(huán)境的搭建

  • 概要
    • 下載并安裝emacs
    • 下載并安裝chezscheme
    • 配置
    • 使用
    • 尾聲

概要

在windows系統(tǒng)下(并不合適,阻力好大),使用chezscheme+emacs 搭建scheme語(yǔ)言的編程環(huán)境.

下載并安裝emacs

請(qǐng)自行搜索并下載安裝emacs(用來(lái)和語(yǔ)言實(shí)現(xiàn)交互的文本編輯器)

下載并安裝chezscheme

在Github是有windows系統(tǒng)可用的安裝包的,安裝chezscheme后記得將要用的.exe文件配置到win系統(tǒng)的系統(tǒng)環(huán)境變量path中.一般會(huì)有兩個(gè)版本的.exe文件,線程功能不同.
下文中 M 表示 Alt C 表示 Ctrl C-c 表示 Ctrl+c

配置

  • 修改emacs/site-lisp下的subdirs.el,添加以下幾行
  • `(defun fullpath-relative-to-call-location (file-path) (concat (file-name-directory (or load-file-name buffer-file-name)) file-path))

    (defalias 'fullpath 'fullpath-relative-to-call-location)

    (load (fullpath “…/CFG/init.el”) )`

    注意CFG會(huì)在subdirs.el的上一級(jí)路徑中,比如subdirs.el位于…\emacs-28.1\share\emacs\site-lisp,那么CFG就應(yīng)當(dāng)在…\emacs-28.1\share\emacs中

    參考博文 https://blog.csdn.net/weixin_33208391/article/details/116579680
    2. 在路徑 *…\emacs-24.3* 中新建 CFG 文件夾
    3. 在CFG文件家中建立init.el文件(可以新建文本文件,將后綴.txt改為.el,查看不了文件后綴的,自行搜索解決)
    4. 打開(kāi)init.el文件,在其中粘貼以下代碼:

    (message "Init init.el!") ;;-SET-ENVIRONMENT-------------------------------------------------------------------------------------------- (setq jinz-default-dir (concat default-directory "/../CFG")) (setq jinz-default-path (concat default-directory "/..")) (setq source-directory (concat jinz-default-path "/24.3")) (setq-default frame-title-format (concat "%b - e@" (system-name))) (setq user-init-file jinz-default-path) (setq user-emacs-directory jinz-default-dir) (setenv "HOME" jinz-default-dir) (setenv "PATH" jinz-default-path) ;; set the default file path (add-to-list 'load-path jinz-default-dir) ;; window-system 表示是否為x窗體,其判斷為: ;; (if window-system nil) ;; (if (not window-system) nil);; system-type 表示系統(tǒng)類型 (cond((string-equal system-type "windows-nt") ; Microsoft Windows(progn(message "Microsoft Windows") ))((string-equal system-type "darwin") ; Mac OS X(progn(message "Mac OS X")))((string-equal system-type "gnu/linux") ; linux(progn(message "Linux") )))
  • CFG文件夾中新建 .emacs 文件(emacs配置文件),打開(kāi)后在其中粘貼如下代碼:
  • (custom-set-variables;; custom-set-variables was added by Custom.;; If you edit it by hand, you could mess it up, so be careful.;; Your init file should contain only one such instance.;; If there is more than one, they won't work right.'(case-fold-search nil)'(column-number-mode t)'(cua-mode t nil (cua-base))'(current-language-environment "utf-8")'(safe-local-variable-values (quote ((package . net\.aserve\.client) (package . net\.aserve) (package . net\.html\.generator))))'(show-paren-mode t)'(text-mode-hook (quote (text-mode-hook-identify)))'(uniquify-buffer-name-style (quote forward) nil (uniquify))) (custom-set-faces;; custom-set-faces was added by Custom.;; If you edit it by hand, you could mess it up, so be careful.;; Your init file should contain only one such instance.;; If there is more than one, they won't work right.) ;============================================ (set-language-environment "utf-8") ;注意,下行不能u8,否則打開(kāi)漢語(yǔ)名文件不顯示內(nèi)容 (setq file-name-coding-system 'gb18030) (set-buffer-file-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (set-next-selection-coding-system 'utf-8) (set-default-coding-systems 'utf-8) (set-clipboard-coding-system 'utf-8) (setq ansi-color-for-comint-mode t) (modify-coding-system-alist 'process "*" 'utf-8) (setq-default pathname-coding-system 'utf-8) (prefer-coding-system 'utf-8) (setq default-process-coding-system '(utf-8 . utf-8)) (setq locale-coding-system 'utf-8) (setq default-buffer-file-coding-system 'utf-8) (setq slime-net-coding-system 'utf-8-unix) ;;=============================== ;設(shè)置行號(hào) (global-linum-mode 1) (setq linum-format "%d") (set-cursor-color "white") (set-mouse-color "blue") (set-foreground-color "green") (set-background-color "black") (set-border-color "lightgreen") (set-face-foreground 'highlight "red") (set-face-background 'highlight "lightblue") (set-face-foreground 'region "darkcyan") (set-face-background 'region "lightblue") (set-face-foreground 'secondary-selection "skyblue") (set-face-background 'secondary-selection "darkblue") ;將幫助命令綁定到 F1鍵 (global-set-key [f1] 'help-command) (global-set-key "\C-c\M-q" 'slime-reindent-defun);;;======================================注意可移動(dòng)模式,不然每次都要改 ;;;關(guān)于scheme需要的包 ;注意有時(shí)路徑不對(duì)依舊可以啟動(dòng)scheme-mode ;下行需使用scheme.exe所在的路徑 (add-to-list 'exec-path "C:\\Program Files\\Chez Scheme 9.5\\bin\\ta6nt") (add-to-list 'load-path "C:\\Program Files\\Chez Scheme 9.5\\bin\\ta6nt");paredit是一個(gè)插件,M+x paredit-mode啟動(dòng), (autoload 'paredit-mode "paredit""Minor mode for pseudo-structurally editing Lisp code."t);; scheme配置 (require 'cmuscheme) ;ALT+x scheme-mode 即可對(duì)一個(gè)buffer開(kāi)啟scheme模式 (setq scheme-program-name "scheme");; bypass the interactive question and start the default interpreter (defun scheme-proc ()"Return the current Scheme process, starting one if necessary."(unless (and scheme-buffer(get-buffer scheme-buffer)(comint-check-proc scheme-buffer))(save-window-excursion(run-scheme scheme-program-name)))(or (scheme-get-process)(error "No current process. See variable `scheme-buffer'")))(defun scheme-split-window ()(cond((= 1 (count-windows))(delete-other-windows)(split-window-vertically (floor (* 0.68 (window-height))))(other-window 1)(switch-to-buffer "*scheme*")(other-window 1))((not (find "*scheme*"(mapcar (lambda (w) (buffer-name (window-buffer w)))(window-list)):test 'equal))(other-window 1)(switch-to-buffer "*scheme*")(other-window -1))))(defun scheme-send-last-sexp-split-window ()(interactive)(scheme-split-window)(scheme-send-last-sexp))(defun scheme-send-definition-split-window ()(interactive)(scheme-split-window)(scheme-send-definition))(add-hook 'scheme-mode-hook(lambda ()(paredit-mode 1)(define-key scheme-mode-map (kbd "<f5>") 'scheme-send-last-sexp-split-window)(define-key scheme-mode-map (kbd "<f6>") 'scheme-send-definition-split-window)))

    5.geiser配置,在.emacs文件中加入如下代碼(記得將geiser解壓到CFG/.emacs.d/路徑下,沒(méi)有的話,請(qǐng)去github下載geiser):

    (load-file "~/.emacs.d/geiser-0.9/elisp/geiser.el") ; (setq geiser-active-implementations '(chez))

    geiser可以幫助emacs和chezscheme更好地交流,解決很多奇怪的問(wèn)題, geiser是有使用手冊(cè)的, 不長(zhǎng), C-c C-z 估計(jì)是最常用的:)
    6.scheme代碼自動(dòng)索引和補(bǔ)全的配置,需要插件popup , fuzzy , pos-tip, auto-complete以及ac-geiser,這些都需要去github下載,解壓到CFG/.emacs.d/路徑下配置到emacs能找到就OK了

    ;; ==============================================代碼自動(dòng)補(bǔ)全============================== ;; ac的前件 ;(setq expls '(popup fuzzy)) ;(map 'require expls) (add-to-list 'load-path "~/.emacs.d") (require 'popup) (require 'fuzzy)(add-to-list 'load-path "~/.emacs.d/auto-complete") (require 'auto-complete) (require 'auto-complete-config)(global-auto-complete-mode t) ;全局自動(dòng)補(bǔ)全;; 使用自帶字典 (add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete/dict") (ac-config-default);; 輸入2個(gè)字符才開(kāi)始補(bǔ)全 (setq ac-auto-start 2);; 0輸入即開(kāi)始補(bǔ)全的快捷鍵 (global-set-key "\M-/" 'auto-complete) ;; 使用增強(qiáng)的pos-tip (require 'pos-tip) (setq ac-quick-help-prefer-pos-tip t);;使用quick-help (setq ac-use-quick-help t) (setq ac-quick-help-delay 0.5);; Show 0.8 second later (setq ac-auto-show-menu 0.8);;設(shè)置tab的使用模式--?? ;;(setq ac-dwim t);;?使用fuzzy的模糊匹配 (setq ac-fuzzy-enable t);;菜單參數(shù) (setq ac-menu-height 12) (set-face-background 'ac-candidate-face "lightgray") (set-face-underline 'ac-candidate-face "darkgray") (set-face-background 'ac-selection-face "steelblue") ;; =========================================== ac-geiser配置======================== (add-to-list 'load-path "~/.emacs.d/ac-geiser") (require 'ac-geiser) (add-hook 'geiser-mode-hook 'ac-geiser-setup) (add-hook 'geiser-repl-mode-hook 'ac-geiser-setup) (eval-after-load "auto-complete"'(add-to-list 'ac-modes 'geiser-repl-mode))
  • CFG文件夾中放入paredit.el文件(一個(gè)編輯器插件,用來(lái)高效處理lisp代碼,提供括號(hào)自動(dòng)匹配等功能)paredit.el應(yīng)該也是可以下載到的.
  • 使用

  • emacs運(yùn)行后,按C-c C-z, chezscheme就啟動(dòng)了
  • 或者新建.ss文件,拖動(dòng)到emacs窗口,再C-c C-z
  • 接下來(lái)愉快地彈奏代碼就OK.
  • 尾聲

    目前就這樣了,還請(qǐng)各位多多指教.

    總結(jié)

    以上是生活随笔為你收集整理的windows系统下scheme语言编程环境的搭建的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

    如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。