unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* (newbie) checking for which buffers are visible to the user
@ 2007-09-11 13:49 Stuart McLean
  2007-09-11 14:02 ` Tassilo Horn
  2007-09-12 19:08 ` Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Stuart McLean @ 2007-09-11 13:49 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

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.

Does anyone have any pointers? I have spent several hours checking the
documentation of several window and buffer related functions, but none
of them (I think) seems to do what I want. Any help would be very
welcome. 

Thanks,

Stuart

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

* Re: (newbie) checking for which buffers are visible to the user
  2007-09-11 13:49 (newbie) checking for which buffers are visible to the user Stuart McLean
@ 2007-09-11 14:02 ` Tassilo Horn
  2007-09-16 17:18   ` Stuart McLean
  2007-09-12 19:08 ` Tom Tromey
  1 sibling, 1 reply; 4+ messages in thread
From: Tassilo Horn @ 2007-09-11 14:02 UTC (permalink / raw)
  To: help-gnu-emacs

Stuart McLean <makhector@gmail.com> writes:

Hi,

> 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.
`----

HTH,
Tassilo
-- 
* delYsid has mortgage, opportunity and penis in his score file.
<delYsid> thats pretty effective against spam
<Luke> aren't you worried about missing opportunities to mortgage
       your penis?

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

* Re: (newbie) checking for which buffers are visible to the user
  2007-09-11 13:49 (newbie) checking for which buffers are visible to the user Stuart McLean
  2007-09-11 14:02 ` Tassilo Horn
@ 2007-09-12 19:08 ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2007-09-12 19:08 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> "Stuart" == Stuart McLean <makhector@gmail.com> writes:

Stuart> I have bound f6 to bring up the calendar. Here is what I would like to
Stuart> do. If the calendar is not visible to me, make it visible. However, if
Stuart> I can see it, I would like to bury the calendar buffer. I am not sure
Stuart> the most effective way to check if a buffer is visible to the user
Stuart> (me) and how to write a function that takes advantage of this.

Iterate over the results of get-buffer-window-list and see if any of
the windows' frames are visible.

I think stuff like this may give weird results if you're using
multi-tty.  E.g., code like this could say that something is "visible"
but you might be using a terminal frame and not be able to physically
see the X frame where the buffer is displayed.  I'm not sure what to
do about this.

Tom

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

* Re: (newbie) checking for which buffers are visible to the user
  2007-09-11 14:02 ` Tassilo Horn
@ 2007-09-16 17:18   ` Stuart McLean
  0 siblings, 0 replies; 4+ messages in thread
From: Stuart McLean @ 2007-09-16 17:18 UTC (permalink / raw)
  To: help-gnu-emacs



> 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

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

end of thread, other threads:[~2007-09-16 17:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-11 13:49 (newbie) checking for which buffers are visible to the user Stuart McLean
2007-09-11 14:02 ` Tassilo Horn
2007-09-16 17:18   ` Stuart McLean
2007-09-12 19:08 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).