From d6cf3334dbe3fe8582f2d71ec02ca9ffc1e76da1 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 26 Jul 2014 15:24:10 +0200 Subject: [PATCH 1/3] clojure-mode.el (clojure-fill-paragraph): Tiny fix * clojure-mode.el (clojure-fill-paragraph): Add a docstring. Fix filling of functions' parameters. --- clojure-mode.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clojure-mode.el b/clojure-mode.el index bdcd2133..0fc34f17 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -298,6 +298,7 @@ This only takes care of filling docstring correctly." (if (clojure-in-docstring-p) " ")) (defun clojure-fill-paragraph (&optional justify) + "Like `fill-paragraph' but handle Clojure docstrings." (if (clojure-in-docstring-p) (let ((paragraph-start (concat paragraph-start @@ -307,7 +308,13 @@ This only takes care of filling docstring correctly." (fill-column (or clojure-docstring-fill-column fill-column)) (fill-prefix " ")) (fill-paragraph justify)) - (lisp-fill-paragraph justify))) + (let ((paragraph-start (concat paragraph-start + "\\|\\s-*\\([(;:\"[]\\|`(\\|#'(\\)")) + (paragraph-separate + (concat paragraph-separate "\\|\\s-*\".*[,\\.[]$"))) + (fill-paragraph justify) + ;; Always return `t' + t))) (defun clojure-auto-fill-function () "Clojure auto-fill function." From 85b812512c1171d2c27013d3576f1d1dc31141ae Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 26 Jul 2014 15:50:33 +0200 Subject: [PATCH 2/3] clojure-mode.el: Cosmetic fixes * clojure-mode.el (clojure-font-lock-keywords) (clojure-mode-font-lock-regexp-groups, define-clojure-indent): Cosmetic fixes. --- clojure-mode.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clojure-mode.el b/clojure-mode.el index 0fc34f17..8dec5f63 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -454,7 +454,8 @@ Called by `imenu--generic-function'." "*print-dup*" "*print-length*" "*print-level*" "*print-meta*" "*print-readably*" "*read-eval*" "*source-path*" - "*use-context-classloader*" "*warn-on-reflection*") t) + "*use-context-classloader*" "*warn-on-reflection*") + t) "\\>") 0 font-lock-builtin-face) ;; Dynamic variables - *something* @@ -575,7 +576,8 @@ point) to check." ;; 3. we also highlight alternative ;; separarators |, and closing parens ) "[|()]" - "\\)\\)") bound t) + "\\)\\)") + bound t) (let ((face (get-text-property (1- (point)) 'face))) (when (and (or (and (listp face) (memq 'font-lock-string-face face)) @@ -757,7 +759,8 @@ Will upwards in an sexp to check for contextual indenting." (defmacro define-clojure-indent (&rest kvs) `(progn ,@(mapcar (lambda (x) `(put-clojure-indent - (quote ,(first x)) ,(second x))) kvs))) + (quote ,(first x)) ,(second x))) + kvs))) (defun add-custom-clojure-indents (name value) (custom-set-default name value) From 2b1a47ba3465c2ea4d862ac9485f8c4a5b147042 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 26 Jul 2014 16:31:49 +0200 Subject: [PATCH 3/3] Let TAB indent correctly in docstrings * clojure-mode.el (clojure-mode): Bind `indent-line-function' to the new function `clojure-indent-line'. (clojure-indent-line): New function to let TAB indent correctly in docstrings. --- clojure-mode.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/clojure-mode.el b/clojure-mode.el index 8dec5f63..0177935e 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -269,6 +269,7 @@ ENDP and DELIMITER." (setq-local normal-auto-fill-function 'clojure-auto-fill-function) (setq-local comment-start-skip "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *") + (setq-local indent-line-function 'clojure-indent-line) (setq-local lisp-indent-function 'clojure-indent-function) (when (< emacs-major-version 24) (setq-local forward-sexp-function 'clojure-forward-sexp)) @@ -618,6 +619,14 @@ since these are single objects this behavior is okay." (forward-sexp dir)) ; if so, jump over it (setq n (- n dir))))) +(defun clojure-indent-line () + "Indent current line as Clojure code." + (if (clojure-in-docstring-p) + (save-excursion + (beginning-of-line) + (when (looking-at "^\\s-*") (replace-match " "))) + (lisp-indent-line))) + (defun clojure-indent-function (indent-point state) "This function is the normal value of the variable `lisp-indent-function'. It is used when indenting a line within a function call, to see if the