[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master ff349d0: * lisp/progmodes/js.el (js--fill-c-advice)
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master ff349d0: * lisp/progmodes/js.el (js--fill-c-advice): New function |
Date: |
Fri, 14 Sep 2018 10:23:43 -0400 (EDT) |
branch: master
commit ff349d021df40fd73ac1ead2ed1e376b214d07fd
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* 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.
---
lisp/progmodes/js.el | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index f30e591..3ce5af4 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',
;; FIXME: Such redefinitions are bad style. We should try and use some other
;; way to get the same result.
-(defadvice c-forward-sws (around js-fill-paragraph activate)
- (if js--filling-paragraph
- (setq ad-return-value (js--forward-syntactic-ws (ad-get-arg 0)))
- ad-do-it))
-
-(defadvice c-backward-sws (around js-fill-paragraph activate)
- (if js--filling-paragraph
- (setq ad-return-value (js--backward-syntactic-ws (ad-get-arg 0)))
- ad-do-it))
-
-(defadvice c-beginning-of-macro (around js-fill-paragraph activate)
- (if js--filling-paragraph
- (setq ad-return-value (js--beginning-of-macro (ad-get-arg 0)))
- ad-do-it))
-
-(defun js-c-fill-paragraph (&optional justify)
- "Fill the paragraph with `c-fill-paragraph'."
+(defun js--fill-c-advice (js-fun)
+ (lambda (orig-fun &rest args)
+ (if js--filling-paragraph
+ (funcall js-fun (car args))
+ (apply orig-fun args))))
+
+(advice-add 'c-forward-sws
+ :around (js--fill-c-advice #'js--forward-syntactic-ws))
+(advice-add 'c-backward-sws
+ :around (js--fill-c-advice #'js--backward-syntactic-ws))
+(advice-add 'c-beginning-of-macro
+ :around (js--fill-c-advice #'js--beginning-of-macro))
+
+(define-obsolete-function-alias 'js-c-fill-paragraph #'js-fill-paragraph
"27.1")
+(defun js-fill-paragraph (&optional justify)
+ "Fill the paragraph for Javascript code."
(interactive "*P")
(let ((js--filling-paragraph t)
(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."
;; Comments
(setq-local comment-start "// ")
(setq-local comment-end "")
- (setq-local fill-paragraph-function #'js-c-fill-paragraph)
+ (setq-local fill-paragraph-function #'js-fill-paragraph)
(setq-local normal-auto-fill-function #'js-do-auto-fill)
;; Parse cache
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master ff349d0: * lisp/progmodes/js.el (js--fill-c-advice): New function,
Stefan Monnier <=