Spacemacsに乗り換えてみた(3)レイヤー編


はじめに

  • Spacemacsレイヤー機能を使ってみる
  • 「レイヤー編」とはタイトル詐欺かもしれない・・・自作レイヤーの作り方ではなく、既存のレイヤーの設定について書いた
  • まずはじめにTwitterを使ってみる

レイヤーを追加する方法

  • Layer Listから使いたいレイヤーを選択肢、そのドキュメントを読む
  • 基本的にはレイヤー名を~/.spacemacsdotspacemacs-configuration-layersに追加し、必要な設定はdotspacemacs/user-configに記述すればOK(なはず)
dotspacemacs/layers()
(defun dotspacemacs/layers ()
  "Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
  (setq-default
   dotspacemacs-distribution 'spacemacs
   dotspacemacs-enable-lazy-installation 'unused
   dotspacemacs-ask-for-lazy-installation t
   dotspacemacs-configuration-layer-path '()
   dotspacemacs-configuration-layers
   '(
     ;; ----------------------------------------------------------------
     ;; Example of useful layers you may want to use right away.
     ;; Uncomment some layer names and press <SPC f e R> (Vim style) or
     ;; <M-m f e R> (Emacs style) to install them.
     ;; ----------------------------------------------------------------
     spell-checking
     syntax-checking
     better-defaults
     ibuffer
     smex
     auto-completion
     ivy
     c-c++
     csv
     emacs-lisp
     html
     ipython-notebook
     python
     shell-scripts
     yaml
     git
     version-control
     markdown
     chrome
     pandoc
     twitter
     (latex :variables
            latex-build-command "ptex2pdf -l"
            )
     (mu4e :variables
           mu4e-installation-path "/usr/local/Cellar/mu/1.0/share/emacs/site-lisp/mu/mu4e/")
     ;; org
     ;; (shell :variables
     ;;        shell-default-height 30
     ;;        shell-default-position 'bottom)
     )
   dotspacemacs-additional-packages '()
   dotspacemacs-frozen-packages '()
   dotspacemacs-excluded-packages '()
   dotspacemacs-install-packages 'used-only))

Twitterの設定

twitter
  twitter
  • レイヤー名twitterを追記し、SPC f e Rdotspacemacsを再読込みする
  • SPC a tでTwitter(twit)を起動する
キー コマンド 動作
SPC a t twit twitを起動
V twittering-visit-timeline タイムラインの切り替え(候補が表示されるので選択すればOK)
v twittering-other-user-timeline 選択しているユーザのタイムラインを表示
g twittering-current-timeline 現在のタイムラインを更新
q twittering-kill-buffer 現在のバッファを消去
C-c C-s 新規ツイートを作成(C-c C-cで投稿/C-c C-kでキャンセル)
  • twitのドキュメントを読むと、新規ツイートの作成はuでもできるはずだけど、Spacemacsではupdateに取られているのでできなくなっている(なのでC-c C-sを使うしかない)

twit起動時の詳細

  • SPC a ttwitを起動する
  • 特に何も設定していない場合、ミニバッファにOpen authorization URL with browser? (using 'browse-url') (y or n)と表示されるのでyと答える
  • ブラウザが起動するのでAuthorize appをクリックし、表示されるPINコードをコピー
  • SpacemacsのミニバッファにInput PIN code:と表示されているので、上記のコードをペースト
  • 認証に成功するとSpacemacsTwitterのタイムラインが表示される
  • 操作に困ったときは?を押して、キーバインドを表示すればOK

タイムラインの切り替え

  • Vで表示するタイムラインを切り替えられるが、Twitter APIが古くて使えないものもあった
コマンド 動作
:direct_message_events DM一覧
:direct_messages
:direct_message_sent
:favorites ♥したツイート一覧
:friends フォローしてる人のツイート一覧
:home
:mentions 自分がメンションされたツイート一覧
:public not supported in the Twitter REST API v1.1
:replies リプ一覧(:mentionsと一緒?)
:retweeted_by_me not supported in the Twitter REST API v1.1
:retweeted_by_user/USERNAME not supported in the Twitter REST API v1.1
:retweeted_to_me not supported in the Twitter REST API v1.1
:retweeted_to_user/USERNAME not supported in the Twitter REST API v1.1
:retweets_of_me RTされた自分のツイート一覧?

パッケージを追加する方法

  • 一時的にパッケージを追加するにはM-x package-list-packageなどを使ってインストールする
  • しかし、この場合、Emacsを再起動した時にOrphan packageだと判断され、アンインストールされてしまう
  • ずっと使いたいパッケージは dotspacemacs-additional-packagesの中に追記する
;; List of additional packages that will be installed without being
;; wrapped in a layer. If you need some configuration for these
;; packages, then consider creating a layer. You can also put the
;; configuration in `dotspacemacs/user-config'.
dotspacemacs-additional-packages
   '(
     ez-query-replace
     visual-regexp
     )
  • とりあえず文字列を置換するコマンドの便利パッケージを追加した
  • ところで、置換のキーバインドはデフォルトでM-%でなのだけれど、入力しにくいのでEsc -> %で代用していた。SpacemacsではEscを入力した時点でモードが変更されるため、この代用キーバインドが使えなくなってしまい、ちょっと不便

目次

  1. Spacemacsに乗り換えてみた(1)導入編
  2. Spacemacsに乗り換えてみた(2)キーバインド編
  3. Spacemacsに乗り換えてみた(3)レイヤー編
  4. Spacemacsに乗り換えてみた(4)ウェブ制作編
  5. Spacemacsに乗り換えてみた(5)メーラ編
  6. Spacemacsに乗り換えてみた(6)LaTeX編(予定)