[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r110840: * lisp/progmodes/js.el: Pref
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r110840: * lisp/progmodes/js.el: Prefer advice to cl-letf's sneaky rebinding. |
Date: |
Thu, 08 Nov 2012 14:44:52 -0500 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 110840
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Thu 2012-11-08 14:44:52 -0500
message:
* 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.
modified:
lisp/ChangeLog
lisp/progmodes/js.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-11-08 16:37:34 +0000
+++ b/lisp/ChangeLog 2012-11-08 19:44:52 +0000
@@ -1,3 +1,10 @@
+2012-11-08 Stefan Monnier <address@hidden>
+
+ * 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 <address@hidden>
* progmodes/ruby-mode.el (auto-mode-alist): Add Rakefile in
=== modified file 'lisp/progmodes/js.el'
--- a/lisp/progmodes/js.el 2012-08-22 05:35:38 +0000
+++ b/lisp/progmodes/js.el 2012-11-08 19:44:52 +0000
@@ -1823,22 +1823,31 @@
;;; 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r110840: * lisp/progmodes/js.el: Prefer advice to cl-letf's sneaky rebinding.,
Stefan Monnier <=