unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: Heime <heimeborgia@protonmail.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 12:25:22 +0700	[thread overview]
Message-ID: <CAP_d_8W-k1_NT1hOwZd=b1Bw0NjVB+FiEO1A3WeF4W8ByrCdoQ@mail.gmail.com> (raw)
In-Reply-To: <itcrHKG-zi-AKyOy0wvgLLGS7rPv8VLyFNaKJukOG0_IwtmGd-77DRCxEpGrdR2rlIW4zT1rGSBZpelX__NNwdyK8_mR8cr6JrMhwXR1hcI=@protonmail.com>

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))

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.



  parent reply	other threads:[~2024-05-15  5:25 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 [this message]
2024-05-15 11:52   ` Heime
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='CAP_d_8W-k1_NT1hOwZd=b1Bw0NjVB+FiEO1A3WeF4W8ByrCdoQ@mail.gmail.com' \
    --to=yuri.v.khan@gmail.com \
    --cc=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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).