1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-23 18:47:57 +00:00

* 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.
This commit is contained in:
Stefan Monnier 2012-11-08 14:44:52 -05:00
parent b7432bb20f
commit be883b34f2
2 changed files with 29 additions and 13 deletions

View File

@ -1,3 +1,10 @@
2012-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
* progmodes/js.el (js--filling-paragraph): New var.
(c-forward-sws, c-backward-sws, c-beginning-of-macro): Advise.
(js-c-fill-paragraph): Prefer advice to cl-letf so the rebinding is
less sneaky.
2012-11-08 Julien Danjou <julien@danjou.info>
* progmodes/ruby-mode.el (auto-mode-alist): Add Rakefile in

View File

@ -1823,22 +1823,31 @@ nil."
;;; Filling
(defvar js--filling-paragraph nil)
;; 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'."
(interactive "*P")
;; FIXME: Such redefinitions are bad style. We should try and use some other
;; way to get the same result.
(cl-letf (((symbol-function 'c-forward-sws)
(lambda (&optional limit)
(js--forward-syntactic-ws limit)))
((symbol-function 'c-backward-sws)
(lambda (&optional limit)
(js--backward-syntactic-ws limit)))
((symbol-function 'c-beginning-of-macro)
(lambda (&optional limit)
(js--beginning-of-macro limit))))
(let ((fill-paragraph-function 'c-fill-paragraph))
(c-fill-paragraph justify))))
(let ((js--filling-paragraph t)
(fill-paragraph-function 'c-fill-paragraph))
(c-fill-paragraph justify)))
;;; Type database and Imenu