From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#5364: 23.1.91; execute-extended-command should do like FFAP Date: Fri, 15 Jan 2010 11:19:38 +0200 Organization: JURTA Message-ID: <87zl4fhgid.fsf@mail.jurta.org> References: <87my0hgy29.fsf@jidanni.org> <87ska8jszf.fsf@mail.jurta.org> <87wrzki0zy.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1263548980 18909 80.91.229.12 (15 Jan 2010 09:49:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Jan 2010 09:49:40 +0000 (UTC) Cc: 5364@debbugs.gnu.org, jidanni@jidanni.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 15 10:49:32 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NVio5-000199-Vr for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Jan 2010 10:49:30 +0100 Original-Received: from localhost ([127.0.0.1]:54355 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVio6-0002WG-QE for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Jan 2010 04:49:30 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NVio1-0002VS-ON for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2010 04:49:25 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NVinw-0002Tm-Ri for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2010 04:49:24 -0500 Original-Received: from [199.232.76.173] (port=57861 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVinw-0002Ti-HC for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2010 04:49:20 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37201) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NVinv-0001bf-Uc for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2010 04:49:20 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1NViTM-0006oE-7R; Fri, 15 Jan 2010 04:28:04 -0500 X-Loop: bug-gnu-emacs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Jan 2010 09:28:04 +0000 Resent-Message-ID: Resent-Sender: bug-gnu-emacs@gnu.org X-Emacs-PR-Message: followup 5364 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 5364-submit@debbugs.gnu.org id=B5364.126354764226150 (code B ref 5364); Fri, 15 Jan 2010 09:28:04 +0000 Original-Received: (at 5364) by debbugs.gnu.org; 15 Jan 2010 09:27:22 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NViSf-0006ng-NF for submit@debbugs.gnu.org; Fri, 15 Jan 2010 04:27:21 -0500 Original-Received: from smtp-out3.starman.ee ([85.253.0.5] helo=mx1.starman.ee) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NViSc-0006nU-Lm for 5364@debbugs.gnu.org; Fri, 15 Jan 2010 04:27:20 -0500 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (85.253.48.2.cable.starman.ee [85.253.48.2]) by mx1.starman.ee (Postfix) with ESMTP id AF9703F40E4; Fri, 15 Jan 2010 11:27:09 +0200 (EET) In-Reply-To: (Stefan Monnier's message of "Thu, 14 Jan 2010 21:20:27 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (x86_64-pc-linux-gnu) X-Spam-Score: -3.4 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list X-Spam-Score: -3.4 (---) Resent-Date: Fri, 15 Jan 2010 04:28:04 -0500 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:34352 Archived-At: > The Elisp code looks OK, except it should be in the C file. Please move > it to simple.el where we can edit it with edebug, font-lock, eldoc, ... A patch for post-23.2: === modified file 'lisp/simple.el' --- lisp/simple.el 2010-01-13 08:35:10 +0000 +++ lisp/simple.el 2010-01-15 09:14:30 +0000 @@ -1210,6 +1210,29 @@ (defun repeat-complex-command (arg) (if command-history (error "Argument %d is beyond length of command history" arg) (error "There are no previous complex commands to repeat"))))) + +(defun read-extended-command () + "Read command name to invoke in `execute-extended-command'." + (minibuffer-with-setup-hook + (lambda () + (set (make-local-variable 'minibuffer-default-add-function) + (lambda () + (with-current-buffer (window-buffer (minibuffer-selected-window)) + (and (commandp (function-called-at-point)) + (format "%S" (function-called-at-point))))))) + (completing-read + (concat (cond + ((eq current-prefix-arg '-) "- ") + ((and (consp current-prefix-arg) + (eq (car current-prefix-arg) 4)) "C-u ") + ((and (consp current-prefix-arg) + (integerp (car current-prefix-arg))) + (format "%d " (car current-prefix-arg))) + ((integerp current-prefix-arg) + (format "%d " current-prefix-arg))) + (key-description (this-single-command-keys)) + " ") + obarray 'commandp t nil 'extended-command-history))) (defvar minibuffer-history nil "Default minibuffer history list. === modified file 'src/keyboard.c' --- src/keyboard.c 2010-01-13 08:35:10 +0000 +++ src/keyboard.c 2010-01-15 09:17:15 +0000 @@ -10512,19 +10512,17 @@ (at your option) any later version. DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_command, - 1, 1, "P", - doc: /* Read function name, then read its arguments and call it. + 2, 2, "(list current-prefix-arg (read-extended-command))", + doc: /* Read arguments, then read FUNCTION name and call it. To pass a numeric argument to the command you are invoking with, specify the numeric argument to this command. Noninteractively, the argument PREFIXARG is the prefix argument to give to the command you invoke, if it asks for an argument. */) - (prefixarg) - Lisp_Object prefixarg; + (prefixarg, function) + Lisp_Object prefixarg, function; { - Lisp_Object function; - char buf[40]; int saved_last_point_position; Lisp_Object saved_keys, saved_last_point_position_buffer; Lisp_Object bindings, value; @@ -10543,32 +10541,8 @@ (at your option) any later version. XVECTOR (this_command_keys)->contents); saved_last_point_position_buffer = last_point_position_buffer; saved_last_point_position = last_point_position; - buf[0] = 0; GCPRO3 (saved_keys, prefixarg, saved_last_point_position_buffer); - if (EQ (prefixarg, Qminus)) - strcpy (buf, "- "); - else if (CONSP (prefixarg) && XINT (XCAR (prefixarg)) == 4) - strcpy (buf, "C-u "); - else if (CONSP (prefixarg) && INTEGERP (XCAR (prefixarg))) - sprintf (buf, "%ld ", (long) XINT (XCAR (prefixarg))); - else if (INTEGERP (prefixarg)) - sprintf (buf, "%ld ", (long) XINT (prefixarg)); - - /* This isn't strictly correct if execute-extended-command - is bound to anything else. Perhaps it should use - this_command_keys? */ - strcat (buf, "M-x "); - - /* Prompt with buf, and then read a string, completing from and - restricting to the set of all defined commands. Don't provide - any initial input. Save the command read on the extended-command - history list. */ - function = Fcompleting_read (build_string (buf), - Vobarray, Qcommandp, - Qt, Qnil, Qextended_command_history, Qnil, - Qnil); - #ifdef HAVE_WINDOW_SYSTEM if (hstarted) start_hourglass (); #endif -- Juri Linkov http://www.jurta.org/emacs/