From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.help Subject: Re: COMPLETING-READ Problem Date: Sun, 09 Mar 2008 17:15:36 +0100 Message-ID: <87ve3vrhzr.fsf@thievol.homelinux.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1205078664 18625 80.91.229.12 (9 Mar 2008 16:04:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Mar 2008 16:04:24 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Volkan YAZICI Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Mar 09 17:04:52 2008 Return-path: Envelope-to: geh-help-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 1JYO13-0007Uy-JB for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2008 17:04:49 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JYO0V-0007vK-MB for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2008 12:04:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JYNzM-0006qA-4k for help-gnu-emacs@gnu.org; Sun, 09 Mar 2008 12:03:04 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JYNzK-0006o1-Ir for help-gnu-emacs@gnu.org; Sun, 09 Mar 2008 12:03:03 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JYNzK-0006ns-8p for help-gnu-emacs@gnu.org; Sun, 09 Mar 2008 12:03:02 -0400 Original-Received: from nf-out-0910.google.com ([64.233.182.185]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JYNzJ-0002v1-SD for help-gnu-emacs@gnu.org; Sun, 09 Mar 2008 12:03:02 -0400 Original-Received: by nf-out-0910.google.com with SMTP id f5so548380nfh.26 for ; Sun, 09 Mar 2008 09:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references:date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=IZ64NUVfWfsg/5E0pPp+SQu4/28NAHstPHAEDoIPXPs=; b=Z86zTxrUqI2L8qWarQ5IbFWc+5xjnI+4NztPOnvU8fL2y6ul9km9GrxkcC4+VkYiyueHvF2RYjVDFJ7Xy6M/vkCo/eZ/iyzI+Pj8B2ilOWOnjf7jMC0cbnHNKTSm8NZ9OAdAmhep8f2wueiDnQt7THsaOu4hawAsuFymUpKyNZM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id:user-agent:mime-version:content-type; b=u0h7i7mG9q0tS5K2aJOTTOPT34izXlvf5m6KbrHvvqJHze2WQZuGNAwtvvBTENWoUhHYnmCJWtel49o9DKyF/sUKc5sscSfflt/eZ//q6lFP2KmxRjVypRAXMAuD/akevGLH+Qm58cwUROMzcnMytM/zj9DZVUmgz0XF4NOeanQ= Original-Received: by 10.78.81.20 with SMTP id e20mr10702843hub.64.1205078580110; Sun, 09 Mar 2008 09:03:00 -0700 (PDT) Original-Received: from thievol.homelinux.org ( [79.85.211.67]) by mx.google.com with ESMTPS id n10sm9295041mue.18.2008.03.09.09.02.57 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Mar 2008 09:02:58 -0700 (PDT) In-Reply-To: (Volkan YAZICI's message of "Sun, 9 Mar 2008 05:51:44 -0700 (PDT)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:52189 Archived-At: Volkan YAZICI writes: > Hi, > > While trying to implement a family of SQL identifier search functions, > I want to offer tab completion to previously searched SQL identifiers > -- besides builtin history functionality binded to M-p. For this > purpose, I try to use COMPLETING-READ. Here's the related code > snippet: > > (defvar searched-sql-items nil > "Association list of previously searched SQL items.") > > (defun make-local-searched-sql-items () > "Creates per-buffer SEARCHED-SQL-ITEMS association list." > (make-local-variable 'searched-sql-items)) > > (add-hook 'sql-mode-hook 'make-local-searched-sql-items) > > (defun search-sql-table (table-name) > "Search for specified TABLE-NAME in the current buffer." > (interactive > (let ((previously-searched-tables (assoc 'table searched-sql- > items))) > (list > (completing-read > (if previously-searched-tables > (format "Table name (default: %s): " > (first previously-searched-tables)) > "Table name: ") > previously-searched-tables))) > ;; Insert specified TABLE-NAME to SEARCHED-SQL-ITEMS. > (let ((previously-searched-tables (assoc 'table searched-sql- > items))) > (setf (assoc 'table searched-sql-items) > ;; Move TABLE-NAME to top. > (cons table-name (remove table-name previously-searched- > tables)))) > ;; Search table. > (search-forward (format "CREATE TABLE %s" table-name)))) > > But for some reason, function doesn't work. (Does nothing during > execution.) I tried to place a (warn "TABLE-NAME: %s" table-name) just > after (interactive ...) block, but there doesn't appear anything in > the *Messages* buffer. Any ideas? > > > Regards. > Or use let* to be able to reuse previously-searched-tables in completing-read. -- A + Thierry Pub key: http://pgp.mit.edu