Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.9 KiB

  1. ;;; ein-hy.el --- Hylang Support -*- lexical-binding: t; -*-
  2. ;; (C) 2018 - John M. Miller
  3. ;; Author: John Miller <millejoh at mac.com>
  4. ;; This file is NOT part of GNU Emacs.
  5. ;; ein-hy.el is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; ein-hy.el is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with ein-hy.el. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;;; Code:
  17. (require 'ein-classes)
  18. (cl-defmethod ein:cell-insert-prompt ((cell ein:hy-codecell))
  19. "Insert prompt of the CELL in the buffer.
  20. Called from ewoc pretty printer via `ein:cell-pp'."
  21. ;; Newline is inserted in `ein:cell-insert-input'.
  22. (ein:insert-read-only
  23. (concat
  24. (format "In (hy) [%s]" (or (ein:oref-safe cell 'input-prompt-number) " "))
  25. (ein:maybe-show-slideshow-data cell)
  26. (when (slot-value cell 'autoexec) " %s" ein:cell-autoexec-prompt))
  27. 'font-lock-face 'ein:cell-input-prompt))
  28. (cl-defmethod ein:cell-execute-internal ((cell ein:hy-codecell)
  29. kernel code &rest args)
  30. (ein:cell-clear-output cell t t t)
  31. (ein:cell-set-input-prompt cell "*")
  32. (ein:cell-running-set cell t)
  33. (setf (slot-value cell 'dynamic) t)
  34. (apply #'ein:kernel-execute kernel (ein:pytools-wrap-hy-code code) (ein:cell-make-callbacks cell) args))
  35. (cl-defmethod ein:cell-to-nb4-json :before ((cell ein:hy-codecell) _ &optional _ignore)
  36. (let ((metadata (slot-value cell 'metadata)))
  37. (setf metadata (plist-put metadata :ein.hycell t))))
  38. (provide 'ein-hy)