all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug in field-string and field-string-no-properties
@ 2003-08-14 21:00 Greg Hill
  2003-08-14 21:21 ` John Paul Wallington
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Hill @ 2003-08-14 21:00 UTC (permalink / raw)


There appears to be a bug in field-string and 
field-string-no-properties.  When (point) or the POS argument is at 
the first character of a field, the function returns an empty string. 
The following fragment of code, executed in the scratch buffer, 
illustrates the problem.

(progn
   (set-buffer (get-buffer-create "junk"))
   (erase-buffer)
   (insert "Test")
   (put-text-property (point-min) (point-max) 'field 1)
   (message "field-string at 1 = '%s'\nfield-string at 2 = '%s'"
   (field-string-no-properties 1) (field-string-no-properties 2)))


platform:  GNU Emacs 21.2.2 (sparc-sun-solaris2.7, X toolkit)

--Greg

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

* Re: bug in field-string and field-string-no-properties
  2003-08-14 21:00 bug in field-string and field-string-no-properties Greg Hill
@ 2003-08-14 21:21 ` John Paul Wallington
  0 siblings, 0 replies; 5+ messages in thread
From: John Paul Wallington @ 2003-08-14 21:21 UTC (permalink / raw)
  Cc: bug-gnu-emacs

> There appears to be a bug in field-string and 
> field-string-no-properties.  When (point) or the POS argument is at 
> the first character of a field, the function returns an empty string. 
> The following fragment of code, executed in the scratch buffer, 
> illustrates the problem.
> 
> (progn
>    (set-buffer (get-buffer-create "junk"))
>    (erase-buffer)
>    (insert "Test")
>    (put-text-property (point-min) (point-max) 'field 1)
>    (message "field-string at 1 = '%s'\nfield-string at 2 = '%s'"
>    (field-string-no-properties 1) (field-string-no-properties 2)))

>From (elisp) Fields Info node:

"When the characters before and after POS are part of the same field,
there is no doubt which field contains POS: the one those characters
both belong to.  When POS is at a boundary between fields, which field
it belongs to depends on the stickiness of the `field' properties of
the two surrounding characters (see *note Sticky Properties::).  The field
whose property would be inherited by text inserted at POS is the field
that contains POS."

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

* Re: bug in field-string and field-string-no-properties
  2003-08-29  2:20   ` Greg Hill
@ 2003-08-29  2:36     ` Miles Bader
  2003-08-29 18:53       ` Kevin Rodgers
  2003-08-29 21:55       ` Greg Hill
  0 siblings, 2 replies; 5+ messages in thread
From: Miles Bader @ 2003-08-29  2:36 UTC (permalink / raw)
  Cc: emacs-devel, Stefan Monnier, monnier, Richard Stallman

Greg Hill <ghill@synergymicro.com> writes:
> "At 1, field-property = X, field-string = ''
>   At 2, field-property = X, field-string = 'xX'
>   At 3, field-property = Y, field-string = ''
>   At 4, field-property = Y, field-string = 'yY'
>   At 5, field-property = nil, field-string = ''
> "

What version of emacs are you using?  My emacs (roughly CVS HEAD),
returns:

   "At 1, field-property = X, field-string = ''
    At 2, field-property = X, field-string = 'xX'
    At 3, field-property = Y, field-string = 'xX'
    At 4, field-property = Y, field-string = 'yY'
    At 5, field-property = nil, field-string = 'yY'
   "

which makes sense since the default for text-properties is rear-stickyness.

> The kind of function I would find useful wouldn't depend on stickiness
> at all.  For a given buffer position, the value of the field property
> returned by get-text-property would determine the string returned by
> field-string when it is passed the same buffer position.

There _is_ a reason why fields use stickiness for ambiguous locations:
it yields consistent result with what happens when a user inserts text,
and fields are fundamentally about inserting text.

Text insertion happens _between_ characters, and field operators
reflect that.

Perhaps mouse operations require some different operators, I don't know.

-Miles
-- 
"1971 pickup truck; will trade for guns"

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

* Re: bug in field-string and field-string-no-properties
  2003-08-29  2:36     ` Miles Bader
@ 2003-08-29 18:53       ` Kevin Rodgers
  2003-08-29 21:55       ` Greg Hill
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2003-08-29 18:53 UTC (permalink / raw)


Miles Bader wrote:

> Greg Hill <ghill@synergymicro.com> writes:
> 
>>"At 1, field-property = X, field-string = ''
>>  At 2, field-property = X, field-string = 'xX'
>>  At 3, field-property = Y, field-string = ''
>>  At 4, field-property = Y, field-string = 'yY'
>>  At 5, field-property = nil, field-string = ''
>>"
>>
> 
> What version of emacs are you using?

I get the same results as Greg on

GNU Emacs 21.3.1 (i386-pc-solaris2.7, X toolkit) of 2003-04-24 on briard

-- 
Kevin Rodgers

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

* Re: bug in field-string and field-string-no-properties
  2003-08-29  2:36     ` Miles Bader
  2003-08-29 18:53       ` Kevin Rodgers
@ 2003-08-29 21:55       ` Greg Hill
  1 sibling, 0 replies; 5+ messages in thread
From: Greg Hill @ 2003-08-29 21:55 UTC (permalink / raw)
  Cc: emacs-devel, Stefan Monnier, monnier, Richard Stallman

At 11:36 AM +0900 8/29/03, Miles Bader wrote:
>Greg Hill <ghill@synergymicro.com> writes:
>>  "At 1, field-property = X, field-string = ''
>>    At 2, field-property = X, field-string = 'xX'
>>    At 3, field-property = Y, field-string = ''
>>    At 4, field-property = Y, field-string = 'yY'
>>    At 5, field-property = nil, field-string = ''
>>  "
>
>What version of emacs are you using?


GNU Emacs 21.2.2 (sparc-sun-solaris2.7, X toolkit) of 2002-12-17


>   My emacs (roughly CVS HEAD),
>returns:
>
>    "At 1, field-property = X, field-string = ''
>     At 2, field-property = X, field-string = 'xX'
>     At 3, field-property = Y, field-string = 'xX'
>     At 4, field-property = Y, field-string = 'yY'
>     At 5, field-property = nil, field-string = 'yY'
>    "
>
>which makes sense since the default for text-properties is rear-stickyness.
>
>>  The kind of function I would find useful wouldn't depend on stickiness
>>  at all.  For a given buffer position, the value of the field property
>>  returned by get-text-property would determine the string returned by
>>  field-string when it is passed the same buffer position.
>
>There _is_ a reason why fields use stickiness for ambiguous locations:
>it yields consistent result with what happens when a user inserts text,
>and fields are fundamentally about inserting text.
>
>Text insertion happens _between_ characters, and field operators
>reflect that.
>
>Perhaps mouse operations require some different operators, I don't know.
>
>-Miles
>--
>"1971 pickup truck; will trade for guns"

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

end of thread, other threads:[~2003-08-29 21:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-14 21:00 bug in field-string and field-string-no-properties Greg Hill
2003-08-14 21:21 ` John Paul Wallington
  -- strict thread matches above, loose matches on Subject: below --
2003-08-27 22:12 [ghill@synergymicro.com: Re: Re: bug in field-string and field-string-no-properties] Richard Stallman
2003-08-28 21:32 ` Fwd: Re: Re: bug in field-string and field-string-no-properties Stefan Monnier
2003-08-29  2:20   ` Greg Hill
2003-08-29  2:36     ` Miles Bader
2003-08-29 18:53       ` Kevin Rodgers
2003-08-29 21:55       ` Greg Hill

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.