Browse Source

add json-mode

pull/1/head
Brett Langdon 12 years ago
parent
commit
09b0e594bc
6 changed files with 78 additions and 0 deletions
  1. +4
    -0
      emacs
  2. +29
    -0
      emacs.d/elpa/json-mode-0.1.2/json-mode-autoloads.el
  3. +1
    -0
      emacs.d/elpa/json-mode-0.1.2/json-mode-pkg.el
  4. BIN
      emacs.d/elpa/json-mode-0.1.2/json-mode-pkg.elc
  5. +44
    -0
      emacs.d/elpa/json-mode-0.1.2/json-mode.el
  6. BIN
      emacs.d/elpa/json-mode-0.1.2/json-mode.elc

+ 4
- 0
emacs View File

@ -52,6 +52,10 @@
'(lambda ()
(add-hook 'before-save-hook 'gofmt)))
;js-mode overwrites json-mode when loading .json files, so this is
; to force json-mode for .json files
(add-to-list 'auto-mode-alist '("\\.json$" . json-mode))
;solarize ALL the things
(color-theme-initialize)
(color-theme-clarity)


+ 29
- 0
emacs.d/elpa/json-mode-0.1.2/json-mode-autoloads.el View File

@ -0,0 +1,29 @@
;;; json-mode-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads (json-mode) "json-mode" "json-mode.el" (21017 62178
;;;;;; 0 0))
;;; Generated autoloads from json-mode.el
(autoload 'json-mode "json-mode" "\
Major mode for editing JSON files
\(fn)" t nil)
;;;***
;;;### (autoloads nil nil ("json-mode-pkg.el") (21017 62178 965022
;;;;;; 0))
;;;***
(provide 'json-mode-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; json-mode-autoloads.el ends here

+ 1
- 0
emacs.d/elpa/json-mode-0.1.2/json-mode-pkg.el View File

@ -0,0 +1 @@
(define-package "json-mode" "0.1.2" "Major mode for editing JSON files" (quote nil))

BIN
emacs.d/elpa/json-mode-0.1.2/json-mode-pkg.elc View File


+ 44
- 0
emacs.d/elpa/json-mode-0.1.2/json-mode.el View File

@ -0,0 +1,44 @@
;;; json-mode.el --- Major mode for editing JSON files
;;; Author: Josh Johnston
;;; URL: https://github.com/joshwnj/json-mode
;;; Version: 0.1.2
;;;;
;; extend javascript-mode's syntax highlighting
(defvar json-mode-hook nil)
(defconst json-quoted-key-re "\\(\"[^\"]+?\"[ ]*:\\)")
(defconst json-quoted-string-re "\\(\".*?\"\\)")
(defconst json-number-re "[^\"]\\([0-9]+\\(\\.[0-9]+\\)?\\)[^\"]")
(defconst json-keyword-re "\\(true\\|false\\|null\\)")
(defconst json-font-lock-keywords-1
(list
(list json-quoted-key-re 1 font-lock-keyword-face)
(list json-quoted-string-re 1 font-lock-string-face)
(list json-keyword-re 1 font-lock-constant-face)
(list json-number-re 1 font-lock-constant-face)
)
"Level one font lock.")
(defun beautify-json ()
(interactive)
(let ((b (if mark-active (min (point) (mark)) (point-min)))
(e (if mark-active (max (point) (mark)) (point-max))))
;; Beautify json with support for non-ascii characters.
;; Thanks to https://github.com/jarl-dk for this improvement.
(shell-command-on-region b e
"python -c 'import sys,json; data=json.loads(sys.stdin.read()); print json.dumps(data,sort_keys=True,indent=4).decode(\"unicode_escape\").encode(\"utf8\",\"replace\")'" (current-buffer) t)))
;;;###autoload
(define-derived-mode json-mode javascript-mode "JSON"
"Major mode for editing JSON files"
(set (make-local-variable 'font-lock-defaults) '(json-font-lock-keywords-1 t)))
(add-to-list 'auto-mode-alist '("\\.json$" . json-mode))
(define-key json-mode-map (kbd "C-c C-f") 'beautify-json)
(provide 'json-mode)
;;; json-mode.el ends here

BIN
emacs.d/elpa/json-mode-0.1.2/json-mode.elc View File


Loading…
Cancel
Save