From 0df861cbc92c8fed236228fbd4dae2958b2dc447 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 18 May 2021 14:20:32 +1200 Subject: [PATCH 1/5] Custom group name should not contain the -mode suffix --- json-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json-mode.el b/json-mode.el index 5d90fa7..3704418 100644 --- a/json-mode.el +++ b/json-mode.el @@ -30,7 +30,7 @@ (require 'rx) (require 'json-snatcher) -(defgroup json-mode '() +(defgroup json '() "Major mode for editing JSON files." :group 'js) @@ -72,7 +72,7 @@ Return the new `auto-mode-alist' entry" Note however that custom `json-mode' entries in `auto-mode-alist' won’t be affected." - :group 'json-mode + :group 'json :type '(repeat string) :set (lambda (symbol value) "Update SYMBOL with a new regexp made from VALUE. From 3015fbf92fa95e69ada241954b31419a0893ccfb Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 18 May 2021 14:24:28 +1200 Subject: [PATCH 2/5] Don't use key sequence reserved for user customisations See https://www.gnu.org/software/emacs/manual/html_node/elisp/Coding-Conventions.html --- json-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json-mode.el b/json-mode.el index 3704418..774aedd 100644 --- a/json-mode.el +++ b/json-mode.el @@ -179,9 +179,9 @@ json font lock syntactic face function." (defun json-mode-kill-path () "Save JSON path to object at point to kill ring." (interactive) - (kill-new (jsons-print-path))) + (kill-new (jsons-print-path))) -(define-key json-mode-map (kbd "C-c P") 'json-mode-kill-path) +(define-key json-mode-map (kbd "C-c C-k") 'json-mode-kill-path) ;;;###autoload (defun json-mode-beautify (begin end) From e6bbab14e6ae344dfbaec8583b453f94530a1978 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 18 May 2021 14:31:18 +1200 Subject: [PATCH 3/5] font-lock-keywords is always buffer-local --- json-mode.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/json-mode.el b/json-mode.el index 774aedd..8161100 100644 --- a/json-mode.el +++ b/json-mode.el @@ -153,10 +153,10 @@ json font lock syntactic face function." (define-derived-mode json-mode javascript-mode "JSON" "Major mode for editing JSON files" :syntax-table json-mode-syntax-table - (set (make-local-variable 'font-lock-defaults) - '(json-font-lock-keywords-1 - nil nil nil nil - (font-lock-syntactic-face-function . json-mode--syntactic-face)))) + (setq font-lock-defaults + '(json-font-lock-keywords-1 + nil nil nil nil + (font-lock-syntactic-face-function . json-mode--syntactic-face)))) ;;;###autoload (define-derived-mode jsonc-mode json-mode "JSONC" From 9a3570d32bba418dab335bd2357f95ecc45c1759 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 22 May 2022 12:26:33 +0200 Subject: [PATCH 4/5] Fix package-lint issues --- json-mode.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/json-mode.el b/json-mode.el index 8161100..1aa6527 100644 --- a/json-mode.el +++ b/json-mode.el @@ -1,4 +1,4 @@ -;;; json-mode.el --- Major mode for editing JSON files. +;;; json-mode.el --- Major mode for editing JSON files ;; Copyright (C) 2011-2014 Josh Johnston @@ -63,11 +63,9 @@ Return the new `auto-mode-alist' entry" (defvar json-mode--auto-mode-entry) ;;;###autoload -(defcustom json-mode-auto-mode-list '( - ".babelrc" +(defcustom json-mode-auto-mode-list '(".babelrc" ".bowerrc" - "composer.lock" - ) + "composer.lock") "List of filenames for the JSON entry of `auto-mode-alist'. Note however that custom `json-mode' entries in `auto-mode-alist' @@ -162,6 +160,7 @@ json font lock syntactic face function." (define-derived-mode jsonc-mode json-mode "JSONC" "Major mode for editing JSON files with comments" :syntax-table jsonc-mode-syntax-table) + (setq font-lock-defaults '(json-font-lock-keywords-1 t)) ;; Well formatted JSON files almost always begin with “{” or “[”. ;;;###autoload From 6f34dca3402bb1ce06f6ce0fdd042429d513e91c Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Sun, 22 May 2022 12:31:25 +0200 Subject: [PATCH 5/5] More checkdoc fixes --- json-mode.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/json-mode.el b/json-mode.el index 1aa6527..0171559 100644 --- a/json-mode.el +++ b/json-mode.el @@ -149,7 +149,7 @@ json font lock syntactic face function." ;;;###autoload (define-derived-mode json-mode javascript-mode "JSON" - "Major mode for editing JSON files" + "Major mode for editing JSON files." :syntax-table json-mode-syntax-table (setq font-lock-defaults '(json-font-lock-keywords-1 @@ -158,7 +158,7 @@ json font lock syntactic face function." ;;;###autoload (define-derived-mode jsonc-mode json-mode "JSONC" - "Major mode for editing JSON files with comments" + "Major mode for editing JSON files with comments." :syntax-table jsonc-mode-syntax-table) (setq font-lock-defaults '(json-font-lock-keywords-1 t)) @@ -184,7 +184,7 @@ json font lock syntactic face function." ;;;###autoload (defun json-mode-beautify (begin end) - "Beautify / pretty-print the active region (or the entire buffer if no active region)." + "Beautify/pretty-print from BEGIN to END (or the entire buffer if no active region)." (interactive "r") (unless (use-region-p) (setq begin (point-min)