unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#12679: 24.2.50; Can't font-at for the beginning of a string
@ 2012-10-19  9:52 Kazuhiro Ito
  2012-10-19 13:11 ` Kenichi Handa
  0 siblings, 1 reply; 5+ messages in thread
From: Kazuhiro Ito @ 2012-10-19  9:52 UTC (permalink / raw)
  To: 12679

The below code raises an error on trunk.

(font-at 0 nil "A")

Please see the below patch.

=== modified file 'src/font.c'
--- src/font.c	2012-09-17 12:07:36 +0000
+++ src/font.c	2012-10-19 09:15:58 +0000
@@ -4775,7 +4775,7 @@
     {
       CHECK_NUMBER (position);
       CHECK_STRING (string);
-      if (! (0 < XINT (position) && XINT (position) < SCHARS (string)))
+      if (! (0 <= XINT (position) && XINT (position) < SCHARS (string)))
 	args_out_of_range (string, position);
       pos = XINT (position);
     }


-- 
Kazuhiro Ito





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

* bug#12679: 24.2.50; Can't font-at for the beginning of a string
  2012-10-19  9:52 bug#12679: 24.2.50; Can't font-at for the beginning of a string Kazuhiro Ito
@ 2012-10-19 13:11 ` Kenichi Handa
  2012-10-20 12:19   ` martin rudalics
  0 siblings, 1 reply; 5+ messages in thread
From: Kenichi Handa @ 2012-10-19 13:11 UTC (permalink / raw)
  To: Kazuhiro Ito; +Cc: 12679

In article <87391an60a.wl%%xmue@d1.dion.ne.jp>, Kazuhiro Ito <kzhr@d1.dion.ne.jp> writes:

> The below code raises an error on trunk.
> (font-at 0 nil "A")

> Please see the below patch.

> === modified file 'src/font.c'
> --- src/font.c	2012-09-17 12:07:36 +0000
> +++ src/font.c	2012-10-19 09:15:58 +0000
> @@ -4775,7 +4775,7 @@
>      {
>        CHECK_NUMBER (position);
>        CHECK_STRING (string);
> -      if (! (0 < XINT (position) && XINT (position) < SCHARS (string)))
> +      if (! (0 <= XINT (position) && XINT (position) < SCHARS (string)))
>  	args_out_of_range (string, position);
>        pos = XINT (position);
>      }


Thank you for the patch.  I've just commited it.

---
Kenichi Handa
handa@gnu.org





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

* bug#12679: 24.2.50; Can't font-at for the beginning of a string
  2012-10-19 13:11 ` Kenichi Handa
@ 2012-10-20 12:19   ` martin rudalics
  2012-10-30 11:45     ` Kenichi Handa
  0 siblings, 1 reply; 5+ messages in thread
From: martin rudalics @ 2012-10-20 12:19 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: Kazuhiro Ito, 12679

Could you please also (1) add a description of the STRING argument in
the doc-string of `font-at', and (2) explain what happens when the
selected window or the window passed as argument do not show the current
buffer.  IIUC face_at_buffer_position expects the window passed to it to
show the current buffer but this might not be true when `font-at' calls
it.  There's also this comment in face_at_buffer_position:

   /* W must display the current buffer.  We could write this function
      to use the frame and buffer of W, but right now it doesn't.  */
   /* eassert (XBUFFER (w->buffer) == current_buffer); */

Later in the code of face_at_buffer_position I see that w->buffer is
sometimes used explicitly but get the impression that most other parts
of the code use the current buffer instead.

Thanks, martin





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

* bug#12679: 24.2.50; Can't font-at for the beginning of a string
  2012-10-20 12:19   ` martin rudalics
@ 2012-10-30 11:45     ` Kenichi Handa
  2012-10-30 18:49       ` martin rudalics
  0 siblings, 1 reply; 5+ messages in thread
From: Kenichi Handa @ 2012-10-30 11:45 UTC (permalink / raw)
  To: martin rudalics; +Cc: kzhr, 12679

In article <508296EA.60000@gmx.at>, martin rudalics <rudalics@gmx.at> writes:

> Could you please also (1) add a description of the STRING argument in
> the doc-string of `font-at',

I added this statement to the docstring.

  Optional third arg STRING, if non-nil, is a string containing the target
  character at index specified by POSITION.

> and (2) explain what happens when the
> selected window or the window passed as argument do not show the current
> buffer.

> IIUC face_at_buffer_position expects the window passed to it to
> show the current buffer but this might not be true when `font-at' calls
> it.  There's also this comment in face_at_buffer_position:

>    /* W must display the current buffer.  We could write this function
>       to use the frame and buffer of W, but right now it doesn't.  */
>    /* eassert (XBUFFER (w->buffer) == current_buffer); */

> Later in the code of face_at_buffer_position I see that w->buffer is
> sometimes used explicitly but get the impression that most other parts
> of the code use the current buffer instead.

I think your worrying is right.  So, I changed font-at to
signal an error when the specified window is not displaying
the current buffer.

---
Kenichi Handa
handa@gnu.org





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

* bug#12679: 24.2.50; Can't font-at for the beginning of a string
  2012-10-30 11:45     ` Kenichi Handa
@ 2012-10-30 18:49       ` martin rudalics
  0 siblings, 0 replies; 5+ messages in thread
From: martin rudalics @ 2012-10-30 18:49 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: kzhr, 12679

 > I added this statement to the docstring.
 >
 >   Optional third arg STRING, if non-nil, is a string containing the target
 >   character at index specified by POSITION.

Thanks.

 > I changed font-at to
 > signal an error when the specified window is not displaying
 > the current buffer.

Yes, I think that's the best solution.

Thanks, martin





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

end of thread, other threads:[~2012-10-30 18:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-19  9:52 bug#12679: 24.2.50; Can't font-at for the beginning of a string Kazuhiro Ito
2012-10-19 13:11 ` Kenichi Handa
2012-10-20 12:19   ` martin rudalics
2012-10-30 11:45     ` Kenichi Handa
2012-10-30 18:49       ` martin rudalics

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