在windows系统下(并不合适,阻力好大),使用chezscheme+emacs 搭建scheme语言的编程环境.
请自行搜索并下载安装emacs(用来和语言实现交互的文本编辑器)
在Github是有windows系统可用的安装包的,安装chezscheme后记得将要用的.exe文件配置到win系统的系统环境变量path中.一般会有两个版本的.exe文件,线程功能不同.
下文中 M 表示 Alt C 表示 Ctrl C-c 表示 Ctrl+c
`(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会在subdirs.el的上一级路径中,比如subdirs.el位于…\emacs-28.1\share\emacs\site-lisp,那么CFG就应当在…\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. 打开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 表示系统类型
(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") ))
)
(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,否则打开汉语名文件不显示内容
(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)
;;===============================
;设置行号
(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)
;;;======================================注意可移动模式,不然每次都要改
;;;关于scheme需要的包
;注意有时路径不对依旧可以启动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是一个插件,M+x paredit-mode启动,
(autoload 'paredit-mode "paredit"
"Minor mode for pseudo-structurally editing Lisp code."
t)
;; scheme配置
(require 'cmuscheme)
;ALT+x scheme-mode 即可对一个buffer开启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/路径下,没有的话,请去github下载geiser):
(load-file "~/.emacs.d/geiser-0.9/elisp/geiser.el") ;
(setq geiser-active-implementations '(chez))
geiser可以帮助emacs和chezscheme更好地交流,解决很多奇怪的问题, geiser是有使用手册的, 不长, C-c C-z 估计是最常用的:)
6.scheme代码自动索引和补全的配置,需要插件popup , fuzzy , pos-tip, auto-complete以及ac-geiser,这些都需要去github下载,解压到CFG/.emacs.d/路径下配置到emacs能找到就OK了
;; ==============================================代码自动补全==============================
;; 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) ;全局自动补全
;; 使用自带字典
(add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete/dict")
(ac-config-default)
;; 输入2个字符才开始补全
(setq ac-auto-start 2)
;; 0输入即开始补全的快捷键
(global-set-key "\M-/" 'auto-complete)
;; 使用增强的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)
;;设置tab的使用模式--??
;;(setq ac-dwim t)
;;ʹ使用fuzzy的模糊匹配
(setq ac-fuzzy-enable t)
;;菜单参数
(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))
目前就这样了,还请各位多多指教.