{"action":"created","issue":{"url":"https://api.github.com/repos/syohex/emacs-anzu/issues/58","labels_url":"https://api.github.com/repos/syohex/emacs-anzu/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/syohex/emacs-anzu/issues/58/comments","events_url":"https://api.github.com/repos/syohex/emacs-anzu/issues/58/events","html_url":"https://github.com/syohex/emacs-anzu/issues/58","id":102920011,"number":58,"title":"anzu--state is global","user":{"login":"blaenk","id":84680,"avatar_url":"https://avatars.githubusercontent.com/u/84680?v=3","gravatar_id":"","url":"https://api.github.com/users/blaenk","html_url":"https://github.com/blaenk","followers_url":"https://api.github.com/users/blaenk/followers","following_url":"https://api.github.com/users/blaenk/following{/other_user}","gists_url":"https://api.github.com/users/blaenk/gists{/gist_id}","starred_url":"https://api.github.com/users/blaenk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blaenk/subscriptions","organizations_url":"https://api.github.com/users/blaenk/orgs","repos_url":"https://api.github.com/users/blaenk/repos","events_url":"https://api.github.com/users/blaenk/events{/privacy}","received_events_url":"https://api.github.com/users/blaenk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-25T00:28:06Z","updated_at":"2015-08-25T05:46:40Z","closed_at":null,"body":"I'm new to emacs so I'm not entirely sure, but I'm configuring the mode-line myself instead of using the default consing mechanism. So I set `anzu-mode-line-update-function` to my own function and `anzu-cons-mode-line-p` to nil. It works well. The only (major) problem is that if I search in one buffer, all of them show the same information with respect to anzu, in the mode-line.\r\n\r\nI believe this is because the `anzu--state` variable is global, which is what I use to determine if the anzu stuff should be shown in my mode-line. It happens to work out fine in the default mechanism because it's only checked once to determine whether or not to cons the anzu stuff to the buffer-local mode-line. However, if you don't use a cons mechanism or otherwise update the mode-line once in response to anzu, then all of the windows will show this.\r\n\r\nI managed to resolve this by doing this:\r\n\r\n``` elisp\r\n(add-hook 'anzu-mode-hook (lambda () (make-local-variable 'anzu--state)))\r\n```\r\n\r\nNow my mode-line is working as expected: searching in one buffer in a window won't set the anzu stuff in my mode-line for every window. I'm not sure if this is the preferred way to fix this though."},"comment":{"url":"https://api.github.com/repos/syohex/emacs-anzu/issues/comments/134488194","html_url":"https://github.com/syohex/emacs-anzu/issues/58#issuecomment-134488194","issue_url":"https://api.github.com/repos/syohex/emacs-anzu/issues/58","id":134488194,"user":{"login":"blaenk","id":84680,"avatar_url":"https://avatars.githubusercontent.com/u/84680?v=3","gravatar_id":"","url":"https://api.github.com/users/blaenk","html_url":"https://github.com/blaenk","followers_url":"https://api.github.com/users/blaenk/followers","following_url":"https://api.github.com/users/blaenk/following{/other_user}","gists_url":"https://api.github.com/users/blaenk/gists{/gist_id}","starred_url":"https://api.github.com/users/blaenk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blaenk/subscriptions","organizations_url":"https://api.github.com/users/blaenk/orgs","repos_url":"https://api.github.com/users/blaenk/repos","events_url":"https://api.github.com/users/blaenk/events{/privacy}","received_events_url":"https://api.github.com/users/blaenk/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T05:46:40Z","updated_at":"2015-08-25T05:46:40Z","body":"Ah I don't have time currently to do that, so don't worry about it since it seems like it doesn't affect many other people, feel free to close it.\r\n\r\nBasically if I do something like:\r\n\r\n``` elisp\r\n(setq anzu-cons-mode-line-p nil)\r\n```\r\n\r\nSo that now I can choose where the anzu information should show up, for example:\r\n\r\n``` elisp\r\n(setq-default mode-line-format '((anzu-mode (:eval (anzu--update-mode-line)))))\r\n```\r\n\r\nThat uses the default mode-line setting format, which only draws the anzu stuff if `anzu--state` is set. Normally what happens if you don't have `anzu-cons-mode-line-p` set to nil, is that you go into search mode, then it performs the cons to the current mode line and sets `anzu--state` to non-nil, so even though `anzu--state` is global, when you switch to another window it won't render the anzu stuff because to do so it'd have to cons, and it already consed in the other window (since mode-line-format is buffer local).\r\n\r\nWhen you disable consing, what happens is that it sets `anzu--state` to non-nil and calls your mode-line update function, which is great, but then if I switch to the other window/buffer, the mode-line-format will check to see if `anzu--state` is non-nil to determine whether or not to show anzu info, and it _will_ be non-nil because the other buffer set it to non-nil, and it's global.\r\n\r\nHope that was a bit clearer. It was a simple fix on my end, I imagine it'd be simple to just make it buffer local in this package, but I don't know if that would have unintended consequences. In the meantime the fix on my end works well."}}