]> code.delx.au - gnu-emacs-elpa/commitdiff
Fix fill-paragraph behavior
authorDmitry Gutov <dgutov@yandex.ru>
Wed, 25 Jan 2012 19:24:55 +0000 (23:24 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Wed, 25 Jan 2012 19:24:55 +0000 (23:24 +0400)
Closes #34

js2-mode.el

index 9b782ee016a268aa36c5396dc11ebe52e1b5e9d3..115cbc1887f90f775452bc2c4ad061b14f71eeff 100644 (file)
@@ -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