Closed yantar92 closed 1 year ago
Ok. Or perhaps print into a separate "popup" buffer?
Mariano Montone @.***> writes:
Ok. Or perhaps print into a separate buffer?
Might be an option.
I have two examples of similar functionality in mind:
`notmuch-show-view-raw-message', which displays a new buffer with raw email message in a new buffer and the same window
`image-toggle-display', which toggles two representations
-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92
The popup buffer would be easier for me to implement. And also that's how SLIME inspector does it, which this inspector is a bit inspired on. I'll implement an inspector-print-current-object command, bound to 'p' letter, and see if that's sufficient.
I've pushed a inspector-pprint-inspected-object
command bound to letter P
. Please let me know if something like this is what you wanted.
- `notmuch-show-view-raw-message', which displays a new buffer with raw email message in a new buffer and the same window
In current implementation, it doesn't work like that by default. But if you set: (pushnew "*inspector pprint*" same-window-buffer-names)
, then it works like that. Use q
to kill the pprint buffer.
Mariano Montone @.***> writes:
I've pushed a
inspector-pprint-inspected-object
bound to letterP
. Please let me know if something like this is what you wanted.
Thanks!
Looks good, except that the printed width spans wider than window for
some reason. Maybe something to do with window not yet being displayed
when calling pp
.
-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92
Do you have a screenshot of that?
This happens when I try to inspect and pprint load-path
for example:
You mean the content in the buffer below?
Let's say I do this (display buffer, then pprint):
(let ((buffer (generate-new-buffer "*my-buffer*")))
(display-buffer buffer)
(with-current-buffer buffer
(insert (pp load-path))))
I'm getting same result.
Mariano Montone @.***> writes:
Do you have a screenshot of that?
I can make one, but I think yours demonstrate the problem clearly.
This happens when I try to inspect and pprint
load-path
for example:You mean the content in the buffer below?
Yup.
-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92
Perhaps there's some pprint function that takes window dimensions as parameter. Current pp function I'm using takes none apart from the object to print.
Let's say I do this (display buffer, then pprint):
(let ((buffer (generate-new-buffer "*my-buffer*"))) (display-buffer buffer) (with-current-buffer buffer (insert (pp load-path))))
I'm getting same result.
There's a pp-max-width
variable that pp looks at, but still get same result. I need to dig a bit more.
Mariano Montone @.***> writes:
Perhaps there's some pprint function that takes window dimensions as parameter. Current pp function I'm using takes none apart from the object to print.
In theory, it should be sufficient to set pp-use-max-width
to non-nil
(which I did). But it does not work for some reason.
The following does work though
(let ((buffer (generate-new-buffer "my-buffer"))) (display-buffer buffer) (let ((pp-use-max-width t) (pp-max-width t)) (pp load-path buffer)))
-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92
Thanks! I'll give it a try.
One thing to consider: those variables appear with version = 29.1 in my Emacs:
(defcustom pp-max-width t
"Max width to use when formatting.
If nil, there's no max width. If t, use the window width.
Otherwise this should be a number."
:type '(choice (const :tag "none" nil)
(const :tag "window width" t)
number)
:version "29.1")
(defcustom pp-use-max-width nil
"If non-nil, `pp'-related functions will try to fold lines.
The target width is given by the `pp-max-width' variable."
:type 'boolean
:version "29.1")
Also I'm considering defining custom variables for controlling pprint for the inspector, so as to not force things on the user. With defaults to current pp- vars defaults. Like this:
(defcustom inspector-pp-max-width pp-max-width
"Max width to use when inspector pretty printing of objects.
If nil, there's no max width. If t, use the window width.
Otherwise this should be a number.
See `pp-max-width'"
:type '(choice (const :tag "none" nil)
(const :tag "window width" t)
number)
:group 'inspector)
(defcustom inspector-pp-use-max-width pp-use-max-width
"If non-nil, `pp'-related functions will try to fold lines.
The target width is given by the `pp-max-width' variable."
:type 'boolean
:group 'inspector)
Or I should just force the use-max-width ?
Also I'm considering defining custom variables for controlling pprint for the inspector, so as to not force things on the user.
For instance, the pretty printing of long lists when use-max-width is on, takes lots of time (it didn't even finished in my machine.)
I've pushed a version that uses customization variables inspector-pp-*
that you need to set.
Mariano Montone @.***> writes:
I've pushed a version that uses customization variables
inspector-pp-*
that you need to set.
Thanks!
-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92
I have been trying to use
inspector-inspect-last-sexp
instead of the usualeval-print-last-sexp
. It is generally nice to look through expression structure. However, I sometimes miss the ability to copy parts of the original sexp for further use.It would be nice to be able to view "raw" expression in current inspector buffer or maybe even toggle between raw and structured representations.