aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-11-08 14:44:52 -0500
committerStefan Monnier2012-11-08 14:44:52 -0500
commitbe883b34f2c2c15681c1aec28aae0811807c64d3 (patch)
tree811e91576dccd17c94d0cc1b30844746807eaeae
parentb7432bb20f48902994bee522bea15acdb0c0e209 (diff)
downloademacs-be883b34f2c2c15681c1aec28aae0811807c64d3.tar.gz
emacs-be883b34f2c2c15681c1aec28aae0811807c64d3.zip
* lisp/progmodes/js.el: Prefer advice to cl-letf's sneaky rebinding.
(c-forward-sws, c-backward-sws, c-beginning-of-macro): Advise. (js--filling-paragraph): New var. (js-c-fill-paragraph): Bind it instead of letf-ing the functions.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/js.el35
2 files changed, 29 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e820dd5ce7f..fc699759d4d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12012-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/js.el (js--filling-paragraph): New var.
4 (c-forward-sws, c-backward-sws, c-beginning-of-macro): Advise.
5 (js-c-fill-paragraph): Prefer advice to cl-letf so the rebinding is
6 less sneaky.
7
12012-11-08 Julien Danjou <julien@danjou.info> 82012-11-08 Julien Danjou <julien@danjou.info>
2 9
3 * progmodes/ruby-mode.el (auto-mode-alist): Add Rakefile in 10 * progmodes/ruby-mode.el (auto-mode-alist): Add Rakefile in
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index d954cd53e0a..33ef7607671 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1823,22 +1823,31 @@ nil."
1823 1823
1824;;; Filling 1824;;; Filling
1825 1825
1826(defvar js--filling-paragraph nil)
1827
1828;; FIXME: Such redefinitions are bad style. We should try and use some other
1829;; way to get the same result.
1830(defadvice c-forward-sws (around js-fill-paragraph activate)
1831 (if js--filling-paragraph
1832 (setq ad-return-value (js--forward-syntactic-ws (ad-get-arg 0)))
1833 ad-do-it))
1834
1835(defadvice c-backward-sws (around js-fill-paragraph activate)
1836 (if js--filling-paragraph
1837 (setq ad-return-value (js--backward-syntactic-ws (ad-get-arg 0)))
1838 ad-do-it))
1839
1840(defadvice c-beginning-of-macro (around js-fill-paragraph activate)
1841 (if js--filling-paragraph
1842 (setq ad-return-value (js--beginning-of-macro (ad-get-arg 0)))
1843 ad-do-it))
1844
1826(defun js-c-fill-paragraph (&optional justify) 1845(defun js-c-fill-paragraph (&optional justify)
1827 "Fill the paragraph with `c-fill-paragraph'." 1846 "Fill the paragraph with `c-fill-paragraph'."
1828 (interactive "*P") 1847 (interactive "*P")
1829 ;; FIXME: Such redefinitions are bad style. We should try and use some other 1848 (let ((js--filling-paragraph t)
1830 ;; way to get the same result. 1849 (fill-paragraph-function 'c-fill-paragraph))
1831 (cl-letf (((symbol-function 'c-forward-sws) 1850 (c-fill-paragraph justify)))
1832 (lambda (&optional limit)
1833 (js--forward-syntactic-ws limit)))
1834 ((symbol-function 'c-backward-sws)
1835 (lambda (&optional limit)
1836 (js--backward-syntactic-ws limit)))
1837 ((symbol-function 'c-beginning-of-macro)
1838 (lambda (&optional limit)
1839 (js--beginning-of-macro limit))))
1840 (let ((fill-paragraph-function 'c-fill-paragraph))
1841 (c-fill-paragraph justify))))
1842 1851
1843;;; Type database and Imenu 1852;;; Type database and Imenu
1844 1853