;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;; dsp.el ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; very rough attempt to allow emacs to control Mosaic. ;; shamefully uses global variables. ;; ;; when you are editing a file XXX you want to display in ;; a running Mosaic with pid nnn, issue the command M-x dsp ;; this will (1) save XXX ;; (2) create /tmp/Mosaic.nnn ;; [with appropriate contents] ;; (3) use kill to tell Mosaic to display XXX ;; ;; ;; load this file using M-x load-file first ;; ;;*****AT THE VERY BOTTOM of this file I ;;*****assign "ALT-a" to the function dsp ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;pick up pid of Mosaic process. ;;haven't tested with >1 Mosaic running (defun get-pids () (interactive) (setq the-pid-string (substring (shell-command "ps | grep Mosaic")0 5)) (setq the-pid-int (string-to-int the-pid-string)) (setq the-pid-string (int-to-string the-pid-int))) ;;eliminates spaces ;;construct contents of tmp file ;;it must contain the name of the file being edited (defun tmp-file-contents () (interactive) (setq line-1 "goto") (setq line-2 (concat "file://localhost" (buffer-file-name)))) ;;get rid of the old tmp file if it exists (defun remove-old-tmp-file () (interactive) (setq the-tmp-file (concat "/tmp/Mosaic." the-pid-string)) (if (file-exists-p the-tmp-file)(delete-file the-tmp-file))) ;;make a new tmp file and put info in it (defun create-new-tmp-file () (interactive) (find-file the-tmp-file) (insert-string line-1) (newline) (insert-string line-2) (newline) (save-buffer 0) (kill-buffer nil)) ;;tell mosaic to visit file using "kill" (defun tell-mosaic () (interactive) (setq the-command (concat "kill -USR1 " the-pid-string)) (shell-command the-command)) ;;here is the "top-level" function (defun dsp () (interactive) (save-buffer 0) (get-pids) (tmp-file-contents) (remove-old-tmp-file) (create-new-tmp-file) (tell-mosaic)) (global-set-key [?\A-a] 'dsp)