From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.bugs Subject: bug#591: 23.0.60; lisp-complete-symbol erases extra text Date: Tue, 29 Jul 2008 14:51:42 -0700 Message-ID: <004201c8f1c5$4a56e840$0200a8c0@us.oracle.com> References: <87ej5czaef.fsf@stupidchicken.com> Reply-To: Drew Adams , 591@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1217369270 26617 80.91.229.12 (29 Jul 2008 22:07:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 29 Jul 2008 22:07:50 +0000 (UTC) To: "'Chong Yidong'" , <591@emacsbugs.donarmstrong.com>, "'Stefan Monnier'" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 30 00:08:39 2008 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 1KNxMz-00044H-Jc for geb-bug-gnu-emacs@m.gmane.org; Wed, 30 Jul 2008 00:08:37 +0200 Original-Received: from localhost ([127.0.0.1]:55784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KNxM5-00014E-8y for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Jul 2008 18:07:41 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KNxLp-0000yC-5v for bug-gnu-emacs@gnu.org; Tue, 29 Jul 2008 18:07:25 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KNxLn-0000xK-FA for bug-gnu-emacs@gnu.org; Tue, 29 Jul 2008 18:07:23 -0400 Original-Received: from [199.232.76.173] (port=59535 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KNxLn-0000xF-9c for bug-gnu-emacs@gnu.org; Tue, 29 Jul 2008 18:07:23 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:38603) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KNxLm-0000gk-Mw for bug-gnu-emacs@gnu.org; Tue, 29 Jul 2008 18:07:23 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m6TM7KIF000459; Tue, 29 Jul 2008 15:07:20 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m6TM03tZ029918; Tue, 29 Jul 2008 15:00:03 -0700 X-Loop: don@donarmstrong.com Resent-From: "Drew Adams" Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Tue, 29 Jul 2008 22:00:03 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 591 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 591-submit@emacsbugs.donarmstrong.com id=B591.121736832728660 (code B ref 591); Tue, 29 Jul 2008 22:00:03 +0000 Original-Received: (at 591) by emacsbugs.donarmstrong.com; 29 Jul 2008 21:52:07 +0000 Original-Received: from agminet01.oracle.com (agminet01.oracle.com [141.146.126.228]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m6TLq3ZY028654 for <591@emacsbugs.donarmstrong.com>; Tue, 29 Jul 2008 14:52:04 -0700 Original-Received: from agmgw1.us.oracle.com (agmgw1.us.oracle.com [152.68.180.212]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id m6TLpqv2025755; Tue, 29 Jul 2008 16:51:53 -0500 Original-Received: from acsmt354.oracle.com (acsmt354.oracle.com [141.146.40.154]) by agmgw1.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id m6THWQr3001549; Tue, 29 Jul 2008 15:51:52 -0600 Original-Received: from inet-141-146-46-1.oracle.com by acsmt354.oracle.com with ESMTP id 11112970461217368299; Tue, 29 Jul 2008 14:51:39 -0700 Original-Received: from dradamslap1 (/141.144.81.72) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 29 Jul 2008 14:51:39 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <87ej5czaef.fsf@stupidchicken.com> Thread-Index: AcjxvziOAh7unJW/ReGMzQ0WpBvmigAAnkDA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Tue, 29 Jul 2008 18:07:23 -0400 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: , 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:18915 Archived-At: > From: Chong Yidong Sent: Tuesday, July 29, 2008 1:46 PM > Hi Stefan, > This bug was introduced by your patch: > 2008-04-13 Stefan Monnier > minibuffer.el (display-completion-list): > Handle all-completions's new base-size info to set > completion-base-size. > > This sets completion-base-size to 0, which causes the > completions buffer to delete everything in the Lisp > buffer when you make a selection. > > I don't understand why we need the (completely undocumented) > hack introduced here, where the cdr of the last item on the > completions list gives completion-base-size. Does anything > else in Emacs depend on this? Why not simply add a new > optional argument to display-completion-list? I won't pronounce on the hack of putting the base size into the cdr; only Stefan knows if that is necessary and the right approach. I will say about that change only that it required me to change my own code in a few places. For example, you can no longer just apply `length' to the list, because it is no longer a true list. My reason for replying to your mail is instead to pass along the code that Icicles uses for `choose-completion-string', in case it helps. I don't provide it as a diff for straightforward patching, but rather as something you might want to think about. The essential differences are these: 1. I use this: (delete-region (+ base-size (if mini-p (minibuffer-prompt-end) (point-min))) (if mini-p (point-max) (point))) instead of this: (delete-region (+ base-size (field-beginning)) (point)) 2. After deleting the region I do this: (when mini-p (goto-char (point-max))) Here is my definition: (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 characters of BUFFER's text to keep. If it is nil, we call `choose-completion-delete-max-match' to decide what to delete. If BUFFER is the minibuffer, then exit the minibuffer, unless one of the following is true: - it is reading a file name, CHOICE is a directory, and `icicle-dir-candidate-can-exit-p' is nil - `completion-no-auto-exit' is non-nil - this is just a `lisp-complete-symbol' completion." (let* ((buffer (or buffer completion-reference-buffer)) (mini-p (minibufferp buffer))) ;; If BUFFER is a minibuffer, barf unless it's currently active. (if (and mini-p (or (not (active-minibuffer-window)) (not (equal buffer (window-buffer (active-minibuffer-window)))))) (error "Minibuffer is not active for completion") ;; Set buffer so buffer-local `choose-completion-string-functions' works. (set-buffer buffer) (unless (run-hook-with-args-until-success 'choose-completion-string-functions choice buffer mini-p base-size) ;; Insert completion into buffer where completion was requested. (if base-size (delete-region (+ base-size (if mini-p (minibuffer-prompt-end) (point-min))) (if mini-p (point-max) (point))) (choose-completion-delete-max-match choice)) (when mini-p (goto-char (point-max))) (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 0))) (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))) (or minibuffer-completion-table (and icicle-mode (or icicle-extra-candidates icicle-proxy-candidates))) (not (eq 'lisp-complete-symbol icicle-cmd-calling-for-completion)) ;; Exit the minibuffer if `icicle-dir-candidate-can-exit-p', ;; or not reading a file name, or chosen file is not a directory. (if (or icicle-dir-candidate-can-exit-p (not (eq minibuffer-completion-table 'read-file-name-internal)) (not (file-directory-p (field-string (point-max))))) (exit-minibuffer) (let ((mini (active-minibuffer-window))) (select-window mini) (when minibuffer-auto-raise (raise-frame (window-frame mini)))))))))) HTH - Drew