emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r114413: * lisp/subr.el (internal--call-interactivel


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r114413: * lisp/subr.el (internal--call-interactively): New const.
Date: Fri, 20 Sep 2013 19:59:51 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114413
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3984
author: Ryan <address@hidden>
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Fri 2013-09-20 15:59:42 -0400
message:
  * lisp/subr.el (internal--call-interactively): New const.
  (called-interactively-p): Use it.
  * test/automated/advice-tests.el (advice-test-called-interactively-p-around)
  (advice-test-called-interactively-p-filter-args)
  (advice-test-called-interactively-p-around): New tests.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/subr.el                   subr.el-20091113204419-o5vbwnq5f7feedwu-151
  test/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-8588
  test/automated/advice-tests.el advice.el-20121111003311-i96f8i1au0zeaju7-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-09-20 05:39:53 +0000
+++ b/lisp/ChangeLog    2013-09-20 19:59:42 +0000
@@ -1,3 +1,8 @@
+2013-09-20  Stefan Monnier  <address@hidden>
+
+       * subr.el (internal--call-interactively): New const.
+       (called-interactively-p): Use it (bug#3984).
+
 2013-09-20  Xue Fuqiao  <address@hidden>
 
        * vc/pcvs.el (cvs-mode-ignore):

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2013-09-18 03:50:18 +0000
+++ b/lisp/subr.el      2013-09-20 19:59:42 +0000
@@ -4246,6 +4246,8 @@
 if those frames don't seem special and otherwise, it should return
 the number of frames to skip (minus 1).")
 
+(defconst internal--call-interactively (symbol-function 'call-interactively))
+
 (defun called-interactively-p (&optional kind)
   "Return t if the containing function was called by `call-interactively'.
 If KIND is `interactive', then only return t if the call was made
@@ -4318,9 +4320,9 @@
       (pcase (cons frame nextframe)
         ;; No subr calls `interactive-p', so we can rule that out.
         (`((,_ ,(pred (lambda (f) (subrp (indirect-function f)))) . ,_) . ,_) 
nil)
-        ;; Somehow, I sometimes got `command-execute' rather than
-        ;; `call-interactively' on my stacktrace !?
-        ;;(`(,_ . (t command-execute . ,_)) t)
+        ;; In case #<subr call-interactively> without going through the
+        ;; `call-interactively' symbol (bug#3984).
+        (`(,_ . (t ,(pred (eq internal--call-interactively)) . ,_)) t)
         (`(,_ . (t call-interactively . ,_)) t)))))
 
 (defun interactive-p ()

=== modified file 'test/ChangeLog'
--- a/test/ChangeLog    2013-09-16 20:58:28 +0000
+++ b/test/ChangeLog    2013-09-20 19:59:42 +0000
@@ -1,3 +1,9 @@
+2013-09-20  Ryan  <address@hidden>  (tiny change)
+
+       * automated/advice-tests.el (advice-test-called-interactively-p-around)
+       (advice-test-called-interactively-p-filter-args)
+       (advice-test-called-interactively-p-around): New tests.
+
 2013-09-16  Glenn Morris  <address@hidden>
 
        * automated/eshell.el (eshell-match-result):

=== modified file 'test/automated/advice-tests.el'
--- a/test/automated/advice-tests.el    2013-08-04 20:18:11 +0000
+++ b/test/automated/advice-tests.el    2013-09-20 19:59:42 +0000
@@ -130,6 +130,38 @@
                 (cons (cons 2 (called-interactively-p)) (apply f args))))
   (should (equal (call-interactively 'sm-test7) '((2 . t) (1 . t) 11))))
 
+(ert-deftest advice-test-called-interactively-p-around ()
+  "Check interaction between around advice and called-interactively-p.
+
+This tests the currently broken case of the innermost advice to a
+function being an around advice."
+  :expected-result :failed
+  (defun sm-test7.2 () (interactive) (cons 1 (called-interactively-p)))
+  (advice-add 'sm-test7.2 :around
+              (lambda (f &rest args)
+                (list (cons 1 (called-interactively-p)) (apply f args))))
+  (should (equal (sm-test7.2) '((1 . nil) (1 . nil))))
+  (should (equal (call-interactively 'sm-test7.2) '((1 . t) (1 . t)))))
+
+(ert-deftest advice-test-called-interactively-p-filter-args ()
+  "Check interaction between filter-args advice and called-interactively-p."
+  :expected-result :failed
+  (defun sm-test7.3 () (interactive) (cons 1 (called-interactively-p)))
+  (advice-add 'sm-test7.3 :filter-args #'list)
+  (should (equal (sm-test7.3) '(1 . nil)))
+  (should (equal (call-interactively 'sm-test7.3) '(1 . t))))
+
+(ert-deftest advice-test-call-interactively ()
+  "Check interaction between advice on call-interactively and 
called-interactively-p."
+  (defun sm-test7.4 () (interactive) (cons 1 (called-interactively-p)))
+  (let ((old (symbol-function 'call-interactively)))
+    (unwind-protect
+        (progn
+          (advice-add 'call-interactively :before #'ignore)
+          (should (equal (sm-test7.4) '(1 . nil)))
+          (should (equal (call-interactively 'sm-test7.4) '(1 . t))))
+      (fset 'call-interactively old))))
+
 (ert-deftest advice-test-interactive ()
   "Check handling of interactive spec."
   (defun sm-test8 (a) (interactive "p") a)


reply via email to

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