サイトマップ 更新履歴 ニュース Elispセクション 利用手引

SlimeMode

SLIME is the Superior Lisp Interaction Mode, Enhanced.

See also CLiki:SLIME and its project page at http://common-lisp.net/project/slime/.

It is based on EmacsLisp magic by EricMarsden (who called it SLIM) to highlight CLiki:CMUCL error/warning/compiler note output directly in the Lisp editing buffer. LukeGorrie and HelmutEller? added control of the Lisp process similar to that found in Distel, CLiki:CMUCL XREF support, good debugger interaction, and many other Lisp interaction enhancements. Most people consider it superior to ILispMode. It has been ported to CLiki:OpenMCL, CLiki:SBCL, CLiki:ACL, CLiki:LispWorks, though support varies a bit between implementations (with CLiki:CMUCL and CLiki:SBCL being the best).

Marco Baringer made a video for this mode; Peter Christensen wrote an annotated reference guide for the tutorial video.

Fontify *SLIME Description* buffer for SBCL

    (defun slime-description-fontify ()
      "Fontify sections of SLIME Description."
      (with-current-buffer "*SLIME Description*"
        (highlight-regexp
         (concat "^Function:\\|"
                 "^Macro-function:\\|"
                 "^Its associated name.+?) is\\|"
                 "^The .+'s arguments are:\\|"
                 "^Function documentation:$\\|"
                 "^Its.+\\(is\\|are\\):\\|"
                 "^On.+it was compiled from:$")
         'hi-green-b)))
    (defadvice slime-show-description (after slime-description-fontify activate)
      "Fontify sections of SLIME Description."
      (slime-description-fontify))

It is easy to adjust to other CL implementations. – rubikitch

Improve usability of slime-apropos: slime-apropos-minor-mode

    (defvar slime-apropos-anchor-regexp "^[^ ]")
    (defun slime-apropos-next-anchor ()
      (interactive)
      (let ((pt (point)))
        (forward-line 1)
        (if (re-search-forward slime-apropos-anchor-regexp nil t)
            (goto-char (match-beginning 0))
          (goto-char pt)
          (error "anchor not found"))))
    (defun slime-apropos-prev-anchor ()
      (interactive)
      (let ((p (point)))
        (if (re-search-backward slime-apropos-anchor-regexp nil t)
            (goto-char (match-beginning 0))
          (goto-char p)
          (error "anchor not found"))))
    (defvar slime-apropos-minor-mode-map (make-sparse-keymap))
    (define-key slime-apropos-minor-mode-map "\C-m" 'slime-describe-symbol)
    (define-key slime-apropos-minor-mode-map "l" 'slime-describe-symbol)
    (define-key slime-apropos-minor-mode-map "j" 'slime-apropos-next-anchor)
    (define-key slime-apropos-minor-mode-map "k" 'slime-apropos-prev-anchor)
    (define-minor-mode slime-apropos-minor-mode "")
    (defadvice slime-show-apropos (after slime-apropos-minor-mode activate)
      ""
      (when (get-buffer "*SLIME Apropos*")
        (with-current-buffer "*SLIME Apropos*" (slime-apropos-minor-mode 1))))

rubikitch

UsageMemo with SLIME

UsageMemo enables you to write annotation in Help and SLIME Description. TAKE A NOTE IN SLIME Description! – rubikitch

Fix end-of-defun's behavior in repl mode

After (require ‘slime), eval follow form. (defun slime-repl-mode-end-of-defun () (forward-sexp) t)

Remove SLIME's keybinding on C-c x

Emacs’s elisp documentaiton states that “Sequences consisting of ‘C-c’ and a letter (either upper or lower case) are reserved for users; they are the only sequences reserved for users, so do not block them.” Unfortunately, slime binds ‘C-c x’ to slime-export-symbol-at-point, shadowing any keybindings the user might have established via global-set-key.

To remove slime’s keybinding, and expose your original keybinding, add the following form after your call to (require ‘slime) or (require ‘slime-autoloads)

  (add-hook 'slime-mode-hook 
            (defun slime-sanitize-bindings ()
              "Removes SLIME's keybinding on C-c x"
              (cond ((boundp 'slime-mode-map)
                     (define-key slime-mode-map (kbd "C-c x") nil)
                     (message "slime keybinding on C-c x has been sanitized"))
                    ('t (message "slime keybindings not sanitized")))))

Integrate yas/expend to TAB key

slime-indent-and-complete-symbol is a good function to bind to TAB key, but if you use Yasnippet, you can let TAB do indent, complete and yas/expand.

    (defun slime-tab ()
      "slime-mode tab dwim, either indent, complete symbol or yas/expand"
      (interactive)
      (let ((r (slime-indent-and-complete-symbol)))
        (unless r
          (yas/expand))))
    (defun my-slime-mode-hook ()
      (interactive)
      (define-key slime-mode-map (kbd "<tab>")
        'slime-tab)
      )
    (add-hook 'slime-mode-hook 'my-slime-mode-hook)

CategoryModes CategoryProgramming