all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: frames dedicated to buffers, or, always see specific buffers in a specific frame
@ 2013-04-12  9:28 martin rudalics
  2013-04-12 12:12 ` João Távora
  0 siblings, 1 reply; 14+ messages in thread
From: martin rudalics @ 2013-04-12  9:28 UTC (permalink / raw)
  To: joaotavora; +Cc: help-gnu-emacs

 > (defadvice switch-to-buffer (around joaot/browse-buffer-maybe activate)
 >   (if (joaot/browse-buffer-p buffer-or-name nil)
 >       (display-buffer buffer-or-name)
 >     ad-do-it))
 >
 > Does anyone know of a less hackish way to do this? The defadvice is
 > particularly nasty... Do you see this breaking anything important that
 > I'm not seeing??

`switch-to-buffer' uses `pop-to-buffer' to make sure the window
displaying the buffer is selected.  You use `display-buffer' which
doesn't necessarily make the window selected - IIUC you rely on the
window manager to select the window.

Other from that I don't see anything hackish with your approach if the
idea is to make `switch-to-buffer' do what you want when it's called
from other code (which ideally should not happen).  In this case you
might also want to advice `switch-to-buffer-other-window' accordingly.

Interactively, you obviously should define your own function and bind it
to C-x b.

martin








^ permalink raw reply	[flat|nested] 14+ messages in thread
* frames dedicated to buffers, or, always see specific buffers in a specific frame
@ 2013-04-10 20:52 João Távora
  2013-04-10 21:30 ` Steven Degutis
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: João Távora @ 2013-04-10 20:52 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org List

So I needed to scratch a code-browsing itch and came up with this monster:

(defvar joaot/browse-frame)
(setq joaot/browse-frame (new-frame))
(setq display-buffer-alist
      `((joaot/browse-buffer-p . (joaot/browse-buffer-in-special-frame . nil))))

(defun joaot/browse-buffer-p (buffer action)
  (declare (ignore action))
  (let ((buffer (and buffer
                     (get-buffer buffer))))
    (and (frame-live-p joaot/browse-frame)
         buffer
         (buffer-file-name buffer)
         (string-match "someproject" (buffer-file-name buffer)))))

(defun joaot/browse-buffer-in-special-frame (buffer alist)
  (let ((window (frame-selected-window joaot/browse-frame)))
    (window--display-buffer buffer window 'reuse alist)))

(defadvice switch-to-buffer (around joaot/browse-buffer-maybe activate)
  (if (joaot/browse-buffer-p buffer-or-name nil)
      (display-buffer buffer-or-name)
    ad-do-it))

Do you see what it is doing? Whenever I switch to a buffer or file
belonging to "someproject", which I only want to read, it makes sure
the buffer is displayed in a special "browse-frame" created beforehand
and that lives in my secondary monitor.

This is not quite "dedicated windows". It's sort of frames dedicated
to buffers.

Does anyone know of a less hackish way to do this? The defadvice is
particularly nasty... Do you see this breaking anything important that
I'm not seeing??

Thanks in advance,
J

PS: yes I refuse to open a secondary emacs instance on principle :-)



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-04-15  7:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-12  9:28 frames dedicated to buffers, or, always see specific buffers in a specific frame martin rudalics
2013-04-12 12:12 ` João Távora
2013-04-12 13:13   ` João Távora
2013-04-12 14:15   ` martin rudalics
     [not found]     ` <CALDnm50Q=eNA6rgUS-DQD2RLuE=kyizGpYWyENVU=2Py+-MTig@mail.gmail.com>
2013-04-14 18:42       ` João Távora
2013-04-15  7:11         ` martin rudalics
2013-04-12 16:45   ` Stefan Monnier
2013-04-13  8:01     ` martin rudalics
2013-04-14 18:18     ` João Távora
  -- strict thread matches above, loose matches on Subject: below --
2013-04-10 20:52 João Távora
2013-04-10 21:30 ` Steven Degutis
2013-04-11  1:22   ` João Távora
2013-04-11 12:42 ` Stefan Monnier
2013-04-11 12:46 ` Stefan Monnier

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.