help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: COMPLETING-READ Problem


From: Thierry Volpiatto
Subject: Re: COMPLETING-READ Problem
Date: Sun, 09 Mar 2008 17:03:14 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Volkan YAZICI <volkan.yazici@gmail.com> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]