rpl-base.el 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ;;; rpl-base.el -- basic setup for the RPL tools
  2. ;; Copyright (C) 2014 Paul Onions
  3. ;; Author: Paul Onions <paul.onions@acm.org>
  4. ;; Keywords: RPL, SysRPL, HP48, HP49, HP50
  5. ;; This file is free software, see the LICENCE file in this directory
  6. ;; for copying terms.
  7. ;;; Commentary:
  8. ;; Basic setup for the RPL tools.
  9. ;;; Code:
  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11. ;; Customizations
  12. ;;
  13. (defgroup rpl nil
  14. "Tools for working with the RPL calculator programming language.")
  15. (defcustom rpl-sysrpl-data-file "sysrpl-data.el"
  16. "File from which to `read' SysRPL data."
  17. :type 'string
  18. :group 'rpl)
  19. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  20. ;; Utility functions for generating/loading pre-computed data
  21. ;;
  22. (defvar rpl-tools-data-dir
  23. (and load-file-name (concat (file-name-directory load-file-name) "data/"))
  24. "RPL tools data directory.")
  25. (defun rpl-write-data-file (obj filename)
  26. "Write OBJ to FILENAME using function `print'.
  27. The directory in which to write the file defaults to the value of
  28. the variable `rpl-tools-data-dir'. This can be overridden by
  29. specifying a different path in the FILENAME string (either
  30. relative or absolute)."
  31. (let ((default-directory rpl-tools-data-dir))
  32. (with-temp-buffer
  33. (print obj (current-buffer))
  34. (write-region (point-min) (point-max) filename))))
  35. (defun rpl-read-data-file (filename)
  36. "Read a Lisp object from FILENAME using function `read'.
  37. The directory in which FILENAME resides is assumed to be the
  38. value of the variable `rpl-tools-data-dir'. This can be
  39. overridden by specifying a different path in the FILENAME
  40. string (either relative or absolute)."
  41. (let ((default-directory rpl-tools-data-dir))
  42. (with-temp-buffer
  43. (insert-file-contents filename)
  44. (goto-char (point-min))
  45. (read (current-buffer)))))
  46. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  47. ;; Load SysRPL names files
  48. ;;
  49. (message "Loading SysRPL information")
  50. (defvar rpl-sysrpl-data
  51. nil ;;(rpl-read-data-file rpl-sysrpl-data-file)
  52. "!!!TODO!!!")
  53. (defvar rpl-sysrpl-names
  54. nil ; extract from rpl-sysrpl-data
  55. "!!!TODO!!!")
  56. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  57. ;; Common keymap (including the ``RPL'' menu)
  58. ;;
  59. (defvar rpl-menu-compile-file-enable nil)
  60. (make-variable-buffer-local 'rpl-menu-compile-file-enable)
  61. (defvar rpl-common-keymap
  62. (let ((map (make-sparse-keymap "RPL"))
  63. (menu-map (make-sparse-keymap "RPL")))
  64. (set-keymap-parent map prog-mode-map)
  65. ;; Key assignments
  66. (define-key map (kbd "C-c C-k") 'rpl-compile-file)
  67. ;; Menu items
  68. (define-key map [menu-bar rpl-menu] (cons "RPL" menu-map))
  69. (define-key menu-map [rpl-menu-compile-file]
  70. '(menu-item "Compile File..." rpl-compile-file
  71. :enable rpl-menu-compile-file-enable))
  72. (define-key menu-map [axiom-menu-separator-1]
  73. '(menu-item "--"))
  74. (define-key menu-map [rpl-menu-apropos]
  75. '(menu-item "Apropos (at point)..." rpl-apropos-thing-at-point))
  76. map)
  77. "The RPL tools common keymap.")
  78. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  79. ;; Developer utils
  80. ;;
  81. (defvar rpl-debug nil)
  82. (defmacro rpl-debug-message (msg)
  83. (if rpl-debug
  84. `(message ,msg)
  85. nil))
  86. (defun rpl-force-reload ()
  87. (interactive)
  88. (load "rpl-base")
  89. (load "rpl-sysrpl-mode"))
  90. (provide 'rpl-base)