Если вы используете jQuery, кто-то на самом деле создал плагин «delay», который является не более чем оболочкой для setTimeout:
// Delay Plugin for jQuery
// - http://www.evanbot.com
// - © 2008 Evan Byrne
jQuery.fn.delay = function(time,func){
this.each(function(){
setTimeout(func,time);
});
return this;
};
Затем вы можете просто использовать его в строке вызовов функций, как и ожидалось. :
$('#warning')
.addClass('highlight')
.delay(1000)
.removeClass('highlight');
The explicit answer to your question is this:
(define-prefix-command 'perly-sense-map)
(global-set-key (kbd "C-p") 'perly-sense-map)
(define-key perly-sense-map (kbd "C-d") 'perly-sense-smart-docs-at-point)
(define-key perly-sense-map (kbd "C-g") 'perly-sense-smart-go-to-at-point)
For more information as to what's being done, check out documentation for
In the original post, you mixed using kbd
and the older "\C-p" notation. You can read this large tutorial discussing keybindings, which has tons of information (more than what you probably need). I find the kbd
usage to be the easiest, you just pass it the string that you'd see when you do help on a key (C-h k).
Emacs, by default, only allows certain keys to be prefixes (the start of multi-key commands). See http://www.gnu.org/software/emacs/manual/html_node/elisp/Prefix-Keys.html You need to create a keymap and bind it to C-p.