Created
September 23, 2012 03:45
-
-
Save doitian/3768772 to your computer and use it in GitHub Desktop.
Open file in dedicated Emacs frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
for file; do | |
emacsclient -e "(find-file-in-dedicated-frame \"${file/\"/\\\"}\" \"Finder\" 'focus)" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun get-frame-create (frame-or-name) | |
"Return the frame specified by FRAME-OR-NAME, creating a new one if needed. | |
If FRAME-OR-NAME is a string and a live frame with that name exists, | |
return that frame. If no such frame exists, create a new frame with | |
that name and return it. | |
If FRAME-OR-NAME is a frame instead of a string, return it as given, | |
even if it is dead. | |
" | |
(if (framep frame-or-name) | |
frame-or-name | |
(or | |
(cdr-safe (assoc frame-or-name (mapcar | |
(lambda (frame) | |
(cons (frame-parameter frame 'name) frame)) | |
(frame-list)))) | |
(let ((frame (make-frame))) | |
(set-frame-parameter frame 'name frame-or-name) | |
frame)))) | |
(defun find-file-in-dedicated-frame (file frame-or-name &optional focus) | |
"Find FILE in dedicated frame specified by FRAME-OR-NAME. Create the frame if needed. | |
Optional argument FOCUS means to whether focus the frame, or just open the file in background. | |
" | |
(let ((remember-frame (selected-frame)) | |
(frame (get-frame-create frame-or-name))) | |
(if focus (select-frame-set-input-focus frame) | |
(select-frame frame)) | |
(find-file file) | |
(unless focus (select-frame-set-input-focus remember-frame)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment