unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#32978: 26.1; newline-and-indent duplicates displayed image
@ 2018-10-07 21:14 Markus Triska
  2018-10-14 14:38 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Triska @ 2018-10-07 21:14 UTC (permalink / raw)
  To: 32978


Please download test.png from:

    https://www.metalevel.at/ei/test.png

and then invoke Emacs as follows:

    $ emacs -Q --eval='(progn (insert-image-file "test.png")
                              (forward-char)
                              (newline-and-indent))'

As a result, test.png is displayed twice, both in line 1 and in line 2.

In this case, I expect test.png to be displayed only in line 1.

In GNU Emacs 26.1 (build 1, i686-pc-linux-gnu, X toolkit, Xaw scroll bars)
 of 2018-05-29 built on debian
Repository revision: 07f8f9bc5a51f5aa94eb099f3e15fbe0c20ea1ea
Windowing system distributor 'The X.Org Foundation', version 11.0.11902000
System Description:	Debian GNU/Linux 9.2 (stretch)






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

* bug#32978: 26.1; newline-and-indent duplicates displayed image
  2018-10-07 21:14 bug#32978: 26.1; newline-and-indent duplicates displayed image Markus Triska
@ 2018-10-14 14:38 ` Eli Zaretskii
  2018-10-14 20:40   ` Markus Triska
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2018-10-14 14:38 UTC (permalink / raw)
  To: Markus Triska; +Cc: 32978

> From: Markus Triska <triska@metalevel.at>
> Date: Sun, 07 Oct 2018 23:14:56 +0200
> 
> 
>     $ emacs -Q --eval='(progn (insert-image-file "test.png")
>                               (forward-char)
>                               (newline-and-indent))'
> 
> As a result, test.png is displayed twice, both in line 1 and in line 2.
> 
> In this case, I expect test.png to be displayed only in line 1.

Not sure why you expected that.  Perhaps you thought that forward-char
will move to after the image?  But that is a feature of the command
loop, and happens only after a command finishes, and Emacs is back to
the command loop.  It doesn't happen in the middle of a Lisp program.
So what your program did is insert a newline character in the middle
of text covered by a 'display' text property, and then the behavior
you observe is expected, right?

If I modify your program as follows:

  (let ((inserted (cadr (insert-image-file "test.png"))))
    (goto-char (1+ inserted))
    (newline-and-indent))

then only one image is displayed, on line 1.

If what forward-char does in this case is not the reason for your
expectations, please tell more about your reasoning.





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

* bug#32978: 26.1; newline-and-indent duplicates displayed image
  2018-10-14 14:38 ` Eli Zaretskii
@ 2018-10-14 20:40   ` Markus Triska
  2018-10-15  2:33     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Triska @ 2018-10-14 20:40 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 32978

Eli Zaretskii <eliz@gnu.org> writes:

>> In this case, I expect test.png to be displayed only in line 1.
>
> Not sure why you expected that.  Perhaps you thought that forward-char
> will move to after the image?

Yes indeed! Since a single forward-char moves over the image when used
interactively, I got the impression that the image is only a single
character. From your code example, I see that this is not the case!

I think a very good solution would be to document the return value of
insert-image-file, i.e., to add to its description a statement such as:

    Returns list of absolute file name and number of characters
    inserted.

What do you think? Thank you very much for looking into this!

All the best,
Markus





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

* bug#32978: 26.1; newline-and-indent duplicates displayed image
  2018-10-14 20:40   ` Markus Triska
@ 2018-10-15  2:33     ` Eli Zaretskii
  2019-04-19 19:28       ` Noam Postavsky
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2018-10-15  2:33 UTC (permalink / raw)
  To: Markus Triska; +Cc: 32978

tags 32978 notabug
thanks

> From: Markus Triska <triska@metalevel.at>
> Cc: 32978@debbugs.gnu.org
> Date: Sun, 14 Oct 2018 22:40:50 +0200
> 
> > Not sure why you expected that.  Perhaps you thought that forward-char
> > will move to after the image?
> 
> Yes indeed! Since a single forward-char moves over the image when used
> interactively, I got the impression that the image is only a single
> character. From your code example, I see that this is not the case!

No, it's not.  You can see in image-file.el that what
insert-image-file does is insert the entire image file into the
buffer, and then put a 'display' property over all those bytes.  So
the image spans many characters in this case.

> I think a very good solution would be to document the return value of
> insert-image-file, i.e., to add to its description a statement such as:
> 
>     Returns list of absolute file name and number of characters
>     inserted.
> 
> What do you think?

I was thinking the same; will do.





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

* bug#32978: 26.1; newline-and-indent duplicates displayed image
  2018-10-15  2:33     ` Eli Zaretskii
@ 2019-04-19 19:28       ` Noam Postavsky
  0 siblings, 0 replies; 5+ messages in thread
From: Noam Postavsky @ 2019-04-19 19:28 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 32978, Markus Triska

close 32978
quit

Eli Zaretskii <eliz@gnu.org> writes:

>> I think a very good solution would be to document the return value of
>> insert-image-file, i.e., to add to its description a statement such as:
>> 
>>     Returns list of absolute file name and number of characters
>>     inserted.
>> 
>> What do you think?
>
> I was thinking the same; will do.

Done now.

037970f1af 2019-04-19T15:19:45-04:00 "Document insert-image-file's return value (Bug#32978)"
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=037970f1af6c87767501ac6d46c50abe9d3f44e0





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

end of thread, other threads:[~2019-04-19 19:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-07 21:14 bug#32978: 26.1; newline-and-indent duplicates displayed image Markus Triska
2018-10-14 14:38 ` Eli Zaretskii
2018-10-14 20:40   ` Markus Triska
2018-10-15  2:33     ` Eli Zaretskii
2019-04-19 19:28       ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

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

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