[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (newbie) checking for which buffers are visible to the user
From: |
Stuart McLean |
Subject: |
Re: (newbie) checking for which buffers are visible to the user |
Date: |
Sun, 16 Sep 2007 17:18:51 GMT |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
> I have bound f6 to bring up the calendar. Here is what I would like to
> do. If the calendar is not visible to me, make it visible. However, if
> I can see it, I would like to bury the calendar buffer. I am not sure
> the most effective way to check if a buffer is visible to the user
> (me) and how to write a function that takes advantage of this.
>> ,----[ C-h f get-buffer-window RET ]
>> | get-buffer-window is a built-in function in `C source code'.
>> | (get-buffer-window BUFFER &optional FRAME)
>> |
>> | Return a window currently displaying BUFFER, or nil if none.
>> | BUFFER can be a buffer or a buffer name.
>> | If optional argument FRAME is `visible', search all visible frames.
>> | If optional argument FRAME is 0, search all visible and iconified frames.
>> | If FRAME is t, search all frames.
>> | If FRAME is nil, search only the selected frame.
>> | If FRAME is a frame, search only that frame.
>> `----
Thanks, Tassilo.
Sorry for the the delayed response. Here is what I came up with:
(defun smc-calendar-display-or-bury ()
"Display the Calendar, or if displayed, bury it."
(interactive)
(if (get-buffer-window "*Calendar*" t)
(delete-window (get-buffer-window "*Calendar*"))
(calendar)))
Thanks again,
Stuart