Hi.
I saw something strange about SLIME and tried googling about it. But couldn't find any clues.
Please allow me to post here.
I read "Let Over Lambda", a book about macros, and noticed function, named with "!", on a file couldn't be recognized nor compiled through using SLIME.
The codes are listed below, using some utilities from the book "On Lisp", written by Paul Graham.
;; *-SIMBOL-P-GENERATOR
;; (defmacro *-symbol-p-generator (str)
;; (let ((len (1+ (length str)))
;; (init-part (string-upcase str)))
;; `(defun ,(intern (concatenate 'string init-part "-SYMBOL-P")) (s)
;; (and (symbolp s)
;; (> (length (symbol-name s)) ,len)
;; (string= (symbol-name s)
;; ,init-part
;; :start1 0
;; :end1 ,len)))))
;; G-BANG-SYMBOL-PREDICATE
;; (*-symbol-p-generator "g!")
(defun g!-symbol-p (s)
(and (symbolp s)
(> (length (symbol-name s)) 2)
(string= (symbol-name s)
"G!"
:start1 0
:end1 2)))
;; DEFMACRO-WITH-G-BANG!
(defmacro defmacro/g! (name args &body body)
(let ((syms (remove-duplicates
(remove-if-not #'g!-symbol-p
(flatten body)))))
`(defmacro ,name ,args
(let ,(mapcar
(lambda (s)
`(,s (gensym ,(subseq
(symbol-name s)
2))))
syms)
,@body))))
;; ONCE-ONLY
(defmacro once-only ((&rest names) &body body)
(let ((gensyms (loop for n in names collect (gensym))))
`(let (,@(loop for g in gensyms collect `(,g (gensym))))
`(let (,,@(loop for g in gensyms for n in names collect ``(,,g ,,n)))
,(let (,@(loop for n in names for g in gensyms collect `(,n ,g)))
,@body)))))
;; O-BANG-SYMBOLS
;; (*-symbol-p-generator "o!")
(defun o!-symbol-p (s)
(and (symbolp s)
(> (length (symbol-name s)) 2)
(string= (symbol-name s)
"O!"
:start1 0
:end1 2)))
(defun o!-symbol-to-g!-symbol (s)
(symb "G!"
(subseq (symbol-name s) 2)))
;; DEFMACRO-BANG
(defmacro defmacro! (name args &body body)
(let ((os (remove-if-not #'o!-symbol-p args)))
(let ((gs (mapcar #'o!-symbol-to-g!-symbol os)))
`(defmacro/g! ,name ,args
`(let ,(mapcar #'list `(,,@gs) `(,,@os))
,(progn ,@body))))))
;; NIF
(defmacro! nif (o!expr pos zero neg)
`(cond ((plusp ,g!expr) ,pos)
((zerop ,g!expr) ,zero)
(t ,neg)))
;;; This is the end of file
; in: DEFMACRO! NIF
; (DEFMACRO! NIF (O!EXPR POS ZERO NEG)
; `(COND ((PLUSP ,G!EXPR) ,POS) ((ZEROP ,G!EXPR) ,ZERO) (T ,NEG)))
;
; caught ERROR:
; (during macroexpansion of (DEFMACRO! NIF ...))
; The function O!-SYMBOL-P is undefined.
;
; compilation unit finished
; caught 1 ERROR condition
; /home/cametan/lol.chapter_2.fasl written
; compilation finished in 0:00:00.091
;;=======================================================================
;; SLIME
;;=======================================================================
(setq inferior-lisp-program "/usr/bin/sbcl")
(add-to-load-path-recompile
(expand-file-name "~/slime"))
(add-hook 'lisp-mode-hook (lambda ()
(inferior-slime-mode t)
(global-set-key "\C-cH" 'hyperspec-lookup)
(push 'ac-source-slime ac-sources)
(auto-complete-mode)))
(require 'slime)
(eval-after-load "slime"
'(progn
(message "Slime configuration...")
(slime-setup '(slime-scratch
slime-editing-commands
slime-fancy
slime-repl
slime-asdf
anything-slime)))
)
;;
(setq slime-net-coding-system 'utf-8-unix
;; inferior-lisp-program "/usr/bin/sbcl"
lisp-indent-function 'common-lisp-indent-function
slime-complete-symbol*-fancy t
slime-complete-symbol-function 'slime-fuzzy-complete-symbol
slime-startup-animation t)
(slime-autodoc-mode)
;;