123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- ;;; sysrpl-mode.el -- Major mode for the SysRPL programming language
- ;; Copyright (C) 2013 Paul Onions
- ;; Author: Paul Onions <paul.onions@acm.org>
- ;; Keywords: RPL, SysRPL, HP48, HP49, HP50, calculator
- ;; This file is free software, see the LICENCE file in this directory
- ;; for copying terms.
- ;;; Commentary:
- ;; A major mode for the SysRPL language, the system programming
- ;; language of HP48/49/50-series calculators.
- ;;; Code:
- (require 'rpl-base)
- (defcustom rpl-sysrpl-default-calculator :HP48G
- "Default calculator type for SysRPL mode."
- :type '(radio :HP38G :HP39G :HP48G :HP49G)
- :group 'rpl)
- (defface sysrpl-name '((t (:foreground "blue")))
- "Face used for displaying SysRPL names."
- :group 'rpl)
- (defvar sysrpl-syntax-table
- (let ((table (make-syntax-table)))
- (modify-syntax-entry ?: "w" table)
- (modify-syntax-entry ?! "w" table)
- (modify-syntax-entry ?@ "w" table)
- (modify-syntax-entry ?# "w" table)
- (modify-syntax-entry ?$ "w" table)
- (modify-syntax-entry ?% "w" table)
- (modify-syntax-entry ?^ "w" table)
- (modify-syntax-entry ?& "w" table)
- (modify-syntax-entry ?\? "w" table)
- (modify-syntax-entry ?- "w" table)
- (modify-syntax-entry ?_ "w" table)
- (modify-syntax-entry ?= "w" table)
- (modify-syntax-entry ?+ "w" table)
- (modify-syntax-entry ?/ "w" table)
- (modify-syntax-entry ?< "w" table)
- (modify-syntax-entry ?> "w" table)
- (modify-syntax-entry ?| "w" table)
- table)
- "The SysRPL syntax table.")
- (defvar sysrpl-keywords-regexp
- (concat "\\<" (regexp-opt rpl-sysrpl-names) "\\>")
- "Regular expression for SysRPL keywords.")
- (defvar sysrpl-keyword-face 'sysrpl-name)
- (defvar sysrpl-font-lock-keywords
- (list (cons sysrpl-keywords-regexp 'sysrpl-keyword-face)))
- (defvar sysrpl-selected-calculator rpl-sysrpl-default-calculator
- "Currently selected calculator model.")
- (defun sysrpl-select-hp38g ()
- "Set the currently selected calculator model to be the 38G."
- (interactive)
- (setq sysrpl-selected-calculator :HP38G))
- (defun sysrpl-select-hp39g ()
- "Set the currently selected calculator model to be the 39G."
- (interactive)
- (setq sysrpl-selected-calculator :HP39G))
- (defun sysrpl-select-hp48g ()
- "Set the currently selected calculator model to be the 48G."
- (interactive)
- (setq sysrpl-selected-calculator :HP48G))
- (defun sysrpl-select-hp49g ()
- "Set the currently selected calculator model to be the 49G."
- (interactive)
- (setq sysrpl-selected-calculator :HP49G))
- (defvar sysrpl-mode-map
- (let ((map (make-sparse-keymap))
- (menu-map (make-sparse-keymap)))
- (set-keymap-parent map rpl-common-keymap)
- ;; Menu items
- (define-key map [menu-bar rpl-menu] (cons "RPL" menu-map))
- (define-key menu-map [sysrpl-menu-separator-1]
- '(menu-item "--"))
- (define-key menu-map [sysrpl-menu-select-hp49g]
- '(menu-item "HP49G" sysrpl-select-hp49g
- :button (:radio . (eql :HP49G sysrpl-selected-calculator))))
- (define-key menu-map [sysrpl-menu-select-hp48g]
- '(menu-item "HP48G" sysrpl-select-hp48g
- :button (:radio . (eql :HP48G sysrpl-selected-calculator))))
- (define-key menu-map [sysrpl-menu-select-hp39g]
- '(menu-item "HP39G" sysrpl-select-hp39g
- :button (:radio . (eql :HP39G sysrpl-selected-calculator))))
- (define-key menu-map [sysrpl-menu-select-hp38g]
- '(menu-item "HP38G" sysrpl-select-hp38g
- :button (:radio . (eql :HP38G sysrpl-selected-calculator))))
- map)
- "The SysRPL mode local keymap.")
- (defvar sysrpl-mode-hook nil
- "Hook for customizing SysRPL mode.")
- (define-derived-mode sysrpl-mode prog-mode "SysRPL"
- "Major mode for the SysRPL language."
- :group 'rpl
- (setq font-lock-defaults (list sysrpl-font-lock-keywords))
- (setq rpl-menu-compile-file-enable t))
- (provide 'sysrpl-mode)
|