Last active
September 11, 2015 12:06
-
-
Save Bad-ptr/e05fb8d02436214abd89 to your computer and use it in GitHub Desktop.
Open files in single emacs instance without daemon.
This file contains hidden or 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/bash | |
if pidof emacs &> /dev/null; then | |
echo "$1" >> /tmp/emacs-files-to-find | |
else | |
emacs "$1" | |
fi |
This file contains hidden or 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
(defvar files-to-find-file-name "/tmp/emacs-files-to-find") | |
(defvar files-to-find-buffer (or (find-buffer-visiting files-to-find-file-name) | |
(with-current-buffer (find-file-noselect files-to-find-file-name) | |
(rename-buffer " *emacs-files-to-find-buf*") | |
(save-buffer) | |
(current-buffer)))) | |
(defun files-to-find-func-for-hook () | |
(let ((files (split-string | |
(with-current-buffer files-to-find-buffer | |
(let ((ret (buffer-string))) | |
(erase-buffer) | |
(save-buffer) | |
ret)) | |
"\n" t "[ \t\n]"))) | |
(mapc #'find-file files))) | |
(with-current-buffer files-to-find-buffer | |
(add-hook 'after-revert-hook #'files-to-find-func-for-hook nil t) | |
(auto-revert-mode)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment