Skip to content

Commit

Permalink
chore (elisp): add example and prepare to publish (#3092)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Apr 9, 2024
1 parent 568285c commit d1aed01
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 26 deletions.
26 changes: 7 additions & 19 deletions dictionaries/elisp/cspell-ext.json
@@ -1,44 +1,32 @@
// cSpell Settings
{
"id": "elisp",
"version": "0.2",
"name": "Emacs Lisp",
"description": "Emacs Lisp dictionary for cspell.",
"readonly": true,
// List of dictionary files to add to the global list of dictionaries
"dictionaryDefinitions": [
{
"name": "elisp",
"path": "./dict/elisp.txt",
"description": "Emacs Lisp dictionary for cspell."
}
],
// Dictionaries to always be used.
// Generally left empty
"dictionaries": [],
// Language Rules to apply to matching files.
// Files are matched on `languageId` and `locale`
"languageSettings": [
{
// VSCode languageId. i.e. typescript, java, go, cpp, javascript, markdown, latex
// * will match against any file type.
"languageId": "elisp",
// Language locale. i.e. en-US, de-AT, or ru. * will match all locales.
// Multiple locales can be specified like: "en, en-US" to match both English and English US.
"languageId": "elisp,lisp",
"locale": "*",
// By default the whole text of a file is included for spell checking
// Adding patterns to the "includeRegExpList" to only include matching patterns
"includeRegExpList": [],
// To exclude patterns, add them to "ignoreRegExpList"
"ignoreRegExpList": [],
// regex patterns than can be used with ignoreRegExpList or includeRegExpList
// Example: "pattern": [{ "name": "mdash", "pattern": "—" }]
// This could be included in "ignoreRegExpList": ["mdash"]
"patterns": [],
// List of dictionaries to enable by name in `dictionaryDefinitions`
"dictionaries": ["elisp"],
// Dictionary definitions can also be supplied here. They are only used iff "languageId" and "locale" match.
"dictionaryDefinitions": []
}
],
"overrides": [
{
"filename": ["**/*.{el,lisp,lsp,l}"],
"dictionaries": ["elisp"]
}
]
}
7 changes: 3 additions & 4 deletions dictionaries/elisp/cspell.json
Expand Up @@ -3,10 +3,9 @@
"files": [
"**/*.{md,txt}"
],
"dictionaries": [
"elisp"
],
"import": [
"./cspell-ext.json"
]
],
"enableFiletypes": ["elisp", "lisp"],
"overrides": [{ "filename": "**/*.{md,txt}", "dictionaries": ["elisp"]}]
}
7 changes: 4 additions & 3 deletions dictionaries/elisp/package.json
@@ -1,8 +1,7 @@
{
"name": "@cspell/dict-elisp",
"version": "1.0.0",
"description": "Emacs Lisp dictionary for cspell. -- Private until verified",
"private": true,
"description": "Emacs Lisp dictionary for cspell.",
"publishConfig": {
"access": "public"
},
Expand All @@ -13,7 +12,9 @@
},
"scripts": {
"build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 cspell-tools-cli build",
"test": "head -n 1000 \"src/elisp.txt\" | cspell -c ./cspell-ext.json \"--locale=*\" \"--languageId=elisp\" stdin",
"test": "pnpm test:words && pnpm test:samples",
"test:words": "head -n 1000 \"src/elisp.txt\" | cspell -c ./cspell-ext.json \"--locale=*\" \"--languageId=elisp\" stdin",
"test:samples": "cspell -r samples .",
"prepublishOnly": "echo OK",
"prepare:dictionary": "pnpm run build"
},
Expand Down
5 changes: 5 additions & 0 deletions dictionaries/elisp/samples/cspell.json
@@ -0,0 +1,5 @@
{
"import": ["../cspell-ext.json"],
"enableFiletypes": ["elisp", "lisp"],
"words": ["elisp"]
}
54 changes: 54 additions & 0 deletions dictionaries/elisp/samples/examples.el
@@ -0,0 +1,54 @@
;;;; http://xahlee.info/emacs/emacs/elisp_examples.html

;;;; Insert Text
(defun my-insert-p-tag ()
"Insert <p></p> at cursor point."
(interactive)
(insert "<p></p>")
(backward-char 4))

;;;; Insert Around Region
(defun my-wrap-markup-region ()
"Insert a markup <b></b> around a region."
(interactive)
(let ((p1 (region-beginning))
(p2 (region-end)))
(goto-char p2)
(insert "</b>")
(goto-char p1)
(insert "<b>")))

;;;; Select Current Word

;; turn on highlight selection
(transient-mark-mode 1)

(defun my-select-current-word ()
"Select the word under cursor.
“word” here is considered any alphanumeric sequence with “_” or “-”."
(interactive)
(let (pt)
(skip-chars-backward "-_A-Za-z0-9")
(setq pt (point))
(skip-chars-forward "-_A-Za-z0-9")
(set-mark pt)))

;;;; Find Replace String in Region

(defun my-replace-greek-region ()
"Replace “alpha” to “α” and other greek letters in current region."
(interactive)
(let (
(p1 (region-beginning))
(p2 (region-end)))
(save-restriction
(narrow-to-region p1 p2)
(goto-char (point-min))
(while (search-forward " alpha" nil t)
(replace-match " α" nil t))
(goto-char (point-min))
(while (search-forward " beta" nil t)
(replace-match " β" nil t))
(goto-char (point-min))
(while (search-forward " gamma" nil t)
(replace-match " γ" nil t)))))

0 comments on commit d1aed01

Please sign in to comment.