aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-12-12 14:47:11 -0500
committerStefan Monnier2013-12-12 14:47:11 -0500
commitcb3a1380602b81aebf2217a2800ae1c326cb263b (patch)
treec75295a81d67e7f57e0c4dadc45b7492f1f1a0ca
parent4618713ae48aac51c6f1a2474cc981f32c2bbede (diff)
downloademacs-cb3a1380602b81aebf2217a2800ae1c326cb263b.tar.gz
emacs-cb3a1380602b81aebf2217a2800ae1c326cb263b.zip
* lisp/emacs-lisp/nadvice.el: Add `depth' property to manage ordering.
(advice--make): Pay attention to `depth'. (advice--make-1): Don't autoload commands eagerly. * lisp/emacs-lisp/elp.el (elp-instrument-function): * lisp/emacs-lisp/trace.el (trace-function-internal): * lisp/emacs-lisp/debug.el (debug-on-entry): Keep them "first". * lisp/iswitchb.el (iswitchb-mode): Don't belittle ido.
-rw-r--r--lisp/ChangeLog33
-rw-r--r--lisp/emacs-lisp/debug.el3
-rw-r--r--lisp/emacs-lisp/elp.el2
-rw-r--r--lisp/emacs-lisp/nadvice.el32
-rw-r--r--lisp/emacs-lisp/trace.el2
-rw-r--r--lisp/iswitchb.el3
6 files changed, 49 insertions, 26 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c761bce7518..59fe5fff0b8 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12013-12-12 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/nadvice.el: Add `depth' property to manage ordering.
4 (advice--make): Pay attention to `depth'.
5 (advice--make-1): Don't autoload commands eagerly.
6 * emacs-lisp/elp.el (elp-instrument-function):
7 * emacs-lisp/trace.el (trace-function-internal):
8 * emacs-lisp/debug.el (debug-on-entry): Keep them "first".
9
10 * iswitchb.el (iswitchb-mode): Don't belittle ido.
11
12013-12-12 Eli Zaretskii <eliz@gnu.org> 122013-12-12 Eli Zaretskii <eliz@gnu.org>
2 13
3 * term/w32-win.el (w32-handle-dropped-file): 14 * term/w32-win.el (w32-handle-dropped-file):
@@ -15,8 +26,8 @@
15 26
162013-12-12 Nathan Trapuzzano <nbtrap@nbtrap.com> (tiny change) 272013-12-12 Nathan Trapuzzano <nbtrap@nbtrap.com> (tiny change)
17 28
18 * progmodes/python.el (python-indent-calculate-indentation): When 29 * progmodes/python.el (python-indent-calculate-indentation):
19 determining indentation, don't treat "return", "pass", etc., as 30 When determining indentation, don't treat "return", "pass", etc., as
20 operators when they are just string constituents. (Bug#15812) 31 operators when they are just string constituents. (Bug#15812)
21 32
222013-12-12 Juri Linkov <juri@jurta.org> 332013-12-12 Juri Linkov <juri@jurta.org>
@@ -56,7 +67,7 @@
562013-12-11 Stefan Monnier <monnier@iro.umontreal.ca> 672013-12-11 Stefan Monnier <monnier@iro.umontreal.ca>
57 68
58 * emacs-lisp/smie.el (smie-indent--hanging-p): Don't bother matching 69 * emacs-lisp/smie.el (smie-indent--hanging-p): Don't bother matching
59 comment-start-skip, since it fails when that uses submatch 1 (bug#16041). 70 comment-start-skip, which fails when that uses submatch 1 (bug#16041).
60 71
61 * emulation/cua-base.el (cua-paste): Add `delete-selection' property 72 * emulation/cua-base.el (cua-paste): Add `delete-selection' property
62 instead of deleting the selection "by hand" (bug#16098). 73 instead of deleting the selection "by hand" (bug#16098).
@@ -137,8 +148,8 @@
137 148
1382013-12-10 Teodor Zlatanov <tzz@lifelogs.com> 1492013-12-10 Teodor Zlatanov <tzz@lifelogs.com>
139 150
140 * emacs-lisp/package.el (package-keyword-button-action): Remove 151 * emacs-lisp/package.el (package-keyword-button-action):
141 finder.el require dependency. 152 Remove finder.el require dependency.
142 153
1432013-12-09 Teodor Zlatanov <tzz@lifelogs.com> 1542013-12-09 Teodor Zlatanov <tzz@lifelogs.com>
144 155
@@ -165,13 +176,13 @@
165 176
1662013-12-09 Cameron Desautels <camdez@gmail.com> (tiny change) 1772013-12-09 Cameron Desautels <camdez@gmail.com> (tiny change)
167 178
168 * progmodes/ruby-mode.el (ruby-forward-string): Document. Handle 179 * progmodes/ruby-mode.el (ruby-forward-string): Document.
169 caret-delimited strings (Bug#16079). 180 Handle caret-delimited strings (Bug#16079).
170 181
1712013-12-09 Dmitry Gutov <dgutov@yandex.ru> 1822013-12-09 Dmitry Gutov <dgutov@yandex.ru>
172 183
173 * progmodes/ruby-mode.el (ruby-accurate-end-of-block): When 184 * progmodes/ruby-mode.el (ruby-accurate-end-of-block):
174 `ruby-use-smie' is t, use `smie-forward-sexp' instead of 185 When `ruby-use-smie' is t, use `smie-forward-sexp' instead of
175 `ruby-parse-partial' (Bug#16078). 186 `ruby-parse-partial' (Bug#16078).
176 187
1772013-12-09 Leo Liu <sdl.web@gmail.com> 1882013-12-09 Leo Liu <sdl.web@gmail.com>
@@ -186,8 +197,8 @@
186 "default" is actually a key in an object literal. 197 "default" is actually a key in an object literal.
187 (js--same-line): New function. 198 (js--same-line): New function.
188 (js--multi-line-declaration-indentation): Use it. 199 (js--multi-line-declaration-indentation): Use it.
189 (js--indent-in-array-comp, js--array-comp-indentation): New 200 (js--indent-in-array-comp, js--array-comp-indentation):
190 functions. 201 New functions.
191 (js--proper-indentation): Use them, to handle array comprehension 202 (js--proper-indentation): Use them, to handle array comprehension
192 continuations. 203 continuations.
193 204
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index dbd0f092446..77abbc96d2d 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -798,7 +798,8 @@ Redefining FUNCTION also cancels it."
798 (not (special-form-p symbol)))) 798 (not (special-form-p symbol))))
799 t nil nil (symbol-name fn))) 799 t nil nil (symbol-name fn)))
800 (list (if (equal val "") fn (intern val))))) 800 (list (if (equal val "") fn (intern val)))))
801 (advice-add function :before #'debug--implement-debug-on-entry) 801 (advice-add function :before #'debug--implement-debug-on-entry
802 '((depth . -100)))
802 function) 803 function)
803 804
804(defun debug--function-list () 805(defun debug--function-list ()
diff --git a/lisp/emacs-lisp/elp.el b/lisp/emacs-lisp/elp.el
index f1321eb4e6d..1187169b034 100644
--- a/lisp/emacs-lisp/elp.el
+++ b/lisp/emacs-lisp/elp.el
@@ -251,7 +251,7 @@ FUNSYM must be a symbol of a defined function."
251 ;; Set the symbol's new profiling function definition to run 251 ;; Set the symbol's new profiling function definition to run
252 ;; ELP wrapper. 252 ;; ELP wrapper.
253 (advice-add funsym :around (elp--make-wrapper funsym) 253 (advice-add funsym :around (elp--make-wrapper funsym)
254 `((name . ,elp--advice-name))))) 254 `((name . ,elp--advice-name) (depth . -99)))))
255 255
256(defun elp--instrumented-p (sym) 256(defun elp--instrumented-p (sym)
257 (advice-member-p elp--advice-name sym)) 257 (advice-member-p elp--advice-name sym))
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
index 0352164caf5..9f539338b59 100644
--- a/lisp/emacs-lisp/nadvice.el
+++ b/lisp/emacs-lisp/nadvice.el
@@ -129,8 +129,6 @@ Each element has the form (WHERE BYTECODE STACK) where:
129 ;; TODO: make it so that interactive spec can be a constant which 129 ;; TODO: make it so that interactive spec can be a constant which
130 ;; dynamically checks the advice--car/cdr to do its job. 130 ;; dynamically checks the advice--car/cdr to do its job.
131 ;; For that, advice-eval-interactive-spec needs to be more faithful. 131 ;; For that, advice-eval-interactive-spec needs to be more faithful.
132 ;; FIXME: The calls to interactive-form below load autoloaded functions
133 ;; too eagerly.
134 (let ((fspec (cadr (interactive-form function)))) 132 (let ((fspec (cadr (interactive-form function))))
135 (when (eq 'function (car-safe fspec)) ;; Macroexpanded lambda? 133 (when (eq 'function (car-safe fspec)) ;; Macroexpanded lambda?
136 (setq fspec (nth 1 fspec))) 134 (setq fspec (nth 1 fspec)))
@@ -147,19 +145,29 @@ Each element has the form (WHERE BYTECODE STACK) where:
147 (apply #'make-byte-code 128 byte-code 145 (apply #'make-byte-code 128 byte-code
148 (vector #'apply function main props) stack-depth 146 (vector #'apply function main props) stack-depth
149 advice--docstring 147 advice--docstring
150 (when (or (commandp function) (commandp main)) 148 (and (or (commandp function) (commandp main))
151 (list (advice--make-interactive-form 149 (not (and (symbolp main) ;; Don't autoload too eagerly!
152 function main)))))) 150 (autoloadp (symbol-function main))))
151 (list (advice--make-interactive-form
152 function main))))))
153 (when adv-sig (puthash advice adv-sig advertised-signature-table)) 153 (when adv-sig (puthash advice adv-sig advertised-signature-table))
154 advice)) 154 advice))
155 155
156(defun advice--make (where function main props) 156(defun advice--make (where function main props)
157 "Build a function value that adds FUNCTION to MAIN at WHERE. 157 "Build a function value that adds FUNCTION to MAIN at WHERE.
158WHERE is a symbol to select an entry in `advice--where-alist'." 158WHERE is a symbol to select an entry in `advice--where-alist'."
159 (let ((desc (assq where advice--where-alist))) 159 (let ((fd (or (cdr (assq 'depth props)) 0))
160 (unless desc (error "Unknown add-function location `%S'" where)) 160 (md (if (advice--p main)
161 (advice--make-1 (nth 1 desc) (nth 2 desc) 161 (or (cdr (assq 'depth (advice--props main))) 0))))
162 function main props))) 162 (if (and md (> fd md))
163 ;; `function' should go deeper.
164 (let ((rest (advice--make where function (advice--cdr main) props)))
165 (advice--make-1 (aref main 1) (aref main 3)
166 (advice--car main) rest (advice--props main)))
167 (let ((desc (assq where advice--where-alist)))
168 (unless desc (error "Unknown add-function location `%S'" where))
169 (advice--make-1 (nth 1 desc) (nth 2 desc)
170 function main props)))))
163 171
164(defun advice--member-p (function name definition) 172(defun advice--member-p (function name definition)
165 (let ((found nil)) 173 (let ((found nil))
@@ -216,8 +224,6 @@ different, but `function-equal' will hopefully ignore those differences.")
216;;;###autoload 224;;;###autoload
217(defmacro add-function (where place function &optional props) 225(defmacro add-function (where place function &optional props)
218 ;; TODO: 226 ;; TODO:
219 ;; - provide some kind of control over ordering. E.g. debug-on-entry, ELP
220 ;; and tracing want to stay first.
221 ;; - maybe let `where' specify some kind of predicate and use it 227 ;; - maybe let `where' specify some kind of predicate and use it
222 ;; to implement things like mode-local or eieio-defmethod. 228 ;; to implement things like mode-local or eieio-defmethod.
223 ;; Of course, that only makes sense if the predicates of all advices can 229 ;; Of course, that only makes sense if the predicates of all advices can
@@ -245,6 +251,10 @@ If FUNCTION was already added, do nothing.
245PROPS is an alist of additional properties, among which the following have 251PROPS is an alist of additional properties, among which the following have
246a special meaning: 252a special meaning:
247- `name': a string or symbol. It can be used to refer to this piece of advice. 253- `name': a string or symbol. It can be used to refer to this piece of advice.
254- `depth': a number indicating a preference w.r.t ordering.
255 The default depth is 0. By convention, a depth of 100 means that
256 the advice should be innermost (i.e. at the end of the list),
257 whereas a depth of -100 means that the advice should be outermost.
248 258
249If PLACE is a simple variable, only its global value will be affected. 259If PLACE is a simple variable, only its global value will be affected.
250Use (local 'VAR) if you want to apply FUNCTION to VAR buffer-locally. 260Use (local 'VAR) if you want to apply FUNCTION to VAR buffer-locally.
diff --git a/lisp/emacs-lisp/trace.el b/lisp/emacs-lisp/trace.el
index 3a2c44a8da6..cbbfd268445 100644
--- a/lisp/emacs-lisp/trace.el
+++ b/lisp/emacs-lisp/trace.el
@@ -256,7 +256,7 @@ be printed along with the arguments in the trace."
256 function :around 256 function :around
257 (trace-make-advice function (or buffer trace-buffer) background 257 (trace-make-advice function (or buffer trace-buffer) background
258 (or context (lambda () ""))) 258 (or context (lambda () "")))
259 `((name . ,trace-advice-name)))) 259 `((name . ,trace-advice-name) (depth . -100))))
260 260
261(defun trace-is-traced (function) 261(defun trace-is-traced (function)
262 (advice-member-p trace-advice-name function)) 262 (advice-member-p trace-advice-name function))
diff --git a/lisp/iswitchb.el b/lisp/iswitchb.el
index 796420a2ede..b802e7418d7 100644
--- a/lisp/iswitchb.el
+++ b/lisp/iswitchb.el
@@ -1427,7 +1427,8 @@ between buffers using substrings. See `iswitchb' for details."
1427 (add-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup) 1427 (add-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)
1428 (remove-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup))) 1428 (remove-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)))
1429 1429
1430(make-obsolete 'iswitchb-mode 'icomplete-mode "24.4") 1430(make-obsolete 'iswitchb-mode
1431 "use icomplete-mode or ido-mode instead" "24.4")
1431 1432
1432(provide 'iswitchb) 1433(provide 'iswitchb)
1433 1434