Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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.
;; 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