@@ -101,7 +101,8 @@ This function calls `json-mode--update-auto-mode' to change the
101
101
(char ?\" ))
102
102
(zero-or-more blank)
103
103
?\: ))
104
- (defconst json-mode-number-re (rx (group (one-or-more digit)
104
+ (defconst json-mode-number-re (rx (group (optional ?- )
105
+ (one-or-more digit)
105
106
(optional ?\. (one-or-more digit)))))
106
107
(defconst json-mode-keyword-re (rx (group (or " true" " false" " null" ))))
107
108
@@ -230,7 +231,7 @@ json font lock syntactic face function."
230
231
((setq symbol (bounds-of-thing-at-point 'symbol ))
231
232
(cond
232
233
((looking-at-p " null" ))
233
- ((save-excursion (skip-chars-backward " [0-9.]" ) (looking-at json-mode-number-re))
234
+ ((save-excursion (skip-chars-backward " [- 0-9.]" ) (looking-at json-mode-number-re))
234
235
(kill-region (match-beginning 0 ) (match-end 0 ))
235
236
(insert " null" ))
236
237
(t (kill-region (car symbol) (cdr symbol)) (insert " null" ))))
@@ -244,8 +245,8 @@ json font lock syntactic face function."
244
245
245
246
(defun json-increment-number-at-point (&optional delta )
246
247
" Add DELTA to the number at point; DELTA defaults to 1."
247
- (interactive )
248
- (when (save-excursion (skip-chars-backward " [0-9.]" ) (looking-at json-mode-number-re))
248
+ (interactive " P " )
249
+ (when (save-excursion (skip-chars-backward " [- 0-9.]" ) (looking-at json-mode-number-re))
249
250
(let ((num (+ (or delta 1 )
250
251
(string-to-number (buffer-substring-no-properties (match-beginning 0 ) (match-end 0 )))))
251
252
(pt (point )))
@@ -255,10 +256,10 @@ json font lock syntactic face function."
255
256
256
257
(define-key json-mode-map (kbd " C-c C-i" ) 'json-increment-number-at-point )
257
258
258
- (defun json-decrement-number-at-point ()
259
+ (defun json-decrement-number-at-point (&optional delta )
259
260
" Decrement the number at point."
260
- (interactive )
261
- (json-increment-number-at-point -1 ))
261
+ (interactive " P " )
262
+ (json-increment-number-at-point ( - ( or delta 1 )) ))
262
263
263
264
(define-key json-mode-map (kbd " C-c C-d" ) 'json-decrement-number-at-point )
264
265
0 commit comments