ein-scratchsheet.el 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ;;; ein-scratchsheet.el --- Worksheet without needs for saving
  2. ;; Copyright (C) 2012 Takafumi Arakaki
  3. ;; Author: Takafumi Arakaki <aka.tkf at gmail.com>
  4. ;; This file is NOT part of GNU Emacs.
  5. ;; ein-scratchsheet.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-scratchsheet.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-scratchsheet.el.
  15. ;; If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;;
  18. ;;; Code:
  19. (require 'ein-worksheet)
  20. (defvar ein:scratchsheet-buffer-name-template "*ein:scratch %s/%s*")
  21. (defclass ein:scratchsheet (ein:worksheet)
  22. ;; Note that `data' slot is accessed when rendering worksheet.
  23. ;; So, set valid empty data (`nil') here.
  24. ((data :initarg :data :initform nil))
  25. :documentation
  26. "Worksheet without needs for saving.")
  27. (defun ein:scratchsheet-new (nbformat get-notebook-name discard-output-p
  28. kernel events &rest args)
  29. (apply #'make-instance 'ein:scratchsheet
  30. :nbformat nbformat :get-notebook-name get-notebook-name
  31. :discard-output-p discard-output-p :kernel kernel :events events
  32. args))
  33. (defmethod ein:worksheet--buffer-name ((ws ein:scratchsheet))
  34. (format ein:scratchsheet-buffer-name-template
  35. (ein:worksheet-url-or-port ws)
  36. (ein:worksheet-full-name ws)))
  37. (provide 'ein-scratchsheet)
  38. ;;; ein-scratchsheet.el ends here