Subject: bug#17446: 24.4.50; What is the situation around `called-interactively-p'?

From: Michael Heerdegen <[email-masked]>
Date: Sat, 10 May 2014 09:40:18 +0200

Stefan Monnier <[email-masked]> writes:

> BTW, for older Emacsen, you can probably use a hack along the lines of
> the guaranteed 100% untested code below:

I tried to make it work:

   (defun funcall-interactively (fun &rest args)
     (setq fun (indirect-function fun))
     (call-interactively
       (cond
        ((consp fun)
         (mapcar (lambda (x)
                   (if (eq (car-safe x) 'interactive)
                       `(interactive ',args) x))
                 fun))
        ((byte-code-function-p fun)
         (apply #'make-byte-code
                (aref fun 0)
                (aref fun 1)
                (aref fun 2)
                (aref fun 3)
                (aref fun 4)
                (aref fun 5)
                args)))))

Works at least with the count-words case:

  (funcall-interactively 'count-words nil nil) ==> something useful

Michael.