From: Matthias Pfeifer <matthias-pfeifer@outlook.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: How do i say it in emacs lisp
Date: Mon, 28 Nov 2016 11:50:32 +0000 [thread overview]
Message-ID: <VI1PR0601MB20150977E608E131560FC719858A0@VI1PR0601MB2015.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <20161128092100.GA23484@tuxteam.de>
Hi Tomas,
thanks for the general clarification. I was suspecting hooks to be the way to go. However I was running in some sort of recursion (i guess) until i figured out to temporarily set my hook to nil. This is what I fiddled together: My plan is to have a package called "neotree" update it's buffer whenever another window's buffer is switched and the selected frame's configuration matches a certain layout. Let me try to re-phrase: When the current frame hosts two windows. And any of these windows is showing the neotree buffer and other window's buffers is switched then I want neotree to go to the buffers file.
Here is my elisp:
(defun mp:neotree-updater ()
(when (eq 2 (length (window-list)))
(let* ((wnd-0 (nth 0 (window-list)))
(wnd-1 (nth 1 (window-list)))
(buf-0 (window-buffer wnd-0))
(buf-1 (window-buffer wnd-1))
(neo-buf nil)
(other-buf nil)
(neo-wnd nil)
(other-wnd nil)
(filename nil)
(neo-buffer (get-buffer " *NeoTree*")))
(when (and neo-buffer
(or (eq buf-0 neo-buffer)
(eq buf-1 neo-buffer)))
(progn
(if (eq buf-0 neo-global--buffer)
(setq neo-buf buf-0
other-buf buf-1
neo-wnd wnd-0
other-wnd wnd-1)
(setq neo-buf buf-1
other-buf buf-0
neo-wnd wnd-1
other-wnd wnd-0))
(setq filename (buffer-file-name other-buf))
(when (and filename
(file-exists-p filename))
(progn
(setq mp:neotree-go-to-dir filename)
(let ((buffer-list-update-hook buffer-list-update-hook))
(neotree-find filename)
(select-window other-wnd)))))))))
;; (add-hook 'buffer-list-update-hook 'mp:neotree-updater)
;; (remove-hook 'buffer-list-update-hook 'mp:neotree-updater)
It seems to be working the way I expected it. Second opinion is welcome :-)
Matthias Pfeifer
next prev parent reply other threads:[~2016-11-28 11:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAPzsW6jZpzKKfy3u0tghOQgeZM9qOoLBH3U5EDpjOFB9GwNHXQ@mail.gmail.com>
[not found] ` <CAPzsW6i3UHiAyWFGKrf=pa3B91ZFqgnAT2+vmg=S-agCRi7vZg@mail.gmail.com>
[not found] ` <CAPzsW6j+8W+i0t_CvDz0BEa6diG+z7YiDi7rJfsiknbLYmK3=A@mail.gmail.com>
[not found] ` <CAPzsW6jdmQkqQwA7wPaPNEA4Ayef7Vm+s1jxVH_Z4zHCWKLyMg@mail.gmail.com>
[not found] ` <CAPzsW6hrvFGVyodjd5Zg83-8ZE3s94EDfv28NQRWoRszOoUPKg@mail.gmail.com>
[not found] ` <CAPzsW6j2iip9LbqC4zs2g39yvS-VpT-bm0cnhUL3arxC1va7_Q@mail.gmail.com>
[not found] ` <CAPzsW6jx0LcsPaTmdoLBjgJSAOw_ytk7e4YqGpo+UwA7+Ou7mA@mail.gmail.com>
[not found] ` <CAPzsW6gvO4jExpo=V5vyu+Zw+04nL808sJwLwVnOrFKkj16zWQ@mail.gmail.com>
2016-11-27 20:46 ` How do i say it in emacs lisp Matthias Pfeifer
2016-11-28 9:21 ` tomas
2016-11-28 11:50 ` Matthias Pfeifer [this message]
2016-11-28 20:12 ` tomas
2016-12-21 18:19 ` Thien-Thi Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=VI1PR0601MB20150977E608E131560FC719858A0@VI1PR0601MB2015.eurprd06.prod.outlook.com \
--to=matthias-pfeifer@outlook.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.