emacs-devel
[Top][All Lists]
Advanced

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

Re: Suggestion: Simple way to make conditional key bindings.


From: David PONCE
Subject: Re: Suggestion: Simple way to make conditional key bindings.
Date: Fri, 23 Aug 2002 14:52:10 +0200 (MET DST)

Hi Kim,

> Sometimes you would like a specific key binding to be controlled
> by some global or local state, but you really don't want to mess
> with minor-mode keymaps etc.
>
[...]
>
> One use would be to bind C-y to `yank' except when the first element
> in the kill-ring is a table, in which case we want to run
> `yank-with-properties':
>
>
> (global-set-key "\C-y"
>         '(cond
>           ((and kill-ring (table-recognize-table (car kill-ring)))
>             yank-with-properties)
>           (t yank)))
>
>
> One advantage (IMO) is that C-h k C-y will report yank or
> yank-with-properties depending on the actual function taken if
> you hit C-y.
>
> WDYT ?

It seems that you can do something similar this way:

(global-set-key "\C-y" '(menu-item "my-filter" :filter my-filter))

(defun my-filter (&rest ignore)
  (cond
   ((and kill-ring (table-recognize-table (car kill-ring)))
    'yank-with-properties)
   (t 'yank)))

Am I wrong?

Sincerely,
David







reply via email to

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