emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r115492: * lisp/emacs-lisp/nadvice.el: Add `depth' p


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r115492: * lisp/emacs-lisp/nadvice.el: Add `depth' property to manage ordering.
Date: Thu, 12 Dec 2013 19:47:18 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115492
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Thu 2013-12-12 14:47:11 -0500
message:
  * 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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/emacs-lisp/debug.el       debug.el-20091113204419-o5vbwnq5f7feedwu-398
  lisp/emacs-lisp/elp.el         elp.el-20091113204419-o5vbwnq5f7feedwu-784
  lisp/emacs-lisp/nadvice.el     nadvice.el-20121015213644-851fdxs2vximj8nr-1
  lisp/emacs-lisp/trace.el       trace.el-20091113204419-o5vbwnq5f7feedwu-569
  lisp/iswitchb.el               
iswitchb.el-20091113204419-o5vbwnq5f7feedwu-1173
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-12-12 18:19:10 +0000
+++ b/lisp/ChangeLog    2013-12-12 19:47:11 +0000
@@ -1,3 +1,14 @@
+2013-12-12  Stefan Monnier  <address@hidden>
+
+       * emacs-lisp/nadvice.el: Add `depth' property to manage ordering.
+       (advice--make): Pay attention to `depth'.
+       (advice--make-1): Don't autoload commands eagerly.
+       * emacs-lisp/elp.el (elp-instrument-function):
+       * emacs-lisp/trace.el (trace-function-internal):
+       * emacs-lisp/debug.el (debug-on-entry): Keep them "first".
+
+       * iswitchb.el (iswitchb-mode): Don't belittle ido.
+
 2013-12-12  Eli Zaretskii  <address@hidden>
 
        * term/w32-win.el (w32-handle-dropped-file):
@@ -15,8 +26,8 @@
 
 2013-12-12  Nathan Trapuzzano  <address@hidden>  (tiny change)
 
-       * progmodes/python.el (python-indent-calculate-indentation): When
-       determining indentation, don't treat "return", "pass", etc., as
+       * progmodes/python.el (python-indent-calculate-indentation):
+       When determining indentation, don't treat "return", "pass", etc., as
        operators when they are just string constituents.  (Bug#15812)
 
 2013-12-12  Juri Linkov  <address@hidden>
@@ -56,7 +67,7 @@
 2013-12-11  Stefan Monnier  <address@hidden>
 
        * emacs-lisp/smie.el (smie-indent--hanging-p): Don't bother matching
-       comment-start-skip, since it fails when that uses submatch 1 
(bug#16041).
+       comment-start-skip, which fails when that uses submatch 1 (bug#16041).
 
        * emulation/cua-base.el (cua-paste): Add `delete-selection' property
        instead of deleting the selection "by hand" (bug#16098).
@@ -137,8 +148,8 @@
 
 2013-12-10  Teodor Zlatanov  <address@hidden>
 
-       * emacs-lisp/package.el (package-keyword-button-action): Remove
-       finder.el require dependency.
+       * emacs-lisp/package.el (package-keyword-button-action):
+       Remove finder.el require dependency.
 
 2013-12-09  Teodor Zlatanov  <address@hidden>
 
@@ -165,13 +176,13 @@
 
 2013-12-09  Cameron Desautels  <address@hidden>  (tiny change)
 
-       * progmodes/ruby-mode.el (ruby-forward-string): Document.  Handle
-       caret-delimited strings (Bug#16079).
+       * progmodes/ruby-mode.el (ruby-forward-string): Document.
+       Handle caret-delimited strings (Bug#16079).
 
 2013-12-09  Dmitry Gutov  <address@hidden>
 
-       * progmodes/ruby-mode.el (ruby-accurate-end-of-block): When
-       `ruby-use-smie' is t, use `smie-forward-sexp' instead of
+       * progmodes/ruby-mode.el (ruby-accurate-end-of-block):
+       When `ruby-use-smie' is t, use `smie-forward-sexp' instead of
        `ruby-parse-partial' (Bug#16078).
 
 2013-12-09  Leo Liu  <address@hidden>
@@ -186,8 +197,8 @@
        "default" is actually a key in an object literal.
        (js--same-line): New function.
        (js--multi-line-declaration-indentation): Use it.
-       (js--indent-in-array-comp, js--array-comp-indentation): New
-       functions.
+       (js--indent-in-array-comp, js--array-comp-indentation):
+       New functions.
        (js--proper-indentation): Use them, to handle array comprehension
        continuations.
 

=== modified file 'lisp/emacs-lisp/debug.el'
--- a/lisp/emacs-lisp/debug.el  2013-12-08 21:23:50 +0000
+++ b/lisp/emacs-lisp/debug.el  2013-12-12 19:47:11 +0000
@@ -798,7 +798,8 @@
                         (not (special-form-p symbol))))
                t nil nil (symbol-name fn)))
      (list (if (equal val "") fn (intern val)))))
-  (advice-add function :before #'debug--implement-debug-on-entry)
+  (advice-add function :before #'debug--implement-debug-on-entry
+              '((depth . -100)))
   function)
 
 (defun debug--function-list ()

=== modified file 'lisp/emacs-lisp/elp.el'
--- a/lisp/emacs-lisp/elp.el    2013-01-02 16:13:04 +0000
+++ b/lisp/emacs-lisp/elp.el    2013-12-12 19:47:11 +0000
@@ -251,7 +251,7 @@
     ;; Set the symbol's new profiling function definition to run
     ;; ELP wrapper.
     (advice-add funsym :around (elp--make-wrapper funsym)
-                `((name . ,elp--advice-name)))))
+                `((name . ,elp--advice-name) (depth . -99)))))
 
 (defun elp--instrumented-p (sym)
   (advice-member-p elp--advice-name sym))

=== modified file 'lisp/emacs-lisp/nadvice.el'
--- a/lisp/emacs-lisp/nadvice.el        2013-11-17 23:11:27 +0000
+++ b/lisp/emacs-lisp/nadvice.el        2013-12-12 19:47:11 +0000
@@ -129,8 +129,6 @@
   ;; TODO: make it so that interactive spec can be a constant which
   ;; dynamically checks the advice--car/cdr to do its job.
   ;; For that, advice-eval-interactive-spec needs to be more faithful.
-  ;; FIXME: The calls to interactive-form below load autoloaded functions
-  ;; too eagerly.
   (let ((fspec (cadr (interactive-form function))))
     (when (eq 'function (car-safe fspec)) ;; Macroexpanded lambda?
       (setq fspec (nth 1 fspec)))
@@ -147,19 +145,29 @@
          (apply #'make-byte-code 128 byte-code
                 (vector #'apply function main props) stack-depth
                 advice--docstring
-                (when (or (commandp function) (commandp main))
-                  (list (advice--make-interactive-form
-                         function main))))))
+                (and (or (commandp function) (commandp main))
+                    (not (and (symbolp main) ;; Don't autoload too eagerly!
+                              (autoloadp (symbol-function main))))
+                     (list (advice--make-interactive-form
+                            function main))))))
     (when adv-sig (puthash advice adv-sig advertised-signature-table))
     advice))
 
 (defun advice--make (where function main props)
   "Build a function value that adds FUNCTION to MAIN at WHERE.
 WHERE is a symbol to select an entry in `advice--where-alist'."
-  (let ((desc (assq where advice--where-alist)))
-    (unless desc (error "Unknown add-function location `%S'" where))
-    (advice--make-1 (nth 1 desc) (nth 2 desc)
-                    function main props)))
+  (let ((fd (or (cdr (assq 'depth props)) 0))
+        (md (if (advice--p main)
+                (or (cdr (assq 'depth (advice--props main))) 0))))
+    (if (and md (> fd md))
+        ;; `function' should go deeper.
+        (let ((rest (advice--make where function (advice--cdr main) props)))
+          (advice--make-1 (aref main 1) (aref main 3)
+                          (advice--car main) rest (advice--props main)))
+      (let ((desc (assq where advice--where-alist)))
+        (unless desc (error "Unknown add-function location `%S'" where))
+        (advice--make-1 (nth 1 desc) (nth 2 desc)
+                        function main props)))))
 
 (defun advice--member-p (function name definition)
   (let ((found nil))
@@ -216,8 +224,6 @@
 ;;;###autoload
 (defmacro add-function (where place function &optional props)
   ;; TODO:
-  ;; - provide some kind of control over ordering.  E.g. debug-on-entry, ELP
-  ;;   and tracing want to stay first.
   ;; - maybe let `where' specify some kind of predicate and use it
   ;;   to implement things like mode-local or eieio-defmethod.
   ;;   Of course, that only makes sense if the predicates of all advices can
@@ -245,6 +251,10 @@
 PROPS is an alist of additional properties, among which the following have
 a special meaning:
 - `name': a string or symbol.  It can be used to refer to this piece of advice.
+- `depth': a number indicating a preference w.r.t ordering.
+  The default depth is 0.  By convention, a depth of 100 means that
+  the advice  should be innermost (i.e. at the end of the list),
+  whereas a depth of -100 means that the advice should be outermost.
 
 If PLACE is a simple variable, only its global value will be affected.
 Use (local 'VAR) if you want to apply FUNCTION to VAR buffer-locally.

=== modified file 'lisp/emacs-lisp/trace.el'
--- a/lisp/emacs-lisp/trace.el  2013-12-11 14:27:15 +0000
+++ b/lisp/emacs-lisp/trace.el  2013-12-12 19:47:11 +0000
@@ -256,7 +256,7 @@
    function :around
    (trace-make-advice function (or buffer trace-buffer) background
                       (or context (lambda () "")))
-   `((name . ,trace-advice-name))))
+   `((name . ,trace-advice-name) (depth . -100))))
 
 (defun trace-is-traced (function)
   (advice-member-p trace-advice-name function))

=== modified file 'lisp/iswitchb.el'
--- a/lisp/iswitchb.el  2013-11-11 04:50:56 +0000
+++ b/lisp/iswitchb.el  2013-12-12 19:47:11 +0000
@@ -1427,7 +1427,8 @@
       (add-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)
     (remove-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)))
 
-(make-obsolete 'iswitchb-mode 'icomplete-mode "24.4")
+(make-obsolete 'iswitchb-mode
+               "use icomplete-mode or ido-mode instead" "24.4")
 
 (provide 'iswitchb)
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]