@@ -152,6 +152,7 @@ if that value is non-nil."
152
152
nil
153
153
(font-lock-mark-block-function . mark-defun)
154
154
(font-lock-syntactic-face-function . lisp-font-lock-syntactic-face-function)))
155
+
155
156
(run-mode-hooks 'clojure-mode-hook ))
156
157
157
158
(defun clojure-font-lock-def-at-point (point )
@@ -238,7 +239,7 @@ elements of a def* forms."
238
239
; ; Function declarations.
239
240
" \\ (n-?\\ |multi\\ |macro\\ |method\\ |"
240
241
; ; Variable declarations.
241
- " "
242
+ " struct \\ | "
242
243
" \\ )\\ )\\ >"
243
244
; ; Any whitespace
244
245
" [ \r\n\t ]*"
@@ -252,11 +253,12 @@ elements of a def* forms."
252
253
(,(concat
253
254
" (\\ (?:clojure/\\ )?"
254
255
(regexp-opt
255
- '(" cond" " for" " if" " loop" " let" " recur" " do" " binding" " with-meta" " when"
256
- " when-not" " delay" " lazy-cons" " ." " .." " ->" " and" " or" " locking"
256
+ '(" cond" " for" " loop" " let" " recur" " do" " binding" " with-meta"
257
+ " when" " when-not" " when-let" " when-first" " if" " if-let"
258
+ " delay" " lazy-cons" " ." " .." " ->" " and" " or" " locking"
257
259
" sync" " doseq" " dotimes" " import" " unimport" " in-ns" " refer"
258
260
" implement" " proxy" " time" " try" " catch" " finally"
259
- " doto" " with-open" " with-local-vars" ) t )
261
+ " doto" " with-open" " with-local-vars" " struct-map " ) t )
260
262
" \\ >" )
261
263
. 1 )
262
264
; ; (fn name? args ...)
@@ -327,7 +329,9 @@ This function also returns nil meaning don't specify the indentation."
327
329
; ; thing on that line has to be complete sexp since we are
328
330
; ; inside the innermost containing sexp.
329
331
(backward-prefix-chars )
330
- (current-column ))
332
+ (if (eq (char-after (point )) ?\[ )
333
+ (+ (current-column ) 2 ) ; ; this is probably inside a defn
334
+ (current-column )))
331
335
(let ((function (buffer-substring (point )
332
336
(progn (forward-sexp 1 ) (point ))))
333
337
(open-paren (elt state 1 ))
@@ -341,6 +345,7 @@ This function also returns nil meaning don't specify the indentation."
341
345
(> (length function) 3 )
342
346
(string-match " \\ `def" function)))
343
347
(lisp-indent-defform state indent-point))
348
+
344
349
((integerp method)
345
350
(lisp-indent-specform method state
346
351
indent-point normal-indent))
@@ -393,6 +398,22 @@ check for contextual indenting."
393
398
(error (setq depth clojure-max-backtracking)))))
394
399
indent))
395
400
401
+
402
+ ; ; (defun clojure-indent-defn (indent-point state)
403
+ ; ; "Indent by 2 if after a [] clause that's at the beginning of a
404
+ ; ; line"
405
+ ; ; (if (not (eq (char-after (elt state 2)) ?\[))
406
+ ; ; (lisp-indent-defform state indent-point)
407
+ ; ; (goto-char (elt state 2))
408
+ ; ; (beginning-of-line)
409
+ ; ; (skip-syntax-forward " ")
410
+ ; ; (if (= (point) (elt state 2))
411
+ ; ; (+ (current-column) 2)
412
+ ; ; (lisp-indent-defform state indent-point))))
413
+
414
+ ; ; (put 'defn 'clojure-indent-function 'clojure-indent-defn)
415
+ ; ; (put 'defmacro 'clojure-indent-function 'clojure-indent-defn)
416
+
396
417
; ; clojure backtracking indent is experimental and the format for these
397
418
; ; entries are subject to change
398
419
(put 'implement 'clojure-backtracking-indent '(4 (2 )))
@@ -406,6 +427,9 @@ check for contextual indenting."
406
427
(put 'if 'clojure-indent-function 1 )
407
428
(put 'let 'clojure-indent-function 1 )
408
429
(put 'loop 'clojure-indent-function 1 )
430
+ (put 'struct-map 'clojure-indent-function 1 )
431
+ (put 'assoc 'clojure-indent-function 1 )
432
+ (put 'fn 'clojure-indent-function 2 )
409
433
410
434
; ; macro indent (auto generated)
411
435
(put 'binding 'clojure-indent-function 1 )
@@ -417,11 +441,14 @@ check for contextual indenting."
417
441
(put 'implement 'clojure-indent-function 1 )
418
442
(put 'lazy-cons 'clojure-indent-function 1 )
419
443
(put 'let 'clojure-indent-function 1 )
444
+ (put 'when-let 'clojure-indent-function 2 )
445
+ (put 'if-let 'clojure-indent-function 2 )
420
446
(put 'locking 'clojure-indent-function 1 )
421
447
(put 'proxy 'clojure-indent-function 2 )
422
448
(put 'sync 'clojure-indent-function 1 )
423
449
(put 'when 'clojure-indent-function 1 )
424
450
(put 'when-first 'clojure-indent-function 2 )
451
+ (put 'when-let 'clojure-indent-function 2 )
425
452
(put 'when-not 'clojure-indent-function 1 )
426
453
(put 'with-local-vars 'clojure-indent-function 1 )
427
454
(put 'with-open 'clojure-indent-function 2 )
0 commit comments