Skip to content

Instantly share code, notes, and snippets.

@yoshinari-nomura
Created September 27, 2011 06:30
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save yoshinari-nomura/1244467 to your computer and use it in GitHub Desktop.
Small aliases to get along with Emacs buffer.
## Invoke the ``dired'' of current working directory in Emacs buffer.
function dired () {
emacsclient -e "(dired \"$PWD\")"
}
## Chdir to the ``default-directory'' of currently opened in Emacs buffer.
function cde () {
EMACS_CWD=`emacsclient -e "
(expand-file-name
(with-current-buffer
(nth 1
(assoc 'buffer-list
(nth 1 (nth 1 (current-frame-configuration)))))
default-directory))" | sed 's/^"\(.*\)"$/\1/'`
echo "chdir to $EMACS_CWD"
cd "$EMACS_CWD"
}
@Dubhead
Copy link

Dubhead commented Sep 27, 2011

dired() の方は
emacsclient -e "(dired "${1:a}")"
にしてはどうでしょう。
「dired」に加えて「dired ..」や「dired /tmp」も出来るようになります。

@yoshinari-nomura
Copy link
Author

Dubhead さん:

dired() の方は
emacsclient -e "(dired "${1:a}")"
にしてはどうでしょう。

なるほど.ありがとうございます.でも,これって,引数なしの場合になぜうまく動いてるんだろ.

@masutaka
Copy link

ありがとうございます!
elscreen 使っていると、(current-frame-configuration) から buffer-list を取得できないので、
fork して修正してみました☆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment