From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.bugs Subject: choose-completion-string should not exit minibuffer upon lisp-complete-symbol Date: Tue, 21 Sep 2004 15:28:22 -0700 Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1677520524==" X-Trace: sea.gmane.org 1095805746 18246 80.91.229.6 (21 Sep 2004 22:29:06 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 21 Sep 2004 22:29:06 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Sep 22 00:28:49 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1C9t7x-0003lN-00 for ; Wed, 22 Sep 2004 00:28:49 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C9tDu-0007MO-0g for geb-bug-gnu-emacs@m.gmane.org; Tue, 21 Sep 2004 18:34:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C9tDq-0007KW-Ib for bug-gnu-emacs@gnu.org; Tue, 21 Sep 2004 18:34:54 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C9tDp-0007JR-F1 for bug-gnu-emacs@gnu.org; Tue, 21 Sep 2004 18:34:54 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C9tDp-0007JJ-AL for bug-gnu-emacs@gnu.org; Tue, 21 Sep 2004 18:34:53 -0400 Original-Received: from [148.87.2.204] (helo=inet-mail4.oracle.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1C9t7h-0008F6-F1 for bug-gnu-emacs@gnu.org; Tue, 21 Sep 2004 18:28:33 -0400 Original-Received: from rgmgw1.us.oracle.com (rgmgw1.us.oracle.com [138.1.191.10]) by inet-mail4.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i8LMNKrM023835 for ; Tue, 21 Sep 2004 15:23:21 -0700 (PDT) Original-Received: from rgmgw1.us.oracle.com (localhost [127.0.0.1]) by rgmgw1.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i8LMSTH2008377 for ; Tue, 21 Sep 2004 16:28:29 -0600 Original-Received: from dradamslap (dhcp-amer-csvpn-gw1-141-144-68-102.vpn.oracle.com [141.144.68.102]) by rgmgw1.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with SMTP id i8LMSSOO008337 for ; Tue, 21 Sep 2004 16:28:29 -0600 Original-To: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Importance: Normal X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:9053 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:9053 This is a multi-part message in MIME format. --===============1677520524== Content-Type: multipart/alternative; boundary="----=_NextPart_000_0039_01C49FEF.A1604EA0" This is a multi-part message in MIME format. ------=_NextPart_000_0039_01C49FEF.A1604EA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit This is more of an enhancement suggestion than a bug report. If you are entering Lisp code for evaluation (e.g. `M-:'), then you don't want to exit the minibuffer when you complete a Lisp symbol. For example, you have "(sear" when you use `lisp-complete-symbol' to pick `search-forward'; you want the minibuffer to have "(search-forward" and let you continue to type code. For this reason, I modified choose-completion-string to recognize this. Below is my version from Emacs 20, but I think the code is about the same for Emacs 21 (the "problem" is still there, in any case). My code uses variable command-calling-for-completion from library `elect-mbuf.el', but the test could be done differently. That variable just holds the last command that caused display of the list of possible completions. ;; REPLACES ORIGINAL in `simple.el': ;; Don't exit minibuffer if this is just a `lisp-complete-symbol' completion. (defun choose-completion-string (choice &optional buffer base-size) "Switch to BUFFER and insert the completion choice CHOICE. BASE-SIZE, if non-nil, says how many chars of BUFFER's text to keep. If it is nil, use `choose-completion-delete-max-match' instead. If BUFFER is the minibuffer, then exit the minibuffer, unless: - it is reading a file name and CHOICE is a directory, *or* - `completion-no-auto-exit' is non-nil, *or* - this is just a `lisp-complete-symbol' completion." (let ((buffer (or buffer completion-reference-buffer))) ; In `simple.el'. ;; If BUFFER is a minibuffer, barf unless it's currently active. (when (and (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer)) (or (not (active-minibuffer-window)) (not (equal buffer (window-buffer (active-minibuffer-window)))))) (error "Minibuffer is not active for completion.")) ;; Insert the completion into the buffer where completion was requested. (set-buffer buffer) (if base-size (delete-region (+ base-size (point-min)) (point)) (choose-completion-delete-max-match choice)) (insert choice) (remove-text-properties (- (point) (length choice)) (point) '(mouse-face nil)) ;; Update point in the window that BUFFER is showing in. (let ((window (get-buffer-window buffer t))) (set-window-point window (point))) ;; If completing for the minibuffer, exit it with this choice, ;; unless this was a `lisp-complete-symbol' completion. (and (not completion-no-auto-exit) (equal buffer (window-buffer (minibuffer-window))) minibuffer-completion-table (not (and (boundp 'command-calling-for-completion) ; Defined in `elect-mbuf.el'. (eq 'lisp-complete-symbol command-calling-for-completion))) ;; If this is reading a file name, and the file name chosen ;; is a directory, don't exit the minibuffer. (if (and (eq minibuffer-completion-table 'read-file-name-internal) (file-directory-p (buffer-string))) (select-window (active-minibuffer-window)) (exit-minibuffer))))) ------=_NextPart_000_0039_01C49FEF.A1604EA0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
This = is more of an=20 enhancement suggestion than a bug report.
 
If you = are entering=20 Lisp code for evaluation (e.g. `M-:'), then you don't want to exit the=20 minibuffer when you complete a Lisp symbol. For example, you have = "(sear" when=20 you use `lisp-complete-symbol' to pick `search-forward'; you want the = minibuffer=20 to have "(search-forward" and let you continue to type = code.
 
For = this reason, I=20 modified choose-completion-string to recognize this. Below is my version = from=20 Emacs 20, but I think the code is about the same for Emacs 21 (the = "problem" is=20 still there, in any case). My code uses variable = command-calling-for-completion=20 from library `elect-mbuf.el', but the test could be done differently. = That=20 variable just holds the last command that caused display of the list of = possible=20 completions.
 
;; REPLACES=20 ORIGINAL in `simple.el':
;; Don't exit minibuffer if this is just a=20 `lisp-complete-symbol' completion.
(defun choose-completion-string = (choice=20 &optional buffer base-size)
  "Switch to BUFFER and insert = the=20 completion choice CHOICE.
BASE-SIZE, if non-nil, says how many chars = of=20 BUFFER's text to keep.
If it is nil, use = `choose-completion-delete-max-match'=20 instead.
If BUFFER is the minibuffer, then exit the minibuffer,=20 unless:
   - it is reading a file name and CHOICE is a = directory,=20 *or*
   - `completion-no-auto-exit' is non-nil,=20 *or*
   - this is just a `lisp-complete-symbol'=20 completion."
  (let ((buffer (or buffer = completion-reference-buffer))) ;=20 In `simple.el'.
    ;; If BUFFER is a minibuffer, barf = unless=20 it's currently active.
    (when (and (string-match = "\\`=20
\\*Minibuf-[0-9]+\\*\\'
"
         = ;            =        =20 (buffer-name=20 buffer))
          &= nbsp;   =20 (or (not=20 (active-minibuffer-window))
       =            =20 (not (equal=20 buffer
          &nb= sp;           &nbs= p;       =20 (window-buffer = (active-minibuffer-window))))))
     =20 (error "Minibuffer is not active for = completion."))
    ;;=20 Insert the completion into the buffer where completion was=20 requested.
    (set-buffer = buffer)
    (if=20 base-size
        (delete-region = (+=20 base-size (point-min)) (point))
     =20 (choose-completion-delete-max-match choice))
    = (insert=20 choice)
    (remove-text-properties (- (point) (length = choice))=20 (point)
          &n= bsp;           &nb= sp;    =20 '(mouse-face nil))
    ;; Update point in the window = that=20 BUFFER is showing in.
    (let ((window = (get-buffer-window=20 buffer t)))
      (set-window-point window=20 (point)))
    ;; If completing for the minibuffer, = exit it=20 with this choice,
    ;; unless this was a=20 `lisp-complete-symbol' completion.
    (and (not=20 completion-no-auto-exit)
       &nb= sp;=20 (equal buffer (window-buffer=20 (minibuffer-window)))
        = =20 minibuffer-completion-table
       =  =20 (not (and (boundp 'command-calling-for-completion) = ; Defined=20 in=20 `elect-mbuf.el'.
         = ;         =20 (eq 'lisp-complete-symbol=20 command-calling-for-completion)))

     = ;   =20 ;; If this is reading a file name, and the file name=20 chosen
         ;; is a = directory,=20 don't exit the = minibuffer.
        =20 (if (and (eq minibuffer-completion-table=20 'read-file-name-internal)
       &n= bsp;         =20 (file-directory-p=20 (buffer-string)))
        &nbs= p;   =20 (select-window=20 (active-minibuffer-window))
       =    =20 (exit-minibuffer)))))
------=_NextPart_000_0039_01C49FEF.A1604EA0-- --===============1677520524== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bug-gnu-emacs mailing list Bug-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs --===============1677520524==--