all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'netawater'" <netstandin-003@yahoo.com.cn>, <help-gnu-emacs@gnu.org>
Subject: RE: How to simulate pressing a key
Date: Fri, 19 Sep 2008 23:19:23 -0700	[thread overview]
Message-ID: <005a01c91ae8$d3ac9e90$0200a8c0@us.oracle.com> (raw)
In-Reply-To: <873ajvttt2.fsf@emacs.Arch.net>

> >> 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.]






  reply	other threads:[~2008-09-20  6:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-19 15:12 How to simulate pressing a key netawater
2008-09-19 15:05 ` Drew Adams
     [not found] ` <mailman.19555.1221836708.18990.help-gnu-emacs@gnu.org>
2008-09-20  2:50   ` netawater
2008-09-20  6:19     ` Drew Adams [this message]
2008-09-20  6:55       ` Drew Adams
2008-09-20  7:08         ` Thierry Volpiatto
2008-09-20 10:59     ` Nikolaj Schumacher
     [not found]     ` <mailman.19594.1221891580.18990.help-gnu-emacs@gnu.org>
2008-09-20 14:37       ` netawater
2008-09-20 16:00         ` Drew Adams
     [not found]         ` <mailman.19618.1221926415.18990.help-gnu-emacs@gnu.org>
2008-09-26 13:18           ` netawater
     [not found]     ` <mailman.19605.1221908356.18990.help-gnu-emacs@gnu.org>
2008-09-20 14:43       ` netawater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='005a01c91ae8$d3ac9e90$0200a8c0@us.oracle.com' \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=netstandin-003@yahoo.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.