all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Print value of selected-window in some info buffer
@ 2024-05-14 21:25 Heime
  2024-05-14 23:50 ` tpeplt
  2024-05-15  5:25 ` Yuri Khan
  0 siblings, 2 replies; 6+ messages in thread
From: Heime @ 2024-05-14 21:25 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

How can the value of selected-window be printed in some info buffer ?

Because I get a failure with (bdrive-insert (selected-window))

(defun bdrive-insert (objekt)
  "TODO"

  (with-current-buffer (get-buffer-create bfname)

    (cond
      ((stringp objekt)
         (insert (concat objekt "\n" ))) )))







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

* Re: Print value of selected-window in some info buffer
  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
  1 sibling, 1 reply; 6+ messages in thread
From: tpeplt @ 2024-05-14 23:50 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

Heime <heimeborgia@protonmail.com> writes:

> How can the value of selected-window be printed in some info buffer ?
>
> Because I get a failure with (bdrive-insert (selected-window))
>
> (defun bdrive-insert (objekt)
>   "TODO"
>
>   (with-current-buffer (get-buffer-create bfname)
>
>     (cond
>       ((stringp objekt)
>          (insert (concat objekt "\n" ))) )))

1. It would be helpful if you would include with your question the error
   that was reported.

2. Have you attempted to compile the buffer or file in which your
   function definition resides?  Have you attempted to include a call to
   your function in a file with the function definition and compile that
   buffer?  Compilation will often point out mistakes and oversights in
   your code.

-- 
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.



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

* Re: Print value of selected-window in some info buffer
  2024-05-14 23:50 ` tpeplt
@ 2024-05-15  0:05   ` Heime
  0 siblings, 0 replies; 6+ messages in thread
From: Heime @ 2024-05-15  0:05 UTC (permalink / raw)
  To: tpeplt; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

On Wednesday, May 15th, 2024 at 11:50 AM, tpeplt <tpeplt@gmail.com> wrote:

> Heime heimeborgia@protonmail.com writes:
> 
> > How can the value of selected-window be printed in some info buffer ?
> > 
> > Because I get a failure with (bdrive-insert (selected-window))
> > 
> > (defun bdrive-insert (objekt)
> > "TODO"
> > 
> > (with-current-buffer (get-buffer-create bfname)
> > 
> > (cond
> > ((stringp objekt)
> > (insert (concat objekt "\n" ))) )))
> 
> 
> 1. It would be helpful if you would include with your question the error
> that was reported.
> 
> 2. Have you attempted to compile the buffer or file in which your
> function definition resides? Have you attempted to include a call to
> your function in a file with the function definition and compile that
> buffer? Compilation will often point out mistakes and oversights in
> your code.

I just don't get anything printed
 
> --
> The lyf so short, the craft so long to lerne.
> - Geoffrey Chaucer, The Parliament of Birds.



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

* Re: Print value of selected-window in some info buffer
  2024-05-14 21:25 Print value of selected-window in some info buffer Heime
  2024-05-14 23:50 ` tpeplt
@ 2024-05-15  5:25 ` Yuri Khan
  2024-05-15 11:52   ` Heime
  1 sibling, 1 reply; 6+ messages in thread
From: Yuri Khan @ 2024-05-15  5:25 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

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.



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

* Re: Print value of selected-window in some info buffer
  2024-05-15  5:25 ` Yuri Khan
@ 2024-05-15 11:52   ` Heime
  2024-05-15 13:14     ` tpeplt
  0 siblings, 1 reply; 6+ messages in thread
From: Heime @ 2024-05-15 11:52 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Heime via Users list for the GNU Emacs text editor

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.



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

* Re: Print value of selected-window in some info buffer
  2024-05-15 11:52   ` Heime
@ 2024-05-15 13:14     ` tpeplt
  0 siblings, 0 replies; 6+ messages in thread
From: tpeplt @ 2024-05-15 13:14 UTC (permalink / raw)
  To: Heime; +Cc: Yuri Khan, Heime via Users list for the GNU Emacs text editor

Heime <heimeborgia@protonmail.com> writes:

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

Note that examples using the debugger are included in the Introduction
to Emacs Lisp.  To read the chapter on debugging, evaluate the following
expression in Emacs:

   (info "(eintr) Debugging")

It might also be useful to look at the buffer functions in the
‘shortdoc’ summary.  To read it, evaluate the following expression in
Emacs:

   (shortdoc-display-group "buffer")

‘shortdoc’ was introduced in Emacs 28, so it is not available if you are
using an earlier version of Emacs.

-- 
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.



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

end of thread, other threads:[~2024-05-15 13:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-05-15 13:14     ` tpeplt

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.