all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* NSTRACE:  Create message indicating window and/or buffer.
@ 2017-09-07  5:07 Keith David Bershatsky
  2017-09-07  8:23 ` Anders Lindgren
  2017-09-07 14:56 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Keith David Bershatsky @ 2017-09-07  5:07 UTC (permalink / raw)
  To: Emacs Devel

I would like to insert a NSTRACE message to let me know the window and/or buffer at issue.

For example, ns_update_window_end contains a first argument of `w`.  I would like to see the pretty human readable name for that window, just like what we see when running `M-x trace-redisplay`.  The `%s` format argument requires a `char`, and rejects a Lisp_Object.

How can I achieve this feature?

Thanks,

Keith



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

* Re: NSTRACE: Create message indicating window and/or buffer.
  2017-09-07  5:07 Keith David Bershatsky
@ 2017-09-07  8:23 ` Anders Lindgren
  2017-09-07 14:56 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Anders Lindgren @ 2017-09-07  8:23 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: Emacs Devel

[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]

Hi!

Disclaimer: I really don't know that much about the internals of Emacs, so
maybe there are better ways to do this...

Anyway, after looking at the `window' structure I see no "name" field.
However, it contains a pointer to the frame, which has a name. Also, it
contains a linked list of pointers to next and previous windows. By
following the link to the previous windows until you have reached the
beginning, you can count which position number it has. Using this you can
print something like:

    window 5 on frame XXXX

Of course, you can package the argument string and the code to retrieve the
values (which may be done inline or using support functions) in macros so
that you can write something like:

    NSTRACE_MSG ("bla bla " NSTRACE_FMT_WIN, NSTRACE_ARG_WIN(w));

Or even:

    NSTRACE_WIN ("bla bla", w)

See the rest of the NSTRACE macros for inspiration.

    -- Anders

Ps. Have you seen the https://github.com/Lindydancer/nstrace package? It,
among else, contains a major mode with font-lock support that makes is
easier to read the output of NSTRACE.

On Thu, Sep 7, 2017 at 7:07 AM, Keith David Bershatsky <esq@lawlist.com>
wrote:

> I would like to insert a NSTRACE message to let me know the window and/or
> buffer at issue.
>
> For example, ns_update_window_end contains a first argument of `w`.  I
> would like to see the pretty human readable name for that window, just like
> what we see when running `M-x trace-redisplay`.  The `%s` format argument
> requires a `char`, and rejects a Lisp_Object.
>
> How can I achieve this feature?
>
> Thanks,
>
> Keith
>
>

[-- Attachment #2: Type: text/html, Size: 2247 bytes --]

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

* Re: NSTRACE:  Create message indicating window and/or buffer.
  2017-09-07  5:07 Keith David Bershatsky
  2017-09-07  8:23 ` Anders Lindgren
@ 2017-09-07 14:56 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2017-09-07 14:56 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: emacs-devel

> Date: Wed, 06 Sep 2017 22:07:53 -0700
> From: Keith David Bershatsky <esq@lawlist.com>
> 
> I would like to insert a NSTRACE message to let me know the window and/or buffer at issue.
> 
> For example, ns_update_window_end contains a first argument of `w`.  I would like to see the pretty human readable name for that window, just like what we see when running `M-x trace-redisplay`.  The `%s` format argument requires a `char`, and rejects a Lisp_Object.
> 
> How can I achieve this feature?

Something like this should work:

  if (BUFFERP (w->contents) && STRINGP (BVAR (XBUFFER (w->contents), name)))
    fprintf (stderr, "window %s\n", SSDATA (BVAR (XBUFFER (w->contents), name));

This prints the name of the buffer shown in the window.



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

* Re: NSTRACE:  Create message indicating window and/or buffer.
@ 2017-09-07 16:34 Keith David Bershatsky
  0 siblings, 0 replies; 4+ messages in thread
From: Keith David Bershatsky @ 2017-09-07 16:34 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Anders Lindgren, emacs-devel

Printing to stderr achieves the desired result -- thank you very much!  I wrapped it in an NSTRACE_ENABLED condition:

#if NSTRACE_ENABLED
  if (BUFFERP (w->contents) && STRINGP (BVAR (XBUFFER (w->contents), name)))
    fprintf (stderr, "window %s\n", SSDATA (BVAR (XBUFFER (w->contents), name)));
#endif

Thank you also to Anders for taking an interest in this thread.  Your assistance is always greatly appreciated.

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DATE:  [09-07-2017 07:56:04] <07 Sep 2017 17:56:04 +0300>
FROM:  Eli Zaretskii <eliz@gnu.org>
> 
> * * * 
> 
>   if (BUFFERP (w->contents) && STRINGP (BVAR (XBUFFER (w->contents), name)))
>     fprintf (stderr, "window %s\n", SSDATA (BVAR (XBUFFER (w->contents), name));
> 
> This prints the name of the buffer shown in the window.



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

end of thread, other threads:[~2017-09-07 16:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-07 16:34 NSTRACE: Create message indicating window and/or buffer Keith David Bershatsky
  -- strict thread matches above, loose matches on Subject: below --
2017-09-07  5:07 Keith David Bershatsky
2017-09-07  8:23 ` Anders Lindgren
2017-09-07 14:56 ` Eli Zaretskii

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.