From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: netawater Newsgroups: gmane.emacs.help Subject: Re: How to simulate pressing a key Date: Sat, 20 Sep 2008 10:50:01 +0800 Organization: Bentium Ltd. (CN99) Message-ID: <873ajvttt2.fsf@emacs.Arch.net> References: <878wtop3t8.fsf@emacs.Arch.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1221882049 23207 80.91.229.12 (20 Sep 2008 03:40:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Sep 2008 03:40:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Sep 20 05:41:46 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 1KgtLs-0004ri-TJ for geh-help-gnu-emacs@m.gmane.org; Sat, 20 Sep 2008 05:41:45 +0200 Original-Received: from localhost ([127.0.0.1]:53883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KgtKr-0004B2-8J for geh-help-gnu-emacs@m.gmane.org; Fri, 19 Sep 2008 23:40:41 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!newsgate.cuhk.edu.hk!news.cn99.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 43 Original-NNTP-Posting-Host: 58.25.216.163 Original-X-Trace: news.cn99.com 1221878991 14530 58.25.216.163 (20 Sep 2008 02:49:51 GMT) Original-X-Complaints-To: usenet@news.cn99.com Original-NNTP-Posting-Date: Sat, 20 Sep 2008 02:49:51 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:x0vYOnWI46hU/wTRUdBuRYsMR54= Original-Xref: news.stanford.edu gnu.emacs.help:162492 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:57835 Archived-At: "Drew Adams" writes: >> I can not just call the function which key is binding for it may >> have uncertainty parameter, like tab's function forward-button has >> parameter, but lisp-indent-line does not. >> >> although execute-extended-command works perfect, but I can not use >> it in my elisp function. > > I'm not sure I understand your question, but if I do, have a look at function > `call-interactively'. It lets you call an interactive function (command) in > such > a way that the function's `interactive' spec is used to obtain the argument > values. > > See the Elisp manual, node `Interactive Call'. Thanks for your reply. I do not want to interactive call a function but call it like pressing a key. for example, press tab in help-mode will cause forward-button function which has a parameter, however I do not need give it parameter and it get parameter by itself. my aim is to binding a funtion to tab key in every mode: if cursor is at the end of word then call M-TAB's function, else call TAB's function. (defun my-indent-or-complete () "if cursor is at the end of word then call M-TAB's function, else call TAB's function." (interactive) ;; ^C^t is binding to tab key's function in mode-hook. (let ((TAB-func (key-binding "^C^t")) (M-TAB-func (key-binding "\M-\t")) ) (if (looking-at "\\>") (apply M-TAB-func '()) (apply TAB-func '()) )) ) my way is only suitable for lisp-indent-line but not forward-button.