aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2018-09-14 10:23:39 -0400
committerStefan Monnier2018-09-14 10:23:39 -0400
commitff349d021df40fd73ac1ead2ed1e376b214d07fd (patch)
treead2c6db755fbca6c8d016bc7847b252926ee3aa0
parent383c9a253b2cd030674982046e23c3670543dc68 (diff)
downloademacs-ff349d021df40fd73ac1ead2ed1e376b214d07fd.tar.gz
emacs-ff349d021df40fd73ac1ead2ed1e376b214d07fd.zip
* lisp/progmodes/js.el (js--fill-c-advice): New function
(c-forward-sws, c-backward-sws, c-beginning-of-macro): Use it. (js-fill-paragraph): Rename from js-c-fill-paragraph.
-rw-r--r--lisp/progmodes/js.el35
1 files changed, 17 insertions, 18 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index f30e591b15a..3ce5af4c49b 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -2368,23 +2368,22 @@ i.e., customize JSX element indentation with `sgml-basic-offset',
2368 2368
2369;; FIXME: Such redefinitions are bad style. We should try and use some other 2369;; FIXME: Such redefinitions are bad style. We should try and use some other
2370;; way to get the same result. 2370;; way to get the same result.
2371(defadvice c-forward-sws (around js-fill-paragraph activate) 2371(defun js--fill-c-advice (js-fun)
2372 (if js--filling-paragraph 2372 (lambda (orig-fun &rest args)
2373 (setq ad-return-value (js--forward-syntactic-ws (ad-get-arg 0))) 2373 (if js--filling-paragraph
2374 ad-do-it)) 2374 (funcall js-fun (car args))
2375 2375 (apply orig-fun args))))
2376(defadvice c-backward-sws (around js-fill-paragraph activate) 2376
2377 (if js--filling-paragraph 2377(advice-add 'c-forward-sws
2378 (setq ad-return-value (js--backward-syntactic-ws (ad-get-arg 0))) 2378 :around (js--fill-c-advice #'js--forward-syntactic-ws))
2379 ad-do-it)) 2379(advice-add 'c-backward-sws
2380 2380 :around (js--fill-c-advice #'js--backward-syntactic-ws))
2381(defadvice c-beginning-of-macro (around js-fill-paragraph activate) 2381(advice-add 'c-beginning-of-macro
2382 (if js--filling-paragraph 2382 :around (js--fill-c-advice #'js--beginning-of-macro))
2383 (setq ad-return-value (js--beginning-of-macro (ad-get-arg 0))) 2383
2384 ad-do-it)) 2384(define-obsolete-function-alias 'js-c-fill-paragraph #'js-fill-paragraph "27.1")
2385 2385(defun js-fill-paragraph (&optional justify)
2386(defun js-c-fill-paragraph (&optional justify) 2386 "Fill the paragraph for Javascript code."
2387 "Fill the paragraph with `c-fill-paragraph'."
2388 (interactive "*P") 2387 (interactive "*P")
2389 (let ((js--filling-paragraph t) 2388 (let ((js--filling-paragraph t)
2390 (fill-paragraph-function #'c-fill-paragraph)) 2389 (fill-paragraph-function #'c-fill-paragraph))
@@ -3875,7 +3874,7 @@ If one hasn't been set, or if it's stale, prompt for a new one."
3875 ;; Comments 3874 ;; Comments
3876 (setq-local comment-start "// ") 3875 (setq-local comment-start "// ")
3877 (setq-local comment-end "") 3876 (setq-local comment-end "")
3878 (setq-local fill-paragraph-function #'js-c-fill-paragraph) 3877 (setq-local fill-paragraph-function #'js-fill-paragraph)
3879 (setq-local normal-auto-fill-function #'js-do-auto-fill) 3878 (setq-local normal-auto-fill-function #'js-do-auto-fill)
3880 3879
3881 ;; Parse cache 3880 ;; Parse cache