{"action":"created","issue":{"url":"https://api.github.com/repos/syl20bnr/spacemacs/issues/1263","labels_url":"https://api.github.com/repos/syl20bnr/spacemacs/issues/1263/labels{/name}","comments_url":"https://api.github.com/repos/syl20bnr/spacemacs/issues/1263/comments","events_url":"https://api.github.com/repos/syl20bnr/spacemacs/issues/1263/events","html_url":"https://github.com/syl20bnr/spacemacs/issues/1263","id":69447268,"number":1263,"title":"guide-key: Polling behavior kills kittens","user":{"login":"bgamari","id":1010174,"avatar_url":"https://avatars.githubusercontent.com/u/1010174?v=3","gravatar_id":"","url":"https://api.github.com/users/bgamari","html_url":"https://github.com/bgamari","followers_url":"https://api.github.com/users/bgamari/followers","following_url":"https://api.github.com/users/bgamari/following{/other_user}","gists_url":"https://api.github.com/users/bgamari/gists{/gist_id}","starred_url":"https://api.github.com/users/bgamari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgamari/subscriptions","organizations_url":"https://api.github.com/users/bgamari/orgs","repos_url":"https://api.github.com/users/bgamari/repos","events_url":"https://api.github.com/users/bgamari/events{/privacy}","received_events_url":"https://api.github.com/users/bgamari/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/syl20bnr/spacemacs/labels/bug%20:-(","name":"bug :-(","color":"fc2929"},{"url":"https://api.github.com/repos/syl20bnr/spacemacs/labels/Guide-key","name":"Guide-key","color":"207de5"},{"url":"https://api.github.com/repos/syl20bnr/spacemacs/labels/Kills%20Kittens%20(=%5E-%5E=)","name":"Kills Kittens (=^-^=)","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-04-19T17:37:54Z","updated_at":"2015-08-10T14:39:36Z","closed_at":null,"body":"Recently I noticed that each of the dozen-or-so emacs processes running on my laptop were waking up 10 times a second, severely impacting my laptop's battery life. `helm-timers` revealed that the culprit is `guide-key/polling-function`. I haven't get investigated whether this is due to spacemacs' configuration or inherent to the package but surely there is a better way to accomplish the goal of this timer than polling at 10 Hz."},"comment":{"url":"https://api.github.com/repos/syl20bnr/spacemacs/issues/comments/129477372","html_url":"https://github.com/syl20bnr/spacemacs/issues/1263#issuecomment-129477372","issue_url":"https://api.github.com/repos/syl20bnr/spacemacs/issues/1263","id":129477372,"user":{"login":"justbur","id":2208382,"avatar_url":"https://avatars.githubusercontent.com/u/2208382?v=3","gravatar_id":"","url":"https://api.github.com/users/justbur","html_url":"https://github.com/justbur","followers_url":"https://api.github.com/users/justbur/followers","following_url":"https://api.github.com/users/justbur/following{/other_user}","gists_url":"https://api.github.com/users/justbur/gists{/gist_id}","starred_url":"https://api.github.com/users/justbur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justbur/subscriptions","organizations_url":"https://api.github.com/users/justbur/orgs","repos_url":"https://api.github.com/users/justbur/repos","events_url":"https://api.github.com/users/justbur/events{/privacy}","received_events_url":"https://api.github.com/users/justbur/received_events","type":"User","site_admin":false},"created_at":"2015-08-10T14:39:36Z","updated_at":"2015-08-10T14:39:36Z","body":"@syl20bnr That's not true exactly, and I think trying to hook into a key press like that would be more intensive than what I'm doing with which-key right now. There are two ways to trigger which-key. The first is analogous to but less resource intensive than what guide-key does. The second doesn't require timers. \r\n\r\n1. guide-key uses `run-at-time` to check if you are in the middle of a key sequence (you've only pressed `C-x` for example), which will then trigger the popup. `run-at-time` is unnecessary because there's no reason to be checking IMO when emacs is not idle, so which-key uses `run-with-idle-timer` to trigger the check (in both cases the check I'm referring to is very simple and uses C-based functions), so it only kicks in if you are idle for the given amount of time (e.g., you are thinking of which key you wanted to press next). The second significant change in which-key is to turn the timer off at appropriate times, mainly when the frame loses focus, so that the timers are not running in the background when they make no sense to run. There might be some other minor differences, but those are the two main improvements, and should address this issue btw.\r\n\r\n2. The second is to use a key binding directly. So `C-x C-h` will by default popup the which-key buffer for the prefix `C-x` and pretend that only `C-x` has been pressed (use can change to another trigger key of course). So you can do something like `C-x C-h C-h C-x` which will call what you have bound to `C-x C-x`. This method doesn't require idle timers, so if you use it exclusively you can set `which-key-idle-delay` to a large number to effectively disable the timer (if there's interest in not having the timer run at all, file an issue at which-key and I'll add the option). \r\n\r\nIt's not perfect, but this is the best I could come up with in designing which-key. I'm always happy to hear from someone who has a better method of triggering which-key when the current key sequence is a [Prefix Key](https://www.gnu.org/software/emacs/manual/html_node/elisp/Prefix-Keys.html#Prefix-Keys), which is the basic problem to be solved. \r\n\r\n@bgamari Do you have an example of an elisp library that ties a function to run exactly on the second? That is, if I understand you correctly. "}}