@edwindjb I knew I wasn’t the only one looking for something like this ![]()
While this post is quite old, I was also looking for a SenseTalk mode for GNU Emacs around 2018. I had a couple false starts on my own mode, and then started up again recently when I saw this post!
The two main references I’m using are Xah Lee’s brief but excellent tutorial and Aemon Cannon’s code for as3-mode.el (ActionScript mode) or a newer one by Austin Haas.
Someone else must have done this by now, but I’ve yet to see it out there on any public SCM’s
If I ever finish even a simple version I’ll post it. But if someone else already completed one I’m game to try it out ![]()
Just from the perspective of getting the shell of the mode started, the below could get an enterprising person started (should be fine for GNU Emacs v27+ but results may vary for previous releases) using the two references above. Additionally, you’ll want to compare how SenseTalk highlighting compares to ActionScript and Objective-C in Emacs; this will make the task of “simulating” Eggplant Functional highlighting a little easier in terms of copying over existing .el features for modification as needed (with appropriate credit, of course, if using a GPL’d major mode file as reference like Cannon’s above).
-
sensetalk-mode-map: Used(make-sparse-keymap)to create a sparse keymap, which may be more efficient. - Example settings in the
sensetalk-modedefinition:
-
comment-start: Sets the comment prefix to#. -
indent-tabs-mode: Disables the use of tabs for indentation. -
tab-width: Sets the tab width to 2 spaces. Adjust this value as needed.
- Placed
(run-hooks 'sensetalk-mode-hook)at the end of thesensetalk-modedefinition to run any user-defined hooks. You can add custom hooks to this mode if desired. - Placed the
(add-to-list 'auto-mode-alist ...)line at the end, after theprovidestatement, to ensure it is executed after all the necessary functions and variables have been defined.
;;; sensetalk-mode.el --- A mode for editing Eggplant .script SenseTalk files
;; Copyright (C) 2023 Ian "GNUian" Bryant
;; Author: Ian "GNUian" Bryant
;; Keywords: language modes
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
(require 'font-lock)
(eval-when-compile
(require 'cl)
(require 'regexp-opt))
(defconst sensetalk-mode-version "0.0.0"
"SenseTalk Mode version number.")
(defgroup sensetalk nil
"Major mode for editing Eggplant .script SenseTalk files."
:group 'languages)
(defvar sensetalk-mode-hook nil)
(defvar sensetalk-mode-map
(let ((map (make-sparse-keymap)))
;; Add custom keybindings here, if needed
map)
"Keymap for SenseTalk major mode")
;;;###autoload
(define-derived-mode sensetalk-mode prog-mode "SenseTalk"
"Major mode for editing SenseTalk scripts."
:syntax-table sensetalk-mode-syntax-table
(setq-local font-lock-defaults '(sensetalk-font-lock-keywords))
;; Enable some additional features
(setq-local comment-start "# ")
(setq-local indent-tabs-mode nil)
(setq-local tab-width 2)
;; Add any other necessary settings
;; Run user-defined hooks
(run-hooks 'sensetalk-mode-hook))
;; Syntax highlighting definitions
(setq sensetalk-font-lock-keywords
'(
;; Add regex patterns for syntax highlighting here
;; Example: (("\\<\\(if\\|then\\|else\\)\\>" . font-lock-keyword-face))
;; You can define multiple patterns using the same face
;; String literals
;; Example: ("\"[^\"]+\"" . font-lock-string-face)
;; Comment syntax
;; Example: ("#.*$" . font-lock-comment-face)
))
(defvar sensetalk-mode-syntax-table
(let ((st (make-syntax-table)))
;; Add character syntax definitions here, if needed
;; Example: (modify-syntax-entry ?_ "w")
st))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.script\\'" . sensetalk-mode))
(provide 'sensetalk-mode)
;;; sensetalk-mode.el ends here