Skip to content

Instantly share code, notes, and snippets.

@ericbmerritt
Created March 9, 2012 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericbmerritt/2006851 to your computer and use it in GitHub Desktop.
Save ericbmerritt/2006851 to your computer and use it in GitHub Desktop.
elisp for opening emacs in emacs
;;;
;;; Eshell stuff
;;;
(when (fboundp 'eshell)
;; This and rmb are my two vices. rmb is defined as an eshell alias.
(defalias 'eshell/lo #'eshell/exit)
(defalias 'eshell/logout #'save-buffers-kill-emacs)
;; I'm obsessive/compulsive with clear.
(defun eshell/clear ()
"\"Clear the screen,\" as it were."
(recenter 0))
(defun eshell/emacs (&rest args)
"Open a file in emacs. Some habits die hard."
(if (null args)
;; If I just ran "emacs", I probably expect to be launching
;; Emacs, which is rather silly since I'm already in Emacs.
;; So just pretend to do what I ask.
(bury-buffer)
;; We have to expand the file names or else naming a directory in an
;; argument causes later arguments to be looked for in that directory,
;; not the starting directory
(mapc #'find-file
(mapcar #'expand-file-name
(eshell-flatten-list (reverse args))))))
(defalias 'eshell/emacsclient #'eshell/emacs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment