LoginSignup
2

More than 5 years have passed since last update.

cdeとelscreen-separate-buffer-listの相性が悪い

Last updated at Posted at 2016-01-15

elscreen-separate-buffer-list便利ですよね。余計なバッファがリストに現れないのは大変見通しが良くなるものです。

そしてcdeも大変便利です。シェルでEmacsのカレントバッファにcdすることってよくやる操作ですからね。

ですがelscreen-separate-buffer-listをインストールしてcdeを使おうとすると、cdeが謎のエラーメッセージを吐いてcdしてくれなくなります。

cdeの方がどちらかと言うと重要だったので elscreen-separate-buffer-list を外してしばらく使っていました。が、どうにも不便なので一念発起して調べてみました。

というかなおす箇所はcdeを定義している.zshrcの中の一箇所で、s/cadr/assoc 'window-configuration/すりゃいいです。

ついでにこれだけのまとまったコードをzsh側に置いておくのもなんか変な気がするのでinit.el側に移します。こんなふうになります。

init.el
(defun return-current-working-directory-to-shell ()
  (expand-file-name
   (with-current-buffer
       (if (featurep 'elscreen)
           (let* ((frame-confs (elscreen-get-frame-confs (selected-frame)))
                  (num (nth 1 (assoc 'screen-history frame-confs)))
                  (cur-window-conf
                   (assoc 'window-configuration
                          (assoc num (assoc 'screen-property frame-confs))))
                  (marker (nth 2 cur-window-conf)))
             (marker-buffer marker))
         (nth 1
              (assoc 'buffer-list
                     (nth 1 (nth 1 (current-frame-configuration))))))
     default-directory)))
.zshrc
function cde () {
        EMACS_CWD=`emacsclient -e "(return-current-working-directory-to-shell)" | sed 's/^"\(.*\)"$/\1/'`
        echo "chdir to $EMACS_CWD"
        cd "$EMACS_CWD"
}

なんかうまい関数名が思いつかなかったので適当になってしまいました。誰かかっこいい関数名を…

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
2