Skip to content

Instantly share code, notes, and snippets.

@kiwanami
Forked from masutaka/.zaliases
Created September 28, 2011 06:07
Show Gist options
  • Save kiwanami/1247111 to your computer and use it in GitHub Desktop.
Save kiwanami/1247111 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 \"${1:a}\")"
}
## Chdir to the ``default-directory'' of currently opened in Emacs buffer.
function cde () {
EMACS_CWD=`emacsclient -e "
(expand-file-name
(with-current-buffer (e2wm:current-buffer) default-directory))" | sed 's/^"\(.*\)"$/\1/'`
echo "chdir to $EMACS_CWD"
cd "$EMACS_CWD"
}
(defun e2wm:current-buffer ()
(cond
((e2wm:managed-p)
(e2wm:history-get-main-buffer))
((featurep 'elscreen)
(let* ((frame-confs (elscreen-get-frame-confs (selected-frame)))
(num (nth 1 (assoc 'screen-history frame-confs)))
(cur-window-conf (cadr (assoc num (assoc 'screen-property frame-confs))))
(marker (nth 2 cur-window-conf)))
(marker-buffer marker)))
(t
(nth 1
(assoc 'buffer-list
(nth 1 (nth 1 (current-frame-configuration))))))))
@kiwanami
Copy link
Author

さらに e2wm のフレームでもOKの版。

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