{"action":"opened","issue":{"url":"https://api.github.com/repos/abo-abo/hydra/issues/169","labels_url":"https://api.github.com/repos/abo-abo/hydra/issues/169/labels{/name}","comments_url":"https://api.github.com/repos/abo-abo/hydra/issues/169/comments","events_url":"https://api.github.com/repos/abo-abo/hydra/issues/169/events","html_url":"https://github.com/abo-abo/hydra/issues/169","id":114258652,"number":169,"title":"Possible race condition between :post and foreign key action?","user":{"login":"larkery","id":1721963,"avatar_url":"https://avatars.githubusercontent.com/u/1721963?v=3","gravatar_id":"","url":"https://api.github.com/users/larkery","html_url":"https://github.com/larkery","followers_url":"https://api.github.com/users/larkery/followers","following_url":"https://api.github.com/users/larkery/following{/other_user}","gists_url":"https://api.github.com/users/larkery/gists{/gist_id}","starred_url":"https://api.github.com/users/larkery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larkery/subscriptions","organizations_url":"https://api.github.com/users/larkery/orgs","repos_url":"https://api.github.com/users/larkery/repos","events_url":"https://api.github.com/users/larkery/events{/privacy}","received_events_url":"https://api.github.com/users/larkery/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-30T12:16:01Z","updated_at":"2015-10-30T12:16:01Z","closed_at":null,"body":"I have a hydra set up like this (minimal-ish example)\r\n\r\n```elisp\r\n(bind-key \"#\" nil)\r\n(defvar did-something 0)\r\n(defvar did-where nil)\r\n(defhydra hydra-hash \r\n  (:exit\r\n   t\r\n   :idle\r\n   0.5\r\n   :pre\r\n   (progn (cl-incf did-something)\r\n          (setq did-where (current-buffer)))\r\n   :post\r\n   (progn\r\n     (unless (> did-something 1)\r\n       (with-current-buffer did-where (insert \"#\")))\r\n     (setq did-something 0 did-where nil))\r\n   )\r\n  (\"a\" (message \"hello world\")))\r\n(bind-key \"#\" hydra-hash/body)\r\n```\r\n\r\nThe hope is to make it so that if I type (for example) `#'` it inserts `#` because of `:post` and then the foreign key command fires which is `self-insert-command` with `'`.\r\n\r\nThis is because I don't type # very often, so I can use it as a prefix for dispatching some commands I do frequently, but by avoiding binding things that I do write after # somethings (like the quote char for lisp function-quote) I can still just type those.\r\n\r\nWhat I find is that this mostly works, but sometimes the # is inserted _after_ the foreign key rather than before. The difference seems to depend on what frame I am in - if I view the same buffer in two frames, it will (somtimes) reliably do the insertions in one order in one frame and in another order in the second frame. I presume there is a loop over buffers or over frames somewhere (I added the current-buffer because sometimes it would otherwise insert into a different buffer).\r\n\r\nAm I doing something insane? Is there a way to make this not mad? Can the `:post` command be made to execute in the current buffer and definitely before the foreign key is typed?\r\n\r\nMany thanks,\r\n\r\nTom"}}