Mercurial > hg > dotemacs
changeset 120:ec989c73f6da
elpa: add json-mode
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Wed, 08 Apr 2015 15:42:01 -0400 |
parents | ae2b533bde8f |
children | 0296487fa83c |
files | elpa/archives/gnu/archive-contents elpa/archives/marmalade/archive-contents elpa/json-mode-1.2.0/json-mode-autoloads.el elpa/json-mode-1.2.0/json-mode-pkg.el elpa/json-mode-1.2.0/json-mode.el |
diffstat | 5 files changed, 357 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/elpa/archives/gnu/archive-contents +++ b/elpa/archives/gnu/archive-contents @@ -1,4 +1,9 @@ (1 + (ace-window . + [(0 8 0) + nil "Quickly switch windows." tar + ((:keywords "window" "location") + (:url . "https://github.com/abo-abo/ace-window"))]) (ack . [(1 3) nil "Interface to ack-like source code search tools" tar @@ -29,11 +34,22 @@ [(3 0) nil "Indent and dedent Lisp code, automatically adjust close parens" tar ((:url . "http://elpa.gnu.org/packages/adjust-parens.html"))]) + (aggressive-indent . + [(1 0 1) + ((emacs + (24 1)) + (names + (20150125 9)) + (cl-lib + (0 5))) + "Minor mode to aggressively keep your code always indented" single + ((:url . "http://github.com/Malabarba/aggressive-indent-mode") + (:keywords "indent" "lisp" "maint" "tools"))]) (ahungry-theme . - [(1 0 3) + [(1 0 6) ((emacs (24))) - "Ahungry color theme for Emacs." tar + "Ahungry color theme for Emacs. Make sure to (load-theme 'ahungry)." tar ((:keywords "ahungry" "palette" "color" "theme" "emacs" "color-theme" "deftheme") (:url . "https://github.com/ahungry/color-theme-ahungry"))]) (all . @@ -47,7 +63,7 @@ ((:url . "http://www.gnuvola.org/software/aa2u/") (:keywords "ascii" "unicode" "box-drawing"))]) (auctex . - [(11 88 2) + [(11 88 3) nil "Integrated environment for *TeX*" tar ((:url . "http://www.gnu.org/software/auctex/"))]) (aumix-mode . @@ -55,6 +71,20 @@ nil "run the aumix program in a buffer" single ((:url . "http://user42.tuxfamily.org/aumix-mode/index.html") (:keywords "multimedia" "mixer" "aumix"))]) + (auto-overlays . + [(0 10 9) + nil "Automatic regexp-delimited overlays" tar + ((:keywords "extensions") + (:url . "http://www.dr-qubit.org/emacs.php"))]) + (bug-hunter . + [(0 1) + ((seq + (1 3)) + (cl-lib + (0 5))) + "Hunt down errors in elisp files" single + ((:url . "http://github.com/Bruce-Connor/elisp-bug-hunter") + (:keywords "lisp"))]) (caps-lock . [(1 0) nil "Caps-lock as a minor mode" single @@ -68,7 +98,7 @@ ((:keywords "games") (:url . "http://elpa.gnu.org/packages/chess.html"))]) (cl-generic . - [(0 1) + [(0 2) nil "Forward cl-generic compatibility for Emacs<25" single ((:url . "http://elpa.gnu.org/packages/cl-generic.html") (:keywords))]) @@ -83,7 +113,7 @@ ((:url . "http://github.com/defunkt/coffee-mode") (:keywords "coffeescript" "major" "mode"))]) (company . - [(0 8 11) + [(0 8 12) ((emacs (24 1)) (cl-lib @@ -92,7 +122,7 @@ ((:keywords "abbrev" "convenience" "matching") (:url . "http://company-mode.github.io/"))]) (company-statistics . - [(0 1) + [(0 1 1) ((emacs (24 3)) (company @@ -100,6 +130,15 @@ "Sort candidates using completion history" tar ((:keywords "abbrev" "convenience" "matching") (:url . "https://github.com/company-mode/company-statistics"))]) + (context-coloring . + [(6 2 0) + ((emacs + (24)) + (js2-mode + (20150126))) + "Syntax highlighting, except not for syntax." single + ((:url . "https://github.com/jacksonrayhamilton/context-coloring") + (:keywords "context" "coloring" "syntax" "highlighting"))]) (crisp . [(1 3 4) nil "CRiSP/Brief Emacs emulator" single @@ -117,6 +156,13 @@ "Remove visual distractions and focus on writing" single ((:url . "http://elpa.gnu.org/packages/darkroom.html") (:keywords "convenience" "emulations"))]) + (dbus-codegen . + [(0 1) + ((cl-lib + (0 5))) + "Lisp code generation for D-Bus." single + ((:url . "http://elpa.gnu.org/packages/dbus-codegen.html") + (:keywords "comm" "dbus" "convenience"))]) (debbugs . [(0 6) nil "SOAP library to access debbugs servers" tar @@ -246,10 +292,10 @@ ((:url . "http://www.dr-qubit.org/emacs.php") (:keywords "extensions" "data structures" "heap" "priority queue"))]) (hydra . - [(0 6 1) + [(0 12 1) ((cl-lib (0 5))) - "Make bindings that stick around" tar + "Make bindings that stick around." tar ((:keywords "bindings") (:url . "https://github.com/abo-abo/hydra"))]) (ioccur . @@ -257,13 +303,20 @@ nil "Incremental occur" single ((:url . "http://elpa.gnu.org/packages/ioccur.html") (:keywords))]) + (iterators . + [(0 1) + ((emacs + (25))) + "Functions for working with iterators" single + ((:url . "http://elpa.gnu.org/packages/iterators.html") + (:keywords "extensions" "elisp"))]) (javaimp . [(0 5) nil "Add and reorder Java import statements in Maven projects" single ((:url . "http://elpa.gnu.org/packages/javaimp.html") (:keywords "java" "maven" "programming"))]) (jgraph-mode . - [(1 0) + [(1 1) ((cl-lib (0 5))) "Major mode for Jgraph files" single @@ -302,6 +355,16 @@ nil "Load all Emacs Lisp files in a given directory" single ((:url . "http://elpa.gnu.org/packages/load-dir.html") (:keywords "lisp" "files" "convenience"))]) + (load-relative . + [(1 2) + nil "relative file load (within a multi-file Emacs package)" single + ((:url . "http://github.com/rocky/emacs-load-relative") + (:keywords "internal"))]) + (loc-changes . + [(1 2) + nil "keep track of positions even after buffer changes" single + ((:url . "http://github.com/rocky/emacs-loc-changes") + (:keywords))]) (markchars . [(0 2 0) nil "Mark chars fitting certain characteristics" single @@ -344,7 +407,7 @@ ((:url . "http://elpa.gnu.org/packages/nhexl-mode.html") (:keywords "data"))]) (nlinum . - [(1 5) + [(1 6) nil "Show line numbers in the margin" single ((:url . "http://elpa.gnu.org/packages/nlinum.html") (:keywords "convenience"))]) @@ -368,7 +431,7 @@ ((:url . "http://elpa.gnu.org/packages/omn-mode.html") (:keywords))]) (org . - [(20150202) + [(20150406) nil "Outline-based notes management and organizer" tar nil]) (osc . [(0 1) @@ -376,7 +439,7 @@ ((:url . "http://elpa.gnu.org/packages/osc.html") (:keywords "comm" "processes" "multimedia"))]) (pabbrev . - [(4 1) + [(4 2) nil "Predictive abbreviation expansion" single ((:url . "http://elpa.gnu.org/packages/pabbrev.html") (:keywords))]) @@ -396,7 +459,7 @@ ((:url . "http://www.dr-qubit.org/emacs.php") (:keywords "extensions" "data structures" "queue"))]) (rainbow-mode . - [(0 10) + [(0 11) nil "Colorize color names in buffers" single ((:url . "http://elpa.gnu.org/packages/rainbow-mode.html") (:keywords "faces"))]) @@ -416,7 +479,7 @@ ((:url . "http://elpa.gnu.org/packages/scroll-restore.html") (:keywords "scrolling"))]) (seq . - [(1 0) + [(1 3) nil "Sequence manipulation functions" single ((:url . "http://elpa.gnu.org/packages/seq.html") (:keywords "sequences"))]) @@ -431,7 +494,7 @@ ((:url . "http://elpa.gnu.org/packages/sisu-mode.html") (:keywords "text" "processes" "tools"))]) (sml-mode . - [(6 5) + [(6 7) nil "Major mode for editing (Standard) ML" single ((:url . "http://elpa.gnu.org/packages/sml-mode.html") (:keywords "sml"))]) @@ -440,6 +503,13 @@ nil "Implementation of Sokoban for Emacs." tar ((:keywords "games") (:url . "http://elpa.gnu.org/packages/sokoban.html"))]) + (spinner . + [(1 0) + ((cl-lib + (0 5))) + "Add spinners and progress-bars to the mode-line for ongoing operations" single + ((:url . "https://github.com/Bruce-Connor/spinner.el") + (:keywords "processes" "mode-line"))]) (svg . [(0 1) ((emacs @@ -456,6 +526,13 @@ "Analog clock using Scalable Vector Graphics" single ((:url . "http://elpa.gnu.org/packages/svg-clock.html") (:keywords "demo" "svg" "clock"))]) + (swiper . + [(0 2 0) + ((emacs + (24 1))) + "Isearch with an overview. Oh, man!" tar + ((:keywords "matching") + (:url . "https://github.com/abo-abo/swiper"))]) (tNFA . [(0 1 1) ((queue @@ -468,6 +545,23 @@ nil "temp buffer browse mode" single ((:url . "http://elpa.gnu.org/packages/temp-buffer-browse.html") (:keywords "convenience"))]) + (test-simple . + [(1 1) + nil "Simple Unit Test Framework for Emacs Lisp" single + ((:url . "http://github.com/rocky/emacs-test-simple") + (:keywords "unit-test"))]) + (timerfunctions . + [(1 4 2) + ((cl-lib + (0 5))) + "Enhanced versions of some timer.el functions" single + ((:url . "http://elpa.gnu.org/packages/timerfunctions.html") + (:keywords))]) + (tiny . + [(0 1) + nil "Quickly generate linear ranges in Emacs" tar + ((:keywords "convenience") + (:url . "https://github.com/abo-abo/tiny"))]) (trie . [(0 2 6) ((tNFA @@ -509,7 +603,7 @@ ((:keywords "http" "server" "network") (:url . "https://github.com/eschulte/emacs-web-server"))]) (websocket . - [(1 3) + [(1 4) nil "Emacs WebSocket client and server" tar ((:keywords "communication" "websocket" "server") (:url . "http://elpa.gnu.org/packages/websocket.html"))])
--- a/elpa/archives/marmalade/archive-contents +++ b/elpa/archives/marmalade/archive-contents @@ -1,11 +1,4 @@ (1 - (niclein . - [(0 0 1) - ((shadchen - (1 4)) - (smartparens - (1 5))) - "Nic's lein and clojure integration" single]) (zone-matrix . [(0 0 1) nil "Matrix themed Zone mode" tar]) @@ -44,6 +37,18 @@ (zeal-at-point . [(0 0 3) nil "Search the word at point with Zeal" single]) + (yoshi-theme . + [(5 12 0) + nil "Theme named after my cat" single]) + (yesql-ghosts . + [(0 1 0) + ((s + (1 9 0)) + (dash + (2 10 0)) + (cider + (0 8 0))) + "Display ghostly yesql defqueries inline" single]) (yasnippet-bundle . [(0 6 1) nil "Yet another snippet extension (Auto compiled bundle)" single]) @@ -84,6 +89,9 @@ ((json (1 3))) "View xkcd from Emacs" single]) + (xbm-life . + [(0 1) + nil "A XBM version of Conway's Game of Life" single]) (wxwidgets-help . [(0 0 3) nil "Look up wxWidgets API by using local html manual." tar]) @@ -136,6 +144,9 @@ (winpoint . [(1 4) nil "Remember buffer positions per-window, not per buffer" single]) + (winner-mode-enable . + [(0 0 5) + nil "Enables winner mode if its available" tar]) (window-number . [(1 0 3) nil "Select windows by numbers." single]) @@ -154,9 +165,9 @@ (1 9 0))) "use elisp doc strings to make other documentation" single]) (wiki-nav . - [(1 0 0) + [(1 0 2) ((button-lock - (1 0 0)) + (1 0 2)) (nav-flash (1 0 0))) "Simple file navigation using [[WikiStrings]]" single]) @@ -180,7 +191,7 @@ [(1 94) nil "Emacs-wget is an interface program of GNU wget on Emacs." tar]) (weechat . - [(0 2) + [(0 2 2) ((s (1 3 1)) (cl-lib @@ -432,7 +443,7 @@ [(12) nil "A theme loosely based on Tron: Legacy colors" single]) (tracking . - [(1 5) + [(1 6) ((shorten (0 3))) "Buffer modification tracking" single]) @@ -542,6 +553,11 @@ (syntactic-sugar . [(0 9 4) nil "Effect-free forms such as if/then/else" single]) + (synosaurus . + [(0 1 0) + ((cl-lib + (0 5))) + "An extensible thesaurus supporting lookup and substitution." tar]) (synonyms . [(1 0) nil "Look up synonyms for a word or phrase in a thesaurus." single]) @@ -857,7 +873,7 @@ [(1 1) nil "Show the css of the html attribute the cursor is on" single]) (shorten . - [(0 3) + [(1 6) nil "component-wise string shortener" single]) (shoes-off . [(0 1 8) @@ -996,7 +1012,7 @@ [(0 2) nil "special functions for Hunspell in ispell.el" single]) (rvm . - [(1 3 0) + [(1 4 0) nil "Emacs integration for rvm" single]) (rust-mode . [(0 1 0) @@ -1132,7 +1148,7 @@ (0 0 5))) "robots based on rcirc irc" single]) (rcirc-notify . - [(0 9) + [(1 0 0) nil "libnotify popups" single]) (rcirc-color . [(0 2) @@ -1347,6 +1363,9 @@ (pinboard . [(0 0 1) nil "get stuff from pinboard" single]) + (picpocket . + [(8) + nil "Image viewer" single]) (pickup . [(0 0 3) nil "pickup file." single]) @@ -1486,7 +1505,7 @@ (1 0))) "Simple package system for Emacs" single]) (pabbrev . - [(4 1) + [(4 2) nil "Predictive abbreviation expansion" single]) (p4 . [(11 0) @@ -1529,7 +1548,7 @@ [(0 0 8) nil "export html and meta data used by static blog like nikola from org file" tar]) (org2jekyll . - [(0 1 2) + [(0 1 4) ((dash (2 10 0)) (dash-functional @@ -1547,9 +1566,9 @@ (1 6 8))) "Blog from Org mode to wordpress" tar]) (org-trello . - [(0 6 9 1) + [(0 6 9 3) ((request-deferred - (0 1 0)) + (0 2 0)) (deferred (0 3 2)) (s @@ -1602,7 +1621,7 @@ (6 1))) "basic support for magit links" single]) (org-journal . - [(1 6 4) + [(1 7 2) nil "a simple org-mode based journaling mode" single]) (org-gnome . [(0 1) @@ -1736,6 +1755,13 @@ ((auto-complete (1 4))) "A major mode for the Nimrod programming language" single]) + (niclein . + [(0 0 5) + ((shadchen + (1 4)) + (smartparens + (1 5))) + "Nic's lein and clojure integration" single]) (nginx-mode . [(1 1) nil "major mode for editing nginx config files" single]) @@ -1757,6 +1783,9 @@ (mwe-log-commands . [(20041106) nil "log keyboard commands to buffer" single]) + (mvn-help . + [(0 0 1) + nil "maven help tools" single]) (mv-shell . [(1 2) nil "keep buffers in sync with filename throughout 'mv'commands in shell-mode." single]) @@ -1782,7 +1811,7 @@ [(0 8 8) nil "Managing multiple terminal buffers in Emacs." single]) (multi-project . - [(0 0 16) + [(0 0 17) nil "Easily work with multiple projects." single]) (multi-eshell . [(0 0 1) @@ -2034,8 +2063,14 @@ (1 2 0))) "completing-read over all files in Git" single]) (magit . - [(1 2 2) - nil "Control Git from Emacs." tar]) + [(1 4 0) + ((cl-lib + (0 5)) + (git-commit-mode + (1 0 0)) + (git-rebase-mode + (1 0 0))) + "Control Git from Emacs." tar]) (mactag . [(0 0 1) nil "Mode for automatically handle multiple tags files with Mactag rubygem" single]) @@ -2062,9 +2097,9 @@ [(0 0 2) nil "lxc integration with Emacs" single]) (lui . - [(1 5) + [(1 6) ((tracking - (1 5))) + (1 6))) "Linewise User Interface" tar]) (lua-mode . [(20110428) @@ -2164,7 +2199,7 @@ [(20120706) nil "Add legalese to your program files" single]) (lcs . - [(1 5) + [(1 6) nil "find out the longest common sequence" single]) (layout-restore . [(0 4) @@ -2234,7 +2269,7 @@ [(0 1 0) nil "Karma Test Runner Emacs Integration" single]) (kanban . - [(0 1 3) + [(0 1 4) nil "Parse org-todo headlines to use org-tables as Kanban tables" single]) (jump-dls . [(0 6) @@ -2309,6 +2344,9 @@ (jasmin . [(1 2) nil "major editing mode for Jasmin Java bytecode assembler files" single]) + (jammer . + [(0 0 2) + nil "Punish yourself for using Emacs inefficiently" single]) (jam-mode . [(0 3) nil "Font-lock support for Jam files" single]) @@ -2443,7 +2481,7 @@ [(1 0) nil "highlight the word the point is on" single]) (ical-pull . - [(0 0 2) + [(0 0 3) ((shadchen (1 2)) (dash @@ -2451,7 +2489,9 @@ (s (1 9 0)) (noflet - (0 0 14))) + (0 0 14)) + (web + (0 5 1))) "pull ical feeds into org-agenda" single]) (ibuffer-vc . [(0 7) @@ -2737,8 +2777,8 @@ [(1 0) nil "vc-mode extension for fast git interaction" single]) (gitignore-mode . - [(0 1) - nil "Major mode for editing .gitconfig files" single]) + [(1 1 0) + nil "Major mode for editing .gitignore files" single]) (github-theme . [(0 0 3) nil "Github color theme for GNU Emacs 24" single]) @@ -2756,6 +2796,12 @@ (gitattributes-whitespace . [(1 20141128) nil "configure whitespace settings from gitattributes" single]) + (gitattributes-mode . + [(1 1 0) + nil "Major mode for editing .gitattributes files" single]) + (git-rebase-mode . + [(1 0 0) + nil "Major mode for editing git rebase files" single]) (git-gutter-fringe . [(0 12) ((git-gutter @@ -2776,13 +2822,13 @@ (2 9 0))) "draft git commit messages" single]) (git-commit-mode . - [(0 13) + [(1 0 0) nil "Major mode for editing git commit messages" single]) (git-commit . [(0 1) nil "Major mode for editing git commit messages" single]) (git-auto-commit-mode . - [(4 3 0) + [(4 4 0) nil "Emacs Minor mode to automatically commit and push" single]) (gist . [(1 2 1) @@ -3060,15 +3106,15 @@ (0 15))) "A flycheck checker for Haskell using hdevtools" single]) (flycheck-haskell . - [(0 4) + [(0 6) ((flycheck - (0 16)) + (0 22)) (haskell-mode (13 7)) (dash (2 4 0)) - (f - (0 11 0))) + (let-alist + (1 0 1))) "Flycheck: Cabal projects and sandboxes" tar]) (flycheck-color-mode-line . [(0 3) @@ -3089,17 +3135,17 @@ (2 4 0))) "Cask support in Flycheck" single]) (flycheck . - [(0 22) - ((dash - (2 4 0)) + [(0 23) + ((emacs + (24 1)) + (cl-lib + (0 3)) + (let-alist + (1 0 1)) (pkg-info (0 4)) - (let-alist - (1 0 1)) - (cl-lib - (0 3)) - (emacs - (24 1))) + (dash + (2 4 0))) "Modern on-the-fly syntax checking for GNU Emacs" tar]) (flx-ido . [(0 2) @@ -3116,9 +3162,9 @@ [(0 1 2) nil "A simple theme for Emacs." single]) (fixmee . - [(0 8 4) + [(0 8 6) ((button-lock - (1 0 0)) + (1 0 2)) (nav-flash (1 0 0)) (back-button @@ -3258,14 +3304,12 @@ (0))) "evil textobjects based on indentation" single]) (evil-escape . - [(1 6 0) + [(2 11) ((emacs (24)) (evil - (1 0 9)) - (key-chord - (0 6))) - "Customizable key sequence to escape from insert state and everything else." single]) + (1 0 9))) + "Escape from anything with a customizable key sequence" single]) (evil . [(1 0 8) ((undo-tree @@ -3397,15 +3441,13 @@ [(1 4 6) nil "Screen for Emacsen" single]) (elpy . - [(1 6 0) + [(1 7 1) ((company (0 8 2)) (find-file-in-project (3 3)) (highlight-indentation (0 5 0)) - (idomenu - (0 1)) (pyvenv (1 3)) (yasnippet @@ -3743,6 +3785,11 @@ (current-story . [(0 1 0) nil "Track and insert current Pivotal Tracker" single]) + (curl-for-url . + [(0 0 2) + ((noflet + (0 0 15))) + "use url-retrieve with curl doing the work" single]) (cups . [(0 1) nil "CUPS features for Emacs" single]) @@ -3762,7 +3809,7 @@ [(0 1 1) nil "Table component for Emacs Lisp" single]) (csharp-mode . - [(0 8 8) + [(0 8 9) nil "C# mode derived mode" tar]) (cryptol-mode . [(0 1 0) @@ -4070,11 +4117,11 @@ [(0 0 2) nil "Major mode for editing Citrus files" single]) (circe . - [(1 5) + [(1 6) ((lui - (1 5)) + (1 6)) (lcs - (1 5))) + (1 1))) "Client for IRC in Emacs" tar]) (cider . [(0 8 2) @@ -4137,8 +4184,11 @@ [(0 7) nil "helpful description of the arguments to C functions" single]) (button-lock . - [(1 0 0) + [(1 0 2) nil "Clickable text defined by regular expression" single]) + (buttercup . + [(1 0) + nil "Behavior-Driven Emacs Lisp Testing" tar]) (butler . [(0 2 0) ((deferred
new file mode 100644 --- /dev/null +++ b/elpa/json-mode-1.2.0/json-mode-autoloads.el @@ -0,0 +1,41 @@ +;;; json-mode-autoloads.el --- automatically extracted autoloads +;; +;;; Code: + + +;;;### (autoloads (json-mode json-mode-beautify-ordered json-mode-beautify) +;;;;;; "json-mode" "json-mode.el" (21797 19307 164820 295000)) +;;; Generated autoloads from json-mode.el + +(autoload 'json-mode-beautify "json-mode" "\ +Beautify / pretty-print from BEG to END, and optionally PRESERVE-KEY-ORDER. + +\(fn &optional PRESERVE-KEY-ORDER)" t nil) + +(autoload 'json-mode-beautify-ordered "json-mode" "\ +Beautify / pretty-print from BEG to END preserving key order. + +\(fn)" t nil) + +(autoload 'json-mode "json-mode" "\ +Major mode for editing JSON files + +\(fn)" t nil) + +(add-to-list 'auto-mode-alist '("\\.json$" . json-mode)) + +;;;*** + +;;;### (autoloads nil nil ("json-mode-pkg.el") (21797 19307 175675 +;;;;;; 579000)) + +;;;*** + +(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
new file mode 100644 --- /dev/null +++ b/elpa/json-mode-1.2.0/json-mode-pkg.el @@ -0,0 +1,1 @@ +(define-package "json-mode" "1.2.0" "Major mode for editing JSON files" (quote nil))
new file mode 100644 --- /dev/null +++ b/elpa/json-mode-1.2.0/json-mode.el @@ -0,0 +1,95 @@ +;;; json-mode.el --- Major mode for editing JSON files + +;; Copyright (C) 2011-2013 Josh Johnston + +;; Author: Josh Johnston +;; URL: https://github.com/joshwnj/json-mode +;; Version: 1.2.0 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;; extend the builtin js-mode's syntax highlighting + +;;; Code: + +(require 'js) +(require 'rx) + +(defconst json-mode-quoted-string-re + (rx (group (char ?\") + (zero-or-more (or (seq ?\\ ?\\) + (seq ?\\ ?\") + (seq ?\\ (not (any ?\" ?\\))) + (not (any ?\" ?\\)))) + (char ?\")))) +(defconst json-mode-quoted-key-re + (rx (group (char ?\") + (zero-or-more (or (seq ?\\ ?\\) + (seq ?\\ ?\") + (seq ?\\ (not (any ?\" ?\\))) + (not (any ?\" ?\\)))) + (char ?\")) + (zero-or-more blank) + ?\:)) +(defconst json-mode-number-re (rx (group (one-or-more digit) + (optional ?\. (one-or-more digit))))) +(defconst json-mode-keyword-re (rx (group (or "true" "false" "null")))) + +(defconst json-font-lock-keywords-1 + (list + (list json-mode-quoted-key-re 1 font-lock-keyword-face) + (list json-mode-quoted-string-re 1 font-lock-string-face) + (list json-mode-keyword-re 1 font-lock-constant-face) + (list json-mode-number-re 1 font-lock-constant-face) + ) + "Level one font lock.") + +(defconst json-mode-beautify-command-python2 + "python2 -c \"import sys,json,collections; data=json.loads(sys.stdin.read(),object_pairs_hook=collections.OrderedDict); print json.dumps(data,sort_keys=%s,indent=4,separators=(',',': ')).decode('unicode_escape').encode('utf8','replace')\"") +(defconst json-mode-beautify-command-python3 + "python3 -c \"import sys,json,codecs,collections; data=json.loads(sys.stdin.read(),object_pairs_hook=collections.OrderedDict); print((codecs.getdecoder('unicode_escape')(json.dumps(data,sort_keys=%s,indent=4,separators=(',',': '))))[0])\"") + +;;;###autoload +(defun json-mode-beautify (&optional preserve-key-order) + "Beautify / pretty-print from BEG to END, and optionally PRESERVE-KEY-ORDER." + (interactive "P") + (shell-command-on-region (if (use-region-p) (region-beginning) (point-min)) + (if (use-region-p) (region-end) (point-max)) + (concat (if (executable-find "env") "env " "") + (format (if (executable-find "python2") + json-mode-beautify-command-python2 + json-mode-beautify-command-python3) + (if preserve-key-order "False" "True"))) + (current-buffer) t)) + +;;;###autoload +(defun json-mode-beautify-ordered () + "Beautify / pretty-print from BEG to END preserving key order." + (interactive) + (json-mode-beautify 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))) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.json$" . json-mode)) + +(define-key json-mode-map (kbd "C-c C-f") 'json-mode-beautify) + +(provide 'json-mode) +;;; json-mode.el ends here