Skip to content

Commit b175798

Browse files
committed
Add function to apply fill-region in doc strings
This commit adds a function that helps one to keep documentation strings under `fill-column` columns. For example, consider the following doc strings: ```elixir @moduledoc """ This is module documentation with a line that is waaaaayyy to long to be read. It's pretty bad when lines get wrapped in your editor or when you have to scroll horizontally to be able to see it well. Gosh, can Emacs relieve me of the pain of keeping documentation columns straight?? """ @doc """ This is module documentation with a line that is waaaaayyy to long to be read. It's pretty bad when lines get wrapped in your editor or when you have to scroll horizontally to be able to see it well. Gosh, can Emacs relieve me of the pain of keeping documentation columns straight?? """ ``` After calling `elixir-mode-fill-doc-string` the result would be: ```elixir @moduledoc """ This is module documentation with a line that is waaaaayyy to long to be read. It's pretty bad when lines get wrapped in your editor or when you have to scroll horizontally to be able to see it well. Gosh, can Emacs relieve me of the pain of keeping documentation columns straight?? """ @doc """ This is module documentation with a line that is waaaaayyy to long to be read. It's pretty bad when lines get wrapped in your editor or when you have to scroll horizontally to be able to see it well. Gosh, can Emacs relieve me of the pain of keeping documentation columns straight?? """ ```
1 parent 9564992 commit b175798

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

elixir-mode.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,17 @@ just return nil."
505505
(let* ((output (elixir-mode--execute-elixir-with-code-string-to-quoted string)))
506506
(elixir-quoted--initialize-buffer output)))
507507

508+
(defun elixir-mode-fill-doc-string ()
509+
(interactive)
510+
(save-excursion
511+
(re-search-backward "@\\(?:module\\)?doc +\"\"\"" nil t)
512+
(re-search-forward "\"\"\"" nil t)
513+
(set-mark (point))
514+
(re-search-forward "\"\"\"" nil t)
515+
(re-search-backward "^ *\"\"\"" nil t)
516+
(backward-char)
517+
(fill-region (point) (mark))))
518+
508519
(defun elixir-mode-eval-on-region (beg end)
509520
"Evaluate the Elixir code on the marked region.
510521
Argument BEG Start of the region.

0 commit comments

Comments
 (0)