4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Elispに添付した外部プログラムの変数定義方法

4
Posted at

Elispに外部プログラムやファイルを添付したとき、そのパスを適切に設定する方法を紹介します。

外部プログラム foo.rb を 使用する foo.el を開発しており、foo.rb は foo.el と同じディレクトリに配置するとします。

foo
├── foo.el
└── foo.rb

foo.rbのパスの変数foo-rb-programを次のように定義すると、状況に合わせてパスが設定されます。

  • 開発中は eval-buffereval-last-sexp などによってfoo-rb-programを評価する。そのとき、自分のワーキングディレクトリからパスが設定される。
  • Elispを配布したときは、requireload で該当のファイルを読み出したとき、 そのロードされたファイルのパスからfoo-rb-programのパスが設定される。
(defvar foo-rb-program
  (let ((current (or load-file-name (buffer-file-name))))
    (expand-file-name "foo.rb" (file-name-directory current)))
  "Path to the `foo.rb'.")

robe.el の コードを読んでいる時に知りました。

4
4
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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?