Skip to content

Commit

Permalink
Added better paragraph filling.
Browse files Browse the repository at this point in the history
Text fills better around Doxygen @param et al. and text in comments now
do auto-fill.

Fixes #5.
  • Loading branch information
arnested committed Jan 29, 2014
1 parent 65efa5b commit 5d45583
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion drupal-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,36 @@ Include path to the executable if it is not in your $PATH."
:type '(repeat symbol)
:group 'drupal)

(defcustom drupal-enable-auto-fill-mode t
"Whether to use `auto-fill-mode' Drupal PHP buffers.
Drupal mode will only do auto fill in comments (auto filling code
is not nice).
If `Yes' enable `auto-fill-mode' in Drupal PHP mode buffers.
If `No' don't enable `auto-fill-mode' in Drupal PHP mode buffers (`auto-fill-mode' can still be enabled by other settings)."
:type `(choice
:tag "Enable `auto-fill-mode'."
(const :tag "Yes" t)
(const :tag "No" nil))
:link '(variable-link comment-auto-fill-only-comments)
:group 'drupal)

(defcustom drupal-paragraph-separate "^[ \t]*\\(\\(/[/\\*]+\\)\\|\\(\\*+/\\)\\|\\(\\*?\\)\\|\\(\\*?[ \t]*@[[:alpha:]]+\\([ \t]+.*\\)?\\)\\)[ \t]*$"
"Regexp for beginning of a line that separates paragraphs.
In Drupal mode we extend the regular `paragraph-separate' so we
will get better filling in Doxygen comments."
:type 'regexp
:link '(variable-link paragraph-separate)
:group 'drupal)

(defcustom drupal-paragraph-start (default-value 'drupal-paragraph-separate)
"Regexp for beginning of a line that starts OR separates paragraphs.
In Drupal mode we extend the regular `paragraph-start' so we will
get better filling in Doxygen comments."
:type 'regexp
:link '(variable-link paragraph-start)
:group 'drupal)



(defvar drupal-version nil "Drupal version as auto detected.")
Expand Down Expand Up @@ -273,7 +303,16 @@ function arguments.")
;; Setup cc-mode style stuff.
(when (derived-mode-p 'c-mode)
(c-add-language 'drupal-mode 'c-mode)
(c-set-style "drupal"))))
(c-set-style "drupal"))

;; Use `auto-fill' only in comments.
(when drupal-enable-auto-fill-mode
(set (make-local-variable 'comment-auto-fill-only-comments) t)
(auto-fill-mode 1))

;; Improve filling in Doxygen comments.
(set (make-local-variable 'paragraph-separate) drupal-paragraph-separate)
(set (make-local-variable 'paragraph-start) drupal-paragraph-start)))



Expand Down

0 comments on commit 5d45583

Please sign in to comment.