-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add emacs #1297
Merged
Merged
add emacs #1297
Changes from all commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
309d971
add emacs
JuanCaicedo 2aee520
rename to elisp
JuanCaicedo 5d3693b
add elisp to components
JuanCaicedo 1c7021c
add comment test
JuanCaicedo 4c96cab
add heading test
JuanCaicedo 68cd7b1
WIP string test
JuanCaicedo 1c45ad7
update string tests
JuanCaicedo 3fdd5a3
test symbols in strings
JuanCaicedo e785a09
test arguments
JuanCaicedo 52a01d2
test quoted symbol
JuanCaicedo 83ba77a
lisp-property test
JuanCaicedo 399b39e
splice test
JuanCaicedo 0ce2119
add keyword test
JuanCaicedo f9dd612
test for declare
JuanCaicedo 2a18699
test interactive
JuanCaicedo e60ef94
boolean test
JuanCaicedo f1551e8
test numbers
JuanCaicedo e0ad45e
test defvar
JuanCaicedo 46a21f7
fix greedy defun regex
JuanCaicedo 994708e
test defun
JuanCaicedo 5527bfd
test lambda
JuanCaicedo 3c9f493
test car
JuanCaicedo 5fbbbc8
test punctuation
JuanCaicedo eb6f73c
use var instead of const
JuanCaicedo 0f757d2
remove arrow functions
JuanCaicedo f099a79
flatten language structure
JuanCaicedo 5837a20
remove unnecessary escaping
JuanCaicedo 989b3ed
add lisp and emacs
JuanCaicedo 0310bb8
add lisp
JuanCaicedo 8ed6f9a
fix template strings
JuanCaicedo 9b573bf
minify lisp
JuanCaicedo 106b79b
add example elisp file
JuanCaicedo 87142dc
simplify number
JuanCaicedo 8f34c13
don't mark other def as keywords
JuanCaicedo 28007d4
dont mark other def as keyword in defun
JuanCaicedo c218e42
make lambda a keyword only at the beginning
JuanCaicedo 4c9111a
restore single quotes in components
JuanCaicedo 97b7a26
double quote in elisp
JuanCaicedo 9c16465
minify elisp
JuanCaicedo 3f5e137
quote keys in components
JuanCaicedo 84369ed
rename punctuation test
JuanCaicedo 5892437
add semicolons elisp
JuanCaicedo 655dc85
undo prettier changes to components.js
JuanCaicedo 20e6942
Merge remote-tracking branch 'upstream/master' into add-emacs
JuanCaicedo aa8eecb
add lisp to components.json
JuanCaicedo f3bf019
rename elisp to lisp
JuanCaicedo b7125bc
fix components.json
JuanCaicedo cc22fbc
add minified lisp file
JuanCaicedo a0099d4
rename example lisp file
JuanCaicedo 95bc23d
move lisp to first position
JuanCaicedo fafc95b
explain null initialized properties in lisp file
JuanCaicedo a2d7b6e
remove trailing commas
JuanCaicedo 76c2cab
put lisp first in example file
JuanCaicedo 6b0f2c6
add ifee for lisp file
JuanCaicedo 5bd1817
update lisp min file
JuanCaicedo c394ad7
update show language assets
JuanCaicedo 0434ded
add components index min file
JuanCaicedo ce3d0fa
add emacs-lisp alias
JuanCaicedo 02ec9af
change title of lisp example file
JuanCaicedo 1201857
undo theme change
JuanCaicedo feb38b6
Merge remote-tracking branch 'upstream/gh-pages' into add-emacs
JuanCaicedo 857fb1f
combine regex for parens
JuanCaicedo 1aebecd
remove min index
JuanCaicedo 58419f0
remove unneeded example html
JuanCaicedo 0b40f6f
remove doubled string test
JuanCaicedo 7999c2b
capitalize lisp in components
JuanCaicedo 9f29d39
change string theme to match master
JuanCaicedo ab77c09
build assets after adding lisp
JuanCaicedo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
(function (Prism) { | ||
// Functions to construct regular expressions | ||
// simple form | ||
// e.g. (interactive ... or (interactive) | ||
function simple_form(name) { | ||
return new RegExp('(\\()' + name + '(?=[\\s\\)])'); | ||
} | ||
// booleans and numbers | ||
function primitive(pattern) { | ||
return new RegExp('([\\s([])' + pattern + '(?=[\\s)])'); | ||
} | ||
|
||
// Patterns in regular expressions | ||
|
||
// Symbol name. See https://www.gnu.org/software/emacs/manual/html_node/elisp/Symbol-Type.html | ||
// & and : are excluded as they are usually used for special purposes | ||
var symbol = '[-+*/_~!@$%^=<>{}\\w]+'; | ||
// symbol starting with & used in function arguments | ||
var marker = '&' + symbol; | ||
// Open parenthesis for look-behind | ||
var par = '(\\()'; | ||
var endpar = '(?=\\))'; | ||
// End the pattern with look-ahead space | ||
var space = '(?=\\s)'; | ||
|
||
var language = { | ||
// Three or four semicolons are considered a heading. | ||
// See https://www.gnu.org/software/emacs/manual/html_node/elisp/Comment-Tips.html | ||
heading: { | ||
pattern: /;;;.*/, | ||
alias: ['comment', 'title'] | ||
}, | ||
comment: /;.*/, | ||
string: { | ||
pattern: /"(?:[^"\\]*|\\.)*"/, | ||
greedy: true, | ||
inside: { | ||
argument: /[-A-Z]+(?=[.,\s])/, | ||
symbol: new RegExp('`' + symbol + "'") | ||
} | ||
}, | ||
'quoted-symbol': { | ||
pattern: new RegExp("#?'" + symbol), | ||
alias: ['variable', 'symbol'] | ||
}, | ||
'lisp-property': { | ||
pattern: new RegExp(':' + symbol), | ||
alias: 'property' | ||
}, | ||
splice: { | ||
pattern: new RegExp(',@?' + symbol), | ||
alias: ['symbol', 'variable'] | ||
}, | ||
keyword: [ | ||
{ | ||
pattern: new RegExp( | ||
par + | ||
'(?:(?:lexical-)?let\\*?|(?:cl-)?letf|if|when|while|unless|cons|cl-loop|and|or|not|cond|setq|error|message|null|require|provide|use-package)' + | ||
space | ||
), | ||
lookbehind: true | ||
}, | ||
{ | ||
pattern: new RegExp( | ||
par + '(?:for|do|collect|return|finally|append|concat|in|by)' + space | ||
), | ||
lookbehind: true | ||
}, | ||
], | ||
declare: { | ||
pattern: simple_form('declare'), | ||
lookbehind: true, | ||
alias: 'keyword' | ||
}, | ||
interactive: { | ||
pattern: simple_form('interactive'), | ||
lookbehind: true, | ||
alias: 'keyword' | ||
}, | ||
boolean: { | ||
pattern: primitive('(?:t|nil)'), | ||
lookbehind: true | ||
}, | ||
number: { | ||
pattern: primitive('[-+]?\\d+(?:\\.\\d*)?'), | ||
lookbehind: true | ||
}, | ||
defvar: { | ||
pattern: new RegExp(par + 'def(?:var|const|custom|group)\\s+' + symbol), | ||
lookbehind: true, | ||
inside: { | ||
keyword: /^def[a-z]+/, | ||
variable: new RegExp(symbol) | ||
} | ||
}, | ||
defun: { | ||
pattern: new RegExp( | ||
par + | ||
'(?:cl-)?(?:defun\\*?|defmacro)\\s+' + | ||
symbol + | ||
'\\s+\\([\\s\\S]*?\\)' | ||
), | ||
lookbehind: true, | ||
inside: { | ||
keyword: /^(?:cl-)?def\S+/, | ||
// See below, this property needs to be defined later so that it can | ||
// reference the language object. | ||
arguments: null, | ||
function: { | ||
pattern: new RegExp('(^\\s)' + symbol), | ||
lookbehind: true | ||
}, | ||
punctuation: /[()]/ | ||
} | ||
}, | ||
lambda: { | ||
pattern: new RegExp(par + 'lambda\\s+\\((?:&?' + symbol + '\\s*)*\\)'), | ||
lookbehind: true, | ||
inside: { | ||
keyword: /^lambda/, | ||
// See below, this property needs to be defined later so that it can | ||
// reference the language object. | ||
arguments: null, | ||
punctuation: /[()]/ | ||
} | ||
}, | ||
car: { | ||
pattern: new RegExp(par + symbol), | ||
lookbehind: true | ||
}, | ||
punctuation: [ | ||
// open paren, brackets, and close paren | ||
/(['`,]?\(|[)\[\]])/, | ||
// cons | ||
{ | ||
pattern: /(\s)\.(?=\s)/, | ||
lookbehind: true | ||
}, | ||
] | ||
}; | ||
|
||
var arg = { | ||
'lisp-marker': new RegExp(marker), | ||
rest: { | ||
argument: { | ||
pattern: new RegExp(symbol), | ||
alias: 'variable' | ||
}, | ||
varform: { | ||
pattern: new RegExp(par + symbol + '\\s+\\S[\\s\\S]*' + endpar), | ||
lookbehind: true, | ||
inside: { | ||
string: language.string, | ||
boolean: language.boolean, | ||
number: language.number, | ||
symbol: language.symbol, | ||
punctuation: /[()]/ | ||
} | ||
} | ||
} | ||
}; | ||
|
||
var forms = '\\S+(?:\\s+\\S+)*'; | ||
|
||
var arglist = { | ||
pattern: new RegExp(par + '[\\s\\S]*' + endpar), | ||
lookbehind: true, | ||
inside: { | ||
'rest-vars': { | ||
pattern: new RegExp('&(?:rest|body)\\s+' + forms), | ||
inside: arg | ||
}, | ||
'other-marker-vars': { | ||
pattern: new RegExp('&(?:optional|aux)\\s+' + forms), | ||
inside: arg | ||
}, | ||
keys: { | ||
pattern: new RegExp('&key\\s+' + forms + '(?:\\s+&allow-other-keys)?'), | ||
inside: arg | ||
}, | ||
argument: { | ||
pattern: new RegExp(symbol), | ||
alias: 'variable' | ||
}, | ||
punctuation: /[()]/ | ||
} | ||
}; | ||
|
||
language['lambda'].inside.arguments = arglist; | ||
language['defun'].inside.arguments = Prism.util.clone(arglist); | ||
language['defun'].inside.arguments.inside.sublist = arglist; | ||
|
||
Prism.languages.lisp = language; | ||
Prism.languages.elisp = language; | ||
Prism.languages.emacs = language; | ||
Prism.languages['emacs-lisp'] = language; | ||
}(Prism)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<h2>Comments</h2> | ||
<pre><code>;; (foo bar)</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>(foo "bar")</code></pre> | ||
|
||
<h3>With nested symbols</h3> | ||
<pre><code>(foo "A string with a `symbol ")</code></pre> | ||
|
||
<h3>With nested arguments</h3> | ||
<pre><code>(foo "A string with an ARGUMENT ")</code></pre> | ||
|
||
<h2>Quoted symbols</h2> | ||
<pre><code>(foo #'bar)</code></pre> | ||
|
||
<h2>Lisp properties</h2> | ||
<pre><code>(foo :bar)</code></pre> | ||
|
||
<h2>Splices</h2> | ||
<pre><code>(foo ,bar ,@bar)</code></pre> | ||
|
||
<h2>Keywords</h2> | ||
<pre><code>(let foo (bar arg))</code></pre> | ||
|
||
<h2>Declarations</h2> | ||
<pre><code>(declare foo)</code></pre> | ||
|
||
<h2>Booleans</h2> | ||
<pre><code>(foo t)</code></pre> | ||
<pre><code>(foo nil)</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>(foo 1)</code></pre> | ||
<pre><code>(foo -1.5)</code></pre> | ||
|
||
<h2>Definitions</h2> | ||
<pre><code>(defvar bar 23)</code></pre> | ||
<pre><code>(defcustom bar 23)</code></pre> | ||
|
||
<h2>Function definitions</h2> | ||
<pre><code>(defun multiply-by-seven (number) | ||
"Multiply NUMBER by seven." | ||
(* 7 number))</code></pre> | ||
|
||
<h2>Lambda expressions</h2> | ||
<pre><code>(lambda (number) (* 7 number))</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(t) | ||
(nil) | ||
(foo t) | ||
[t ] | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation", "("], ["boolean", "t"], ["punctuation", ")"], | ||
["punctuation", "("], ["boolean", "nil"], ["punctuation", ")"], | ||
["punctuation", "("], ["car", "foo"], ["boolean", "t"], ["punctuation", ")"], | ||
["punctuation", "["], ["boolean", "t"], ["punctuation", "]"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for booleans. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(foo) | ||
(foo bar) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation","("], ["car", "foo"], ["punctuation",")"], | ||
["punctuation","("], ["car", "foo"], " bar", ["punctuation",")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for car. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
;; h1 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", ";; h1"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(declare) | ||
(declare a) | ||
(declare | ||
a) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation", "("], ["declare", "declare"], ["punctuation", ")"], | ||
["punctuation", "("], ["declare", "declare"], " a", ["punctuation", ")"], | ||
["punctuation", "("], ["declare", "declare"], "\r\na", ["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for declare. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(defun foo ()) | ||
(defun foo (bar)) | ||
(defun foo (bar &body arg1) ) | ||
(defun foo (bar &rest arg1) ) | ||
(defun foo (bar &body arg1 arg2) ) | ||
(defun foo (bar &key arg1) ) | ||
(defun foo (bar &key arg1 &allow-other-keys) ) | ||
(defun foo (&optional arg1) ) | ||
(defun defabc ()) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation", "("], ["defun", [ ["keyword", "defun" ], ["function", "foo"], ["punctuation", "("], ["arguments", []], ["punctuation", ")"]]], ["punctuation", ")"], | ||
["punctuation", "("], ["defun", [ ["keyword", "defun" ], ["function", "foo"], ["punctuation", "("], ["arguments", [[ "argument", "bar" ]]], ["punctuation", ")"]]], ["punctuation", ")"], | ||
["punctuation", "("], ["defun", [ ["keyword", "defun" ], ["function", "foo"], ["punctuation", "("], ["arguments", [[ "argument", "bar" ], ["rest-vars", [["lisp-marker", "&body" ], ["argument", "arg1"]]]]], ["punctuation", ")"]] ], ["punctuation", ")"], | ||
["punctuation", "("], ["defun", [ ["keyword", "defun" ], ["function", "foo"], ["punctuation", "("], ["arguments", [[ "argument", "bar" ], ["rest-vars", [["lisp-marker", "&rest" ], ["argument", "arg1"]]]]], ["punctuation", ")"]] ], ["punctuation", ")"], | ||
["punctuation", "("], ["defun", [ ["keyword", "defun" ], ["function", "foo"], ["punctuation", "("], ["arguments", [[ "argument", "bar" ], ["rest-vars", [["lisp-marker", "&body" ], ["argument", "arg1"], ["argument", "arg2"]]]]], ["punctuation", ")"]] ], ["punctuation", ")"], | ||
["punctuation", "("], ["defun", [ ["keyword", "defun" ], ["function", "foo"], ["punctuation", "("], ["arguments", [[ "argument", "bar" ], ["keys", [["lisp-marker", "&key" ], ["argument", "arg1"]]]]], ["punctuation", ")"]] ], ["punctuation", ")"], | ||
["punctuation", "("], ["defun", [ ["keyword", "defun" ], ["function", "foo"], ["punctuation", "("], ["arguments", [[ "argument", "bar" ], ["keys", [["lisp-marker", "&key" ], ["argument", "arg1"], ["lisp-marker", "&allow-other-keys"]]]]], ["punctuation", ")"]] ], ["punctuation", ")"], | ||
["punctuation", "("], ["defun", [ ["keyword", "defun" ], ["function", "foo"], ["punctuation", "("], ["arguments", [["other-marker-vars", [["lisp-marker", "&optional" ], ["argument", "arg1"]]]]], ["punctuation", ")"]] ], ["punctuation", ")"], | ||
["punctuation", "("], ["defun", [ ["keyword", "defun" ], ["function", "defabc"], ["punctuation", "("], ["arguments", []], ["punctuation", ")"]]], ["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for defun. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(defvar foo) | ||
(defvar foo bar) | ||
(defvar foo) | ||
(defvar) | ||
(defconst foo) | ||
(defcustom foo) | ||
(defgroup foo) | ||
(defvar defabc) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation", "("], ["defvar", [ ["keyword", "defvar" ], ["variable", "foo"] ]], ["punctuation", ")"], | ||
["punctuation", "("], ["defvar", [ ["keyword", "defvar" ], ["variable", "foo"] ]], " bar", ["punctuation", ")"], | ||
["punctuation", "("], ["defvar", [ ["keyword", "defvar" ], ["variable", "foo"] ]], ["punctuation", ")"], | ||
["punctuation", "("], ["car", "defvar"], ["punctuation", ")"], | ||
["punctuation", "("], ["defvar", [ ["keyword", "defconst" ], ["variable", "foo"] ]], ["punctuation", ")"], | ||
["punctuation", "("], ["defvar", [ ["keyword", "defcustom" ], ["variable", "foo"] ]], ["punctuation", ")"], | ||
["punctuation", "("], ["defvar", [ ["keyword", "defgroup" ], ["variable", "foo"] ]], ["punctuation", ")"], | ||
["punctuation", "("], ["defvar", [ ["keyword", "defvar" ], ["variable", "defabc"] ]], ["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for defvar. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
;;; h1 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["heading", ";;; h1"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for headings. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this alias is allowed. I added it to allow more flexibility, but I can remove it you'd rather not have it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok, we can keep it.