]> code.delx.au - gnu-emacs/commitdiff
Teach M-x disassemble a default argument.
authorMark Oteiza <mvoteiza@udel.edu>
Thu, 31 Mar 2016 23:34:05 +0000 (19:34 -0400)
committerMark Oteiza <mvoteiza@udel.edu>
Thu, 31 Mar 2016 23:34:05 +0000 (19:34 -0400)
Adopts default argument in the same way as `describe-function'.
* lisp/emacs-lisp/disass.el (disassemble): Default to function at point,
if any.

lisp/emacs-lisp/disass.el

index e67b0220e14dea7431087c89fd0558457421e42c..8506ed696694840eb1ad7d871df6362c9ada29e3 100644 (file)
@@ -54,9 +54,13 @@ OBJECT can be a symbol defined as a function, or a function itself
 \(a lambda expression or a compiled-function object).
 If OBJECT is not already compiled, we compile it, but do not
 redefine OBJECT if it is a symbol."
-  (interactive (list (intern (completing-read "Disassemble function: "
-                                             obarray 'fboundp t))
-                    nil 0 t))
+  (interactive
+   (let* ((fn (function-called-at-point))
+          (prompt (if fn (format "Disassemble function (default %s): " fn)
+                    "Disassemble function: "))
+          (def (and fn (symbol-name fn))))
+     (list (intern (completing-read prompt obarray 'fboundp t nil nil def))
+           nil 0 t)))
   (if (and (consp object) (not (functionp object)))
       (setq object `(lambda () ,object)))
   (or indent (setq indent 0))          ;Default indent to zero