From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: How to simulate pressing a key Date: Fri, 19 Sep 2008 23:19:23 -0700 Message-ID: <005a01c91ae8$d3ac9e90$0200a8c0@us.oracle.com> References: <878wtop3t8.fsf@emacs.Arch.net> <873ajvttt2.fsf@emacs.Arch.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1221891607 18792 80.91.229.12 (20 Sep 2008 06:20:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Sep 2008 06:20:07 +0000 (UTC) To: "'netawater'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Sep 20 08:21:03 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 1Kgvq0-0000TU-3z for geh-help-gnu-emacs@m.gmane.org; Sat, 20 Sep 2008 08:21:00 +0200 Original-Received: from localhost ([127.0.0.1]:49345 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kgvoy-0004n2-Fb for geh-help-gnu-emacs@m.gmane.org; Sat, 20 Sep 2008 02:19:56 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kgvog-0004mV-I6 for help-gnu-emacs@gnu.org; Sat, 20 Sep 2008 02:19:38 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kgvoe-0004m6-0Y for help-gnu-emacs@gnu.org; Sat, 20 Sep 2008 02:19:37 -0400 Original-Received: from [199.232.76.173] (port=42329 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kgvod-0004m3-RU for help-gnu-emacs@gnu.org; Sat, 20 Sep 2008 02:19:35 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:8506) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kgvod-0002pA-Qc for help-gnu-emacs@gnu.org; Sat, 20 Sep 2008 02:19:35 -0400 Original-Received: from rgminet01.oracle.com ([148.87.113.118]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KgvoW-0002aw-1I for help-gnu-emacs@gnu.org; Sat, 20 Sep 2008 02:19:28 -0400 Original-Received: from agmgw1.us.oracle.com (agmgw1.us.oracle.com [152.68.180.212]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id m8K6JH4Y023304; Sat, 20 Sep 2008 00:19:17 -0600 Original-Received: from acsmt704.oracle.com (acsmt704.oracle.com [141.146.40.82]) by agmgw1.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id m8K6JGMj025059; Sat, 20 Sep 2008 00:19:17 -0600 Original-Received: from dradamslap1 (/24.23.165.218) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 19 Sep 2008 23:19:16 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <873ajvttt2.fsf@emacs.Arch.net> Thread-Index: Acka0s2A/b9R+fXTRHam3ROivT2WtQAE3aCw X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: by mx20.gnu.org: Linux 2.4-2.6 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:57839 Archived-At: > >> 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. Sorry, I'm unable to follow you. Hopefully someone else will understand and answer you. > 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. As you said, `forward-button' expects at least one argument, and you are applying it to zero arguments. Above, you say "it get parameter by itself". It's unclear to me what you mean by that. Calling the command interactively (call-interactively #'button) will provide the needed arguments (by default, N=1, WRAP=(point), DISPLAY-MESSAGE=(point), which I think will do just what you want - but you say you don't want that. Again, perhaps someone else can help you better. Also, it sounds like you are trying to do something that several others have already done. Take a look here and see if you don't find what you're looking for already made: http://www.emacswiki.org/cgi-bin/wiki/TabCompletion [BTW, you don't need to quote nil: '(). () evaluates to itself.]