Skip to content

Commit 7def92e

Browse files
committed
Add src
1 parent 39ab3f2 commit 7def92e

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

gptscript-mode.el

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
;;; gptscript-mode.el --- Major mode for editing GPTScript natural language -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2024 Shen, Jen-Chieh
4+
5+
;; Author: Shen, Jen-Chieh <jcs090218@gmail.com>
6+
;; Maintainer: Shen, Jen-Chieh <jcs090218@gmail.com>
7+
;; URL: https://github.com/emacs-openai/gptscript-mode
8+
;; Version: 0.0.1
9+
;; Package-Requires: ((emacs "26.1"))
10+
;; Keywords: languages
11+
12+
;; This file is not part of GNU Emacs.
13+
14+
;; This program is free software: you can redistribute it and/or modify
15+
;; it under the terms of the GNU General Public License as published by
16+
;; the Free Software Foundation, either version 3 of the License, or
17+
;; (at your option) any later version.
18+
19+
;; This program is distributed in the hope that it will be useful,
20+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
;; GNU General Public License for more details.
23+
24+
;; You should have received a copy of the GNU General Public License
25+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
26+
27+
;;; Commentary:
28+
;;
29+
;; Major mode for editing GPTScript natural language.
30+
;;
31+
32+
;;; Code:
33+
34+
(defgroup gptscript-mode nil
35+
"Major mode for editing GPTScript natural language."
36+
:prefix "gptscript-mode-"
37+
:group 'comm
38+
:link '(url-link :tag "Repository" "https://github.com/emacs-openai/gptscript-mode"))
39+
40+
(defface gptscript-mode-symbol-face
41+
'((t :inherit font-lock-constant-face))
42+
"Face for highlighting symbols in GPTScript files."
43+
:group 'gptscript-mode)
44+
45+
(defconst gptscript-mode-parameters
46+
'("tool" "name" "model" "modelname" "description" "internalprompt" "tools"
47+
"args" "arg" "maxtoken" "maxtokens" "cache" "jsonresponse" "temperature")
48+
"List of parameters name.")
49+
50+
(defconst gptscript-mode-font-lock-keywords
51+
`((,(regexp-opt
52+
gptscript-mode-parameters
53+
'symbols)
54+
. gptscript-mode-symbol-face))
55+
"Keywords in GPTScript file.")
56+
57+
;;;###autoload
58+
(define-derived-mode gptscript-mode text-mode "GPTScript"
59+
"Major mode for editing GPTScript files."
60+
(font-lock-add-keywords 'gptscript-mode gptscript-mode-font-lock-keywords))
61+
62+
;;;###autoload
63+
(add-to-list 'auto-mode-alist '("\\.gpt\\'" . gptscript-mode))
64+
65+
(provide 'gptscript-mode)
66+
;;; gptscript-mode.el ends here

0 commit comments

Comments
 (0)