@@ -163,6 +163,36 @@ Include path to the executable if it is not in your $PATH."
163163 :type '(repeat symbol)
164164 :group 'drupal )
165165
166+ (defcustom drupal-enable-auto-fill-mode t
167+ " Whether to use `auto-fill-mode' Drupal PHP buffers.
168+ Drupal mode will only do auto fill in comments (auto filling code
169+ is not nice).
170+
171+ If `Yes' enable `auto-fill-mode' in Drupal PHP mode buffers.
172+ If `No' don't enable `auto-fill-mode' in Drupal PHP mode buffers (`auto-fill-mode' can still be enabled by other settings)."
173+ :type `(choice
174+ :tag " Enable `auto-fill-mode' ."
175+ (const :tag " Yes" t )
176+ (const :tag " No" nil ))
177+ :link '(variable-link comment-auto-fill-only-comments)
178+ :group 'drupal )
179+
180+ (defcustom drupal-paragraph-separate " ^[ \t ]*\\ (\\ (/[/\\ *]+\\ )\\ |\\ (\\ *+/\\ )\\ |\\ (\\ *?\\ )\\ |\\ (\\ *?[ \t ]*@[[:alpha:]]+\\ ([ \t ]+.*\\ )?\\ )\\ )[ \t ]*$"
181+ " Regexp for beginning of a line that separates paragraphs.
182+ In Drupal mode we extend the regular `paragraph-separate' so we
183+ will get better filling in Doxygen comments."
184+ :type 'regexp
185+ :link '(variable-link paragraph-separate)
186+ :group 'drupal )
187+
188+ (defcustom drupal-paragraph-start (default-value 'drupal-paragraph-separate )
189+ " Regexp for beginning of a line that starts OR separates paragraphs.
190+ In Drupal mode we extend the regular `paragraph-start' so we will
191+ get better filling in Doxygen comments."
192+ :type 'regexp
193+ :link '(variable-link paragraph-start)
194+ :group 'drupal )
195+
166196
167197
168198(defvar drupal-version nil " Drupal version as auto detected." )
@@ -273,7 +303,16 @@ function arguments.")
273303 ; ; Setup cc-mode style stuff.
274304 (when (derived-mode-p 'c-mode )
275305 (c-add-language 'drupal-mode 'c-mode )
276- (c-set-style " drupal" ))))
306+ (c-set-style " drupal" ))
307+
308+ ; ; Use `auto-fill' only in comments.
309+ (when drupal-enable-auto-fill-mode
310+ (set (make-local-variable 'comment-auto-fill-only-comments ) t )
311+ (auto-fill-mode 1 ))
312+
313+ ; ; Improve filling in Doxygen comments.
314+ (set (make-local-variable 'paragraph-separate ) drupal-paragraph-separate)
315+ (set (make-local-variable 'paragraph-start ) drupal-paragraph-start)))
277316
278317
279318
0 commit comments