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#11661: 24.1; (wrong-type-argument stringp t) in `display-completion-list' Date: Sat, 9 Jun 2012 10:50:57 -0700 Message-ID: <53C8ABAE936443A3B97386D344C715E0@us.oracle.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1339264305 11759 80.91.229.3 (9 Jun 2012 17:51:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 9 Jun 2012 17:51:45 +0000 (UTC) To: 11661@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 09 19:51:44 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SdPp7-0006Ja-K5 for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Jun 2012 19:51:41 +0200 Original-Received: from localhost ([::1]:38247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdPp7-0003M7-FK for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Jun 2012 13:51:41 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdPp4-0003LL-Cp for bug-gnu-emacs@gnu.org; Sat, 09 Jun 2012 13:51:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SdPp2-0006dS-6F for bug-gnu-emacs@gnu.org; Sat, 09 Jun 2012 13:51:37 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54894) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdPp2-0006dM-30 for bug-gnu-emacs@gnu.org; Sat, 09 Jun 2012 13:51:36 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SdPrN-0002vq-Lz for bug-gnu-emacs@gnu.org; Sat, 09 Jun 2012 13:54:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Drew Adams" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Jun 2012 17:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 11661 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: Original-Received: via spool by submit@debbugs.gnu.org id=B.133926442611244 (code B ref -1); Sat, 09 Jun 2012 17:54:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Jun 2012 17:53:46 +0000 Original-Received: from localhost ([127.0.0.1]:36207 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SdPr7-0002vI-CW for submit@debbugs.gnu.org; Sat, 09 Jun 2012 13:53:45 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44893) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SdPr4-0002vB-EZ for submit@debbugs.gnu.org; Sat, 09 Jun 2012 13:53:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SdPog-0006bI-By for submit@debbugs.gnu.org; Sat, 09 Jun 2012 13:51:15 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:47648) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdPog-0006bD-8b for submit@debbugs.gnu.org; Sat, 09 Jun 2012 13:51:14 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdPoe-0003DT-Av for bug-gnu-emacs@gnu.org; Sat, 09 Jun 2012 13:51:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SdPoc-0006aT-6v for bug-gnu-emacs@gnu.org; Sat, 09 Jun 2012 13:51:11 -0400 Original-Received: from rcsinet15.oracle.com ([148.87.113.117]:21917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdPoc-0006a4-0l for bug-gnu-emacs@gnu.org; Sat, 09 Jun 2012 13:51:10 -0400 Original-Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q59Hp6AJ004921 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 9 Jun 2012 17:51:07 GMT Original-Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q59Hp5LI029296 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 9 Jun 2012 17:51:06 GMT Original-Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q59Hp5uv020896 for ; Sat, 9 Jun 2012 12:51:05 -0500 Original-Received: from dradamslap1 (/10.159.219.243) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 Jun 2012 10:51:05 -0700 X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Thread-Index: Ac1GaGxk1hyKGEEGSQ+gOrmmm+YklQ== X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:60815 Archived-At: This bug is at least as old as Emacs 20. So it is clearly not too important. ;-) emacs -Q M-x load-library minibuffer.el RET M-x load-library simple.el RET M-x debug-on-entry display-completion-list Evaluate this in buffer *scratch*, then walk through the debugger: (display-completion-list ()) First, you will notice that the recursive clause is called in this case, which puts the lie to this comment in the code: ;; This *never* (ever) happens, so there's no point trying to be clever. Continuing, the text "There are no possible completions of what you have typed." is inserted into the temporary buffer, which is expected. It is also princ'd, I'm not sure where (or why). Then the temporary buffer is killed. Perhaps it should not be killed in this recursive call of `display-completion-list'? Continuing, the code uses buffer standard-output, and it runs `completion-setup-hook' (again), which calls `completion-setup-function', which also tries (with-current-buffer standard-output...). But standard-output is `t' then, so we get: Debugger entered--Lisp error: (wrong-type-argument stringp t) * set-buffer(t) * (save-current-buffer (set-buffer standard-output) (let ((base-size completion-base-size) (base-position completion-base-position) (insert-fun completion-list-insert-choice-function)) (completion-list-mode) (set (make-local-variable (quote completion-base-size)) base-size) (set (make-local-variable (quote completion-base-position)) base-position) (set (make-local-variable (quote completion-list-insert-choice-function)) insert-fun)) (set (make-local-variable (quote completion-reference-buffer)) mainbuf) (if base-dir (setq default-directory base-dir)) (when completion-show-help (goto-char (point-min)) (if (display-mouse-p) (insert (substitute-command-keys "Click \\[mouse-choose-completion] on a completion to select it.\n"))) (insert (substitute-command-keys "In this buffer, type \\[choose-completion] to select the completion near point.\n\n")))) `display-completion-list' should do something sane for an empty completions list in an arbitrary buffer. Users should never see a `wrong-type-arg' error. Yes, it is the case that in the existing Emacs source code, `display-completion-list' is ALWAYS called within `with-output-to-temp-buffer', with this one exception in `message.el', where the code does something similar anyway: (with-temp-buffer (let ((standard-output (current-buffer))) (eval '(display-completion-list nil ""))) (defalias 'message-display-completion-list 'display-completion-list)) So the problem does not arise for the source code that Emacs provides. In that context (a) the source comment is true and (b) the error is not raised. But there is nothing in the doc of `display-completion-list' that says that it must be called with `standard-output' so bound etc. It says only: "It [`completion-setup-hook'] can find the completion buffer in `standard-output'." Which is true only if called within `with-output-to-temp-buffer' or a similar context. The doc in (elisp) suffers from the same problem. There, at least, it mentions `with-output-to-temp-buffer', but it does so only saying "a common way to use it...". In fact, that (or equivalent) is currently the ONLY way you can use it without getting a wrong-type-arg error. The function could try to support enforcement of using it only within `with-output-to-temp-buffer' by raising an error unless (bufferp standard-output) (with a better error message than wrong-type-arg). But at that point it is too late: it is the user and not the developer who would see the error. If the code is kept as it is or an error is raised like that, then the doc should be improved to mention the proper calling context. FWIW, in the similar Icicles function, I do this for the recursive case of `display-completion-list', instead of using (with-temp-buffer ...): (let ((standard-output (current-buffer))) (icicle-display-completion-list completions)) And I also do not do (princ (buffer-string)) in that case. This has the effect of inserting the text "There are no possible completions..." - or the completion candidates if there are some - into the current buffer. I think it always DTRT (including within `with-output-to-temp-buffer'). Perhaps that would make sense for `display-completion-list' too - dunno. In GNU Emacs 24.1.1 (i386-mingw-nt5.1.2600) of 2012-06-01 on MARVIN Windowing system distributor `Microsoft Corp.', version 5.1.2600 Configured using: `configure --with-gcc (4.6) --no-opt --enable-checking --cflags -ID:/devel/emacs/libs/libXpm-3.5.8/include -ID:/devel/emacs/libs/libXpm-3.5.8/src -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include -ID:/devel/emacs/libs/giflib-4.1.4-1/include -ID:/devel/emacs/libs/jpeg-6b-4/include -ID:/devel/emacs/libs/tiff-3.8.2-1/include -ID:/devel/emacs/libs/gnutls-3.0.9/include'