Closed
Description
Expected behavior
Given the following text in clojure-mode
, with point represented by |
:
(def my-example-variable
"It has a very long docstring. So long, in fact, that it wraps onto multiple lines! This is to demonstrate what happens when the docstring wraps over three lines.|"
nil)
Pressing M-q
should yield the following:
(def my-example-variable
"It has a very long docstring. So long, in fact, that it wraps onto
multiple lines! This is to demonstrate what happens when the
docstring wraps over three lines.|"
nil)
Actual behavior
The initial value of the variable is wrapped onto the same line as the docstring:
(def my-example-variable
"It has a very long docstring. So long, in fact, that it wraps onto
multiple lines! This is to demonstrate what happens when the
docstring wraps over three lines." nil)
Steps to reproduce the problem
Run emacs -Q
, install clojure-mode
, and open a Clojure file. Then see the "Expected behavior" section.
Environment & Version information
clojure-mode version information
clojure-mode (version 5.7.0-snapshot)
I am running revision 197298e of clojure-mode
using straight.el
.
Emacs version
GNU Emacs 25.2.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911))
Installed by brew cask install emacs
, running in the terminal.
Operating system
-/+:. raxod502@[redacted]
:++++. ----------------------------
/+++/. OS: OS X El Capitan 10.11.6 15G1510 x86_64
.:-::- .+/:-``.::- Model: MacBookPro11,3
.:/++++++/::::/++++++/:` Kernel: 15.6.0
.:///////////////////////:` Uptime: 39 days, 46 minutes
////////////////////////` Packages: 355
-+++++++++++++++++++++++` Shell: zsh 5.3.1
/++++++++++++++++++++++/ Resolution: 3008x1692@2x, 1440x900@2x
/sssssssssssssssssssssss. DE: Aqua
:ssssssssssssssssssssssss- WM: Quartz Compositor
osssssssssssssssssssssssso/` WM Theme: Blue
`syyyyyyyyyyyyyyyyyyyyyyyy+` Terminal: iTerm2
`ossssssssssssssssssssss/ Terminal Font: InputMono-Medium 14
:ooooooooooooooooooo+. CPU: Intel i7-4980HQ (8) @ 2.80GHz
`:+oo+/:-..-:/+o+/- GPU: Intel Iris Pro, NVIDIA GeForce GT 750M
Memory: 4322MiB / 16384MiB
Commentary
Filling works correctly for functions. I presume that one of regexes must be tweaked in clojure-fill-paragraph
, as the current ones apparently only recognize a vector as terminating the docstring.
(defun clojure-fill-paragraph (&optional justify)
"Like `fill-paragraph', but can handle Clojure docstrings.
If JUSTIFY is non-nil, justify as well as fill the paragraph."
(if (clojure-in-docstring-p)
(let ((paragraph-start
(concat paragraph-start
"\\|\\s-*\\([(:\"[]\\|~@\\|`(\\|#'(\\)"))
(paragraph-separate
(concat paragraph-separate "\\|\\s-*\".*[,\\.]$"))
(fill-column (or clojure-docstring-fill-column fill-column))
(fill-prefix (clojure-docstring-fill-prefix)))
(fill-paragraph justify))
(let ((paragraph-start (concat paragraph-start
"\\|\\s-*\\([(:\"[]\\|`(\\|#'(\\)"))
(paragraph-separate
(concat paragraph-separate "\\|\\s-*\".*[,\\.[]$")))
(or (fill-comment-paragraph justify)
(fill-paragraph justify))
;; Always return `t'
t)))
Metadata
Metadata
Assignees
Labels
No labels