Klimi's new dotfiles with stow.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

67 linhas
2.4 KiB

5 anos atrás
  1. (defpackage swank-snapshot
  2. (:use cl)
  3. (:export restore-snapshot save-snapshot background-save-snapshot)
  4. (:import-from swank defslimefun))
  5. (in-package swank-snapshot)
  6. (defslimefun save-snapshot (image-file)
  7. (swank/backend:save-image image-file
  8. (let ((c swank::*emacs-connection*))
  9. (lambda () (resurrect c))))
  10. (format nil "Dumped lisp to ~A" image-file))
  11. (defslimefun restore-snapshot (image-file)
  12. (let* ((conn swank::*emacs-connection*)
  13. (stream (swank::connection.socket-io conn))
  14. (clone (swank/backend:dup (swank/backend:socket-fd stream)))
  15. (style (swank::connection.communication-style conn))
  16. (repl (if (swank::connection.user-io conn) t))
  17. (args (list "--swank-fd" (format nil "~d" clone)
  18. "--swank-style" (format nil "~s" style)
  19. "--swank-repl" (format nil "~s" repl))))
  20. (swank::close-connection conn nil nil)
  21. (swank/backend:exec-image image-file args)))
  22. (defslimefun background-save-snapshot (image-file)
  23. (let ((connection swank::*emacs-connection*))
  24. (flet ((complete (success)
  25. (let ((swank::*emacs-connection* connection))
  26. (swank::background-message
  27. "Dumping lisp image ~A ~:[failed!~;succeeded.~]"
  28. image-file success)))
  29. (awaken ()
  30. (resurrect connection)))
  31. (swank/backend:background-save-image image-file
  32. :restart-function #'awaken
  33. :completion-function #'complete)
  34. (format nil "Started dumping lisp to ~A..." image-file))))
  35. (in-package :swank)
  36. (defun swank-snapshot::resurrect (old-connection)
  37. (setq *log-output* nil)
  38. (init-log-output)
  39. (clear-event-history)
  40. (setq *connections* (delete old-connection *connections*))
  41. (format *error-output* "args: ~s~%" (command-line-args))
  42. (let* ((fd (read-command-line-arg "--swank-fd"))
  43. (style (read-command-line-arg "--swank-style"))
  44. (repl (read-command-line-arg "--swank-repl"))
  45. (* (format *error-output* "fd=~s style=~s~%" fd style))
  46. (stream (make-fd-stream fd nil))
  47. (connection (make-connection nil stream style)))
  48. (let ((*emacs-connection* connection))
  49. (when repl (swank-repl:create-repl nil))
  50. (background-message "~A" "Lisp image restored"))
  51. (serve-requests connection)
  52. (simple-repl)))
  53. (defun read-command-line-arg (name)
  54. (let* ((args (command-line-args))
  55. (pos (position name args :test #'equal)))
  56. (read-from-string (elt args (1+ pos)))))
  57. (in-package :swank-snapshot)
  58. (provide :swank-snapshot)