Created
January 9, 2012 15:32
-
-
Save sgr/1583427 to your computer and use it in GitHub Desktop.
Initialize functions for Windows-native Common Lisp through SLIME on Cygwin Emacs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun init-cygpath () | |
(when (eq system-type 'cygwin) | |
(require 'compile) | |
(require 'cl) | |
(labels ((dquote (s) (concat "\"" s "\"")) | |
(apply-cygpath (opt p) | |
(replace-regexp-in-string | |
"\n" "" | |
(shell-command-to-string | |
(mapconcat 'identity (list "cygpath" opt (dquote p)) " "))))) | |
(defun to-win-path (p) (apply-cygpath "-a -m" p)) | |
(defun to-cyg-path (p) (apply-cygpath "-u" p))) | |
(setq compilation-parse-errors-filename-function 'to-cyg-path))) | |
(defun init-popwin () | |
(add-to-list 'load-path "~/.emacs.d/popwin-el/") | |
(require 'popwin) | |
(setq display-buffer-function 'popwin:display-buffer)) | |
(defun init-ac () | |
(add-to-list 'load-path "~/.emacs.d/auto-complete") | |
(require 'auto-complete-config) | |
(add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete/ac-dict") | |
(ac-config-default)) | |
(defun init-cl () | |
(add-to-list 'load-path (expand-file-name "~/.emacs.d/slime/")) ; your SLIME directory | |
(setq slime-net-coding-system 'utf-8-unix) | |
(setq slime-lisp-implementations | |
`((clisp ("/usr/bin/clisp")) | |
(sbcl ("/usr/local/bin/sbcl") :init slime-init-command-win) | |
(ccl ("/usr/local/bin/ccl64") :init slime-init-command-win))) | |
(setq slime-default-lisp 'ccl) | |
(setq common-lisp-hyperspec-root | |
(expand-file-name "/usr/local/doc/HyperSpec-7-0/Hyperspec/") | |
common-lisp-hyperspec-symbol-table | |
(expand-file-name "/usr/local/doc/HyperSpec-7-0/Hyperspec/Data/Map_Sym.txt")) | |
(require 'slime) | |
(when (and (eq system-type 'cygwin) (or (eq slime-default-lisp 'ccl) | |
(eq slime-default-lisp 'sbcl))) | |
(defun slime-init-command-win (port-filename coding-system) | |
"Return a string to initialize for Windows-native Common Lisp." | |
(let ((loader (if (file-name-absolute-p slime-backend) | |
slime-backend | |
(concat slime-path slime-backend)))) | |
;; Return a single form to avoid problems with buffered input. | |
(format "%S\n\n" | |
`(progn | |
(load ,(to-win-path (expand-file-name loader)) | |
:verbose t) | |
(funcall (read-from-string "swank-loader:init")) | |
(funcall (read-from-string "swank:start-server") | |
,(to-win-path port-filename)))))) | |
(setq slime-to-lisp-filename-function #'to-win-path) | |
(defun slime-find-definitions-rpc (name) | |
"Redefined for file path translation." | |
(labels ((t (x) | |
`(,(first x) (,(caadr x) ,(to-cyg-path (cadr (cadr x)))) ,(caddr x) ,(cadddr x)))) | |
(mapcar (lambda (xref) | |
(destructuring-bind (dspec location) xref | |
(list dspec (t location)))) | |
(slime-eval `(swank:find-definitions-for-emacs ,name)))))) | |
(slime-setup '(slime-repl slime-fancy slime-banner)) | |
(add-hook 'lisp-mode-hook (lambda () | |
(slime-mode t) | |
(global-set-key "\C-cH" 'hyperspec-lookup))) | |
(add-hook 'slime-repl-mode-hook (lambda () (global-set-key "\C-cH" 'hyperspec-lookup))) | |
(unless (featurep 'popwin) (init-popwin)) | |
(when (featurep 'popwin) | |
(progn | |
(push '("*slime-apropos*") popwin:special-display-config) ; Apropos | |
(push '("*slime-macroexpansion*") popwin:special-display-config) ; Macroexpand | |
(push '("*slime-description*") popwin:special-display-config) ; Help | |
(push '("*slime-compilation*" :noselect t) popwin:special-display-config) ; Compilation | |
(push '("*slime-xref*") popwin:special-display-config) ; Cross-reference | |
(push '(sldb-mode :stick t) popwin:special-display-config) ; Debugger | |
(push '(slime-repl-mode) popwin:special-display-config) ; REPL | |
(push '(slime-connection-list-mode) popwin:special-display-config))) ; Connections | |
;; ac-slime | |
(unless (featurep 'auto-complete-config) (init-ac)) | |
(when (featurep 'auto-complete-config) | |
(add-to-list 'load-path "~/.emacs.d/ac-slime/") | |
(require 'ac-slime) | |
(add-hook 'lisp-mode-hook 'set-up-slime-ac) | |
(add-hook 'slime-mode-hook 'set-up-slime-ac) | |
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac) | |
(eval-after-load "auto-complete" | |
'(add-to-list 'ac-modes 'slime-repl-mode 'lisp-mode))) | |
;; Better indentation for Common Lisp | |
(when (require 'cl-indent-patches nil t) | |
(setq lisp-indent-function | |
(lambda (&rest args) | |
(apply (if (memq major-mode '(emacs-lisp-mode lisp-interaction-mode)) | |
'lisp-indent-function | |
'common-lisp-indent-function) | |
args))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SBCL_HOME_CYGWIN="/cygdrive/c/Program Files (x86)/Steel Bank Common Lisp/1.0.54" | |
SBCL_HOME=`cygpath -w "${SBCL_HOME_CYGWIN}"` | |
SBCL_CORE=`cygpath -w "${SBCL_HOME_CYGWIN}/sbcl.core"` | |
exec "${SBCL_HOME_CYGWIN}/sbcl" --core "${SBCL_CORE}" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment