;;; sysrpl-mode.el -- Major mode for the SysRPL programming language ;; Copyright (C) 2013 Paul Onions ;; Author: Paul Onions ;; 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)