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:03:14 +0100 Message-ID: <87zlt7rikd.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 1205077878 16392 80.91.229.12 (9 Mar 2008 15:51:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Mar 2008 15:51:18 +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 16:51:43 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 1JYNoK-0003t4-AM for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2008 16:51:40 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JYNnm-0006mK-99 for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Mar 2008 11:51:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JYNnO-0006jr-S6 for help-gnu-emacs@gnu.org; Sun, 09 Mar 2008 11:50:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JYNnN-0006jA-56 for help-gnu-emacs@gnu.org; Sun, 09 Mar 2008 11:50:42 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JYNnN-0006j2-08 for help-gnu-emacs@gnu.org; Sun, 09 Mar 2008 11:50:41 -0400 Original-Received: from fk-out-0910.google.com ([209.85.128.187]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JYNnM-0008BI-AP for help-gnu-emacs@gnu.org; Sun, 09 Mar 2008 11:50:40 -0400 Original-Received: by fk-out-0910.google.com with SMTP id 26so1356442fkx.10 for ; Sun, 09 Mar 2008 08:50:37 -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=TmEqi/nkQ34YLu5wpMqjZaVhcWA6wugRz1uXL5ETuyA=; b=C5JzXdfOwuvwsn22a6fqLthQ0VD3k5ZCBm//bAxnnNw4SRJHdKkg+EoNnXrA3xx7MLkw9j6q1V44/6GcYGbYaVcKGnhGWbbVuNpwvSScpG/8ZNfogaTFOGhm3gDHyhTQfT80Sco923NHyblf8vR/GBNt5Q33AcF4hKMxXa5VIlo= 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=h4X1HaJc2deG5Gz+E+SR5MpI1uzfq/+7/j+mLuQ96q7w1GGR5Xcq1f+UE4nvHGF1MabytGTyzmuYi1R3yCQC/EksjZOXmbthSh3FNynmOYNc4N7ywx/+8oG/Tt+l50/0m93zQx4c/9dSim0HfaZ1LjjAgS29SSrByBkX26wSAsg= Original-Received: by 10.78.139.14 with SMTP id m14mr10622617hud.76.1205077837326; Sun, 09 Mar 2008 08:50:37 -0700 (PDT) Original-Received: from thievol.homelinux.org ( [79.85.211.67]) by mx.google.com with ESMTPS id j2sm24430047mue.3.2008.03.09.08.50.35 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Mar 2008 08:50:36 -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:52188 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. > I think you have to put your completing-read outside of the let body. -- A + Thierry Pub key: http://pgp.mit.edu