LoginSignup
7
4

More than 5 years have passed since last update.

Melpa+Cask環境で個人用レシピを使いたい

Last updated at Posted at 2018-01-03

はじめに

Emacsのパッケージを作ったら MELPA に登録して世界中に公開するのが良いですね.ただそうは言っても,とりあえず適当に作って Githubに登録してしまえば,MELPAには登録せずに事足りてしまうのも現実です.

そこで今回は,ローカルにMelpaリポジトリを作ってレシピを登録する方法をまとめておきます.

参考)https://github.com/melpa/melpa/wiki/Custom-Melpa-Archive

手順

  • 任意の場所に melpa をクローンする
cd ~/hoge
git clone --depth 1 https://github.com/milkypostman/melpa.git myrepo
  • 新しいブランチを準備して既存レシピを全削除
cd myrepo
git checkout -b myrepo
git rm recipes/*
git commit -am 'removed all recipes'
mkdir recipes
  • recipes 以下に,個人用レシピを追加

お好きなように( ' -')b

  • make する
make packages packages/archive-contents

$which emacsで古いEmacsが帰る場合は,Makefile内のEMACS_COMMANDの値に注意.

  • Cask ファイルに新しい source を追加
Cask
(source "myrepo" "~/hoge/myrepo/packages")

なお,Caskファイルには,登録した個人用レシピを depends-on で通常通りに指定しておきます.
Screen Shot 2018-01-04 at 12.33.49 AM.png

  • M-x list-packages で自分のレシピのパッケージを選んでインストール

Screen Shot 2018-01-04 at 12.30.33 AM.png

おわりに

実際のところ,こんなことをせずに Caskファイルの depends-on のオプション指定を使えばいい話なのです.

(depends-on "hoge" :git "https://github.com/hoge/hoge.git")

ただ私の環境だと,色々と手を入れているせいか,上記のオプション指定ではエラーが出るようになったため,今回の回避策を取ったというオチでした.

(留意点)Caskのエラーは,cask コマンドがエラーを出し始めたらの方法で解決する場合もあります.

おまけ

作ったリポジトリをWebに公開して,Caskファイルの source をグローバルに移せます.変更点は以下.

(前提)https://hogehoge.org/melpa で公開したい.

  • (変更点1)html/index.html のL.45らへん
html/index.html
   <footer class="container">
     <small>
-      <a href="https://github.com/melpa/melpa/blob/master/html/js/melpa.js">Source code for this page &rarr;</a>
+      <a href="https://github.com/xx/melpa/blob/myrepo/html/js/melpa.js">Source code for this page &rarr;</a>
       <br/>
       <a href="jslicense.html" data-jslicense="1">JavaScript license information</a>
     </small>
   </footer>
  • (変更点2)html/js/melpa.js のL.102,L.148,L.488らへん
html/js/melpa.js
   melpa.packageList = m.sync([
-    m.request({method: 'GET', url: "/recipes.json"}),
-    m.request({method: 'GET', url: "/archive.json"}),
-    m.request({method: 'GET', url: "/download_counts.json"})
+    m.request({method: 'GET', url: "/melpa/recipes.json"}),
+    m.request({method: 'GET', url: "/melpa/archive.json"}),
+    m.request({method: 'GET', url: "/melpa/download_counts.json"})
html/js/melpa.js
         fetcher: recipe.fetcher,
-        recipeURL: "https://github.com/melpa/melpa/blob/master/recipes/" + name,
+        recipeURL: "https://github.com/xx/melpa/blob/myrepo/recipes/" + name,
         packageURL: "packages/" + name + "-" + version + "." + (built.type == "single" ? "el" : "tar"),
html/js/melpa.js
     this.running = function() { return !this.completed(); }.bind(this);

-    m.request({method: 'GET', url: "/build-status.json", background: true})
+    m.request({method: 'GET', url: "/melpa/build-status.json", background: true})
       .then(function(status){
  • データベースを更新してサーバに同期
cd ~/hoge
make -j1
rsync -avh ./html/ myserver:/path/to/htsdocs/melpa/
rsync -avh ./packages/ myserver:/path/to/htsdocs/packages/
  • Caskファイルの source を書き換える
Cask
;; (source "myrepo" "~/devel/git/melpa/packages")
(source "myrepo" "https://hogehoge/melpa/packages/")
7
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
7
4