unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Heime <heimeborgia@protonmail.com>
To: Yuri Khan <yuri.v.khan@gmail.com>
Cc: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Re: Print value of selected-window in some info buffer
Date: Wed, 15 May 2024 11:52:23 +0000	[thread overview]
Message-ID: <rUurlRZ-SlHddY9nn5EMLp1y0DEmfUxoIu_dbdNvLZaO93VSGjGdPbT2EneDVTvN17vALlAdBjux8uZD5c7xJVGTGPm0MJ4eskoOPzt-ViE=@protonmail.com> (raw)
In-Reply-To: <CAP_d_8W-k1_NT1hOwZd=b1Bw0NjVB+FiEO1A3WeF4W8ByrCdoQ@mail.gmail.com>

On Wednesday, May 15th, 2024 at 5:25 PM, Yuri Khan <yuri.v.khan@gmail.com> wrote:

> On Wed, 15 May 2024 at 04:26, Heime heimeborgia@protonmail.com wrote:
> 
> > How can the value of selected-window be printed in some info buffer ?
> > 
> > Because I get a failure with (bdrive-insert (selected-window))
> 
> 
> You are passing a window here…
> 
> > (defun bdrive-insert (objekt)
> > "TODO"
> > 
> > (with-current-buffer (get-buffer-create bfname)
> > 
> > (cond
> > ((stringp objekt)
> 
> 
> … but here you test objekt for being a string, and if not, you skip
> the insertion.
> 
> > (insert (concat objekt "\n" ))) )))
> 
> 
> If you want to print the window object’s default string
> representation, like ‘#<window 669 on scratch>’, remove the stringp
> 
> test and use:
> 
> (insert (format "%s\n" objekt))

I want to print the string representation.  The function will perform
something for a string, something else for an integer, ...

How can one capture a window such as (selected-window) with a cond ?
 
> If you want to print specific properties of the window, extract those
> with the appropriate ‘window-*’ functions and pass them into ‘format’.
> Provide placeholders in the format string for each value you print.
> 
> 
> Also, learn to use the debugger so you can solve this and similar
> issues yourself. Anywhere within the ‘bdrive-insert’ definition, type
> ‘C-u C-M-x’. This instruments your function to invoke the debugger
> when called. Next, evaluate your ‘(bdrive-insert (selected-window))’
> form. You get a window showing the function source, with point on the
> first subexpression to be evaluated, likely ‘bfname’, echo area
> showing its value. Type ‘n’ for ‘next’. Point moves to the next
> expression in evaluation order. Do this until you get to ‘objekt’
> (showing ‘#<window 669 on scratch>’) and then ‘(stringp objekt)’
> 
> (showing ‘nil’). At this point, you can see that a window is not a
> string.



  reply	other threads:[~2024-05-15 11:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 21:25 Print value of selected-window in some info buffer Heime
2024-05-14 23:50 ` tpeplt
2024-05-15  0:05   ` Heime
2024-05-15  5:25 ` Yuri Khan
2024-05-15 11:52   ` Heime [this message]
2024-05-15 13:14     ` tpeplt

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='rUurlRZ-SlHddY9nn5EMLp1y0DEmfUxoIu_dbdNvLZaO93VSGjGdPbT2EneDVTvN17vALlAdBjux8uZD5c7xJVGTGPm0MJ4eskoOPzt-ViE=@protonmail.com' \
    --to=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=yuri.v.khan@gmail.com \
    /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.
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).