From 029dd7e006c850883026be022ce09c7e0ac60d57 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Wed, 25 Jan 2012 23:24:55 +0400 Subject: [PATCH] Fix fill-paragraph behavior Closes #34 --- js2-mode.el | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/js2-mode.el b/js2-mode.el index 9b782ee01..115cbc188 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -10417,9 +10417,8 @@ If so, we don't ever want to use bounce-indent." (set (make-local-variable 'indent-region-function) #'js2-indent-region) ;; I tried an "improvement" to `c-fill-paragraph' that worked out badly - ;; on most platforms other than the one I originally wrote it on. So it's - ;; back to `c-fill-paragraph'. Still not perfect, though -- something to do - ;; with our binding of the RET key inside comments: short lines stay short. + ;; on most platforms other than the one I originally wrote it on. + ;; So it's back to `c-fill-paragraph'. (set (make-local-variable 'fill-paragraph-function) #'c-fill-paragraph) (set (make-local-variable 'before-save-hook) #'js2-before-save) @@ -10435,9 +10434,9 @@ If so, we don't ever want to use bounce-indent." (put 'js2-mode 'find-tag-default-function #'js2-mode-find-tag) ;; some variables needed by cc-engine for paragraph-fill, etc. - (setq c-buffer-is-cc-mode t - c-comment-prefix-regexp js2-comment-prefix-regexp + (setq c-comment-prefix-regexp js2-comment-prefix-regexp c-comment-start-regexp "/[*/]\\|\\s|" + c-line-comment-starter "//" c-paragraph-start js2-paragraph-start c-paragraph-separate "$" comment-start-skip js2-comment-start-skip @@ -10445,6 +10444,15 @@ If so, we don't ever want to use bounce-indent." c-syntactic-ws-end js2-syntactic-ws-end c-syntactic-eol js2-syntactic-eol) + (let ((c-buffer-is-cc-mode t)) + ;; Copied from `js-mode'. Also see Bug#6071. + (make-local-variable 'paragraph-start) + (make-local-variable 'paragraph-separate) + (make-local-variable 'paragraph-ignore-fill-prefix) + (make-local-variable 'adaptive-fill-mode) + (make-local-variable 'adaptive-fill-regexp) + (c-setup-paragraph-variables)) + (setq js2-default-externs (append js2-ecma-262-externs (if js2-include-browser-externs -- 2.39.2