Created
July 23, 2025 02:46
-
-
Save eddieh/4b2152c15ea9ec10f1b286a900c48f76 to your computer and use it in GitHub Desktop.
Modify Generate Your Projects (GYP) files .gyp & .gypi handling in Emacs 30.1
This file contains hidden or 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
(defun e/modify-gyp-syntax () | |
"Generate Your Projects (GYP) files .gyp & .gypi files look like JSON, | |
but can have # comments and single quotes are permitted as string | |
delimiters. It also permits trailing commas at the end of list and | |
dictionary content." | |
(when (and (stringp buffer-file-name) | |
(string-match "\\.gypi?\\'" buffer-file-name)) | |
(let ((gyp-syntax-table (copy-syntax-table js-mode-syntax-table))) | |
(modify-syntax-entry ?# "<" gyp-syntax-table) | |
(modify-syntax-entry ?\n ">" gyp-syntax-table) | |
(modify-syntax-entry ?\' "\"" gyp-syntax-table) | |
(set-syntax-table gyp-syntax-table)))) | |
(add-to-list 'auto-mode-alist '("\\.gypi?\\'" . js-json-mode)) | |
(add-hook 'js-json-mode-hook (lambda () | |
(e/modify-gyp-syntax) | |
(editorconfig-apply))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also applies EditorConfig rules manually since the built-in editorconfig-mode and js-json-mode don't seem to like each other.