LoginSignup
8
9

More than 5 years have passed since last update.

Common Lisp のリファレンスを使う

Last updated at Posted at 2015-04-03

経緯

  • Common Lisp のリファレンスが欲しいなと思って、本屋で『COMMON LISP 第2版』をみたけど、片手で持てない。
  • Common Lisp のリファレンスで使いやすいのを探したらHyperSpecが良さそうだった。
  • Emacs からオフラインファイルを w3m で検索することができるらしい。
  • やり方が書いてあるリンクはたくさんあるけど、HyperSpec 以外の導入についても混ぜて書かれていて初学者には敷居が高い

HyperSpec のインストール

環境
* Debian 7.8 (wheezy)
* GNU Emacs 24.4.1 (backports で入れた。Emacs23 でも問題はない。)
* w3m 0.5.3-8 (インストールしてなければ入れる)

apt で「hyperspec」パッケージを入れると、ダウンロードから展開までやってくれてる。

$ sudo apt-get install hyperspec

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  hyperspec
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/9,510 B of archives.
After this operation, 58.4 kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package hyperspec.
(Reading database ... 246363 files and directories currently installed.)
Unpacking hyperspec (from .../hyperspec_1.30+nmu2_all.deb) ...
Processing triggers for doc-base ...
Processing 1 added doc-base file...
Error in `/usr/share/doc-base/hyperspec', line 13: all `Format' sections are invalid.
Note: `install-docs --verbose --check file_name' may give more details about the above error.
Registering documents with scrollkeeper...
Setting up hyperspec (1.30+nmu2) ...
No or old version of the hyperspec found. Getting newer version
Downloading the hyperspec from the Internet
--2015-04-03 17:00:17--  ftp://ftp.lispworks.com/pub/software_tools/reference/HyperSpec-7-0.tar.gz
           => `/root/tmp/HyperSpec-7-0.tar.gz'
Resolving ftp.lispworks.com (ftp.lispworks.com)... 213.198.64.101
Connecting to ftp.lispworks.com (ftp.lispworks.com)|213.198.64.101|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /pub/software_tools/reference ... done.
==> SIZE HyperSpec-7-0.tar.gz ... 2032830
==> PASV ... done.    ==> RETR HyperSpec-7-0.tar.gz ... done.
Length: 2032830 (1.9M) (unauthoritative)

100%[=================================================================>] 2,032,830    101K/s   in 22s     

2015-04-03 17:00:43 (91.8 KB/s) - `/root/tmp/HyperSpec-7-0.tar.gz' saved [2032830]

エラーが出てるから scrollkeeper を追加でインストールして、再インストールした。
それでも同じエラーが出るので「/usr/share/doc-base/hyperspec」の
13行目が空行になっているのが原因かなと思う。まあ支障があれば対処する。

HyperSpec を Emacs から使う設定

  • 参考サイト:OSSはアルミニウムの翼で飛ぶ: gnupack + NTEmacs23 で SBCL/SLIME
  • Emacs の設定ファイル「~/.emacs.d/init.el」に以下を追加する。
  • キーバインドは好みで変更した。
    • デフォルト: C-c C-d h
    • 今回の設定: C-o
    • その他:「C-c H」 や「C-. H」が使われてる
  • HyperSpec がインストールされているパス「/usr/share/doc/hyperspec/」も設定に記述するのが正しいらしいけど、省略しても問題なかった。
;; w3m をロード
(when (require 'w3m nil t)
  "HyperSpec を w3m で読む"
  (defadvice common-lisp-hyperspec
      (around hyperspec-lookup-w3m () activate)
    (let* ((window-configuration (current-window-configuration))
           (browse-url-browser-function
            `(lambda (url new-window)
               (w3m-browse-url url nil)
               (let ((hs-map (copy-keymap w3m-mode-map)))
                 (define-key hs-map (kbd "q")
                   (lambda ()
                     (interactive)
                     (kill-buffer nil)
                     (set-window-configuration ,window-configuration)))
                 (user-local-map hs-map)))))
      ad-do-it)))

;; Hyperspec の検索開始キー
(global-set-key (kbd "C-o") 'hyperspec-lookup)

Emacs で init.el を編集後 M-x eval-buffer すれば準備が完了する。(Emacs を再起動してもいい)

編集中の lisp ファイルの関数の上にポインタをおいて「C-o」すれば、別のバッファでリファレンスが開く。
リファレンスのバッファは「q」で閉じる。

参考までに、browse-url で w3m が開いても気にならない人は、
この3行でもいい。

(require 'w3m)
(setq browse-url-browser-function 'w3m-browse-url)
(global-set-key (kbd "C-o") 'hyperspec-lookup)
8
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9