[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Distinguishing interactive and non-interactive functions or customiz
From: |
Teemu Likonen |
Subject: |
Re: Distinguishing interactive and non-interactive functions or customizing `execute-extended-command'? |
Date: |
Wed, 08 Dec 2010 15:16:41 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2.50 (gnu/linux) |
* 2010-07-01 02:56 (-0700), Elena wrote:
> For instance, I'd like to define an interactive "sort" command which
> would act accordingly to context. However, a non-interactive `sort'
> function already exists and I think that redefining it should be my
> last (ugly) resort. I'd just like to find a way to type `M-x sort RET'
> and having my own `sort' command executed.
I don't recommend doing that but it should be possible with so called
"around-advices". The idea is that your "advice" code runs instead of
the original function and then you can decide to call the original
function according to some condition (if (called-interactively-p) ...).
See the Emacs Lisp manual and section 17 Advising Emacs Lisp Functions.
But I'd just choose a different name for such user-interface sort
command and perhaps bind it to a key if it's needed often.