help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: frames dedicated to buffers, or, always see specific buffers in a sp


From: João Távora
Subject: Re: frames dedicated to buffers, or, always see specific buffers in a specific frame
Date: Thu, 11 Apr 2013 02:22:47 +0100

On Wed, Apr 10, 2013 at 10:30 PM, Steven Degutis <sbdegutis@gmail.com> wrote:
> Depending on why you want this behavior, you might find this project useful:
> https://github.com/sdegutis/project-buffers.el

Thanks, but this quite unrelated to what I'm asking for.

I want Emacs to always display certain buffers in a different Emacs
frame. The (string-match "someproject" ...) dummy example I provided
is just one of many possible criteria for selecting buffers, it could
be something completely different, like read-only buffers, for
example.


>
> On Wed, Apr 10, 2013 at 3:52 PM, João Távora <joaotavora@gmail.com> wrote:
>>
>> 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 :-)
>>
>



-- 
João Távora



reply via email to

[Prev in Thread] Current Thread [Next in Thread]