ein-ipynb-mode.el 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ;;; ein-ipynb-mode.el --- A simple mode for ipynb file
  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-ipynb-mode.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-ipynb-mode.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-ipynb-mode.el.
  15. ;; If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;;
  18. ;;; Code:
  19. (require 'ein-notebooklist)
  20. (defvar ein:ipynb-parent-mode 'js-mode
  21. "A mode (a symbol) to use for parent mode for `ein:ipynb-mode'.
  22. Note that this variable must be set *before* compiling EIN.")
  23. (defalias 'ein:ipynb-parent-mode ein:ipynb-parent-mode)
  24. ;;;###autoload
  25. (define-derived-mode ein:ipynb-mode ein:ipynb-parent-mode "ein:ipynb"
  26. "A simple mode for ipynb file.")
  27. (let ((map ein:ipynb-mode-map))
  28. (define-key map "\C-c\C-z" 'ein:notebooklist-open-notebook-by-file-name)
  29. (define-key map "\C-c\C-o" 'ein:notebooklist-open-notebook-by-file-name)
  30. (easy-menu-define ein:ipynb-menu map "EIN IPyNB Mode Menu"
  31. `("EIN IPyNB File"
  32. ,@(ein:generate-menu
  33. '(("Open notebook" ein:notebooklist-open-notebook-by-file-name))))))
  34. ;;;###autoload
  35. (add-to-list 'auto-mode-alist '(".*\\.ipynb\\'" . ein:ipynb-mode))
  36. (provide 'ein-ipynb-mode)
  37. ;;; ein-ipynb-mode.el ends here