source location should be in characters not bytes

Bug #226090 reported by Derick Eddington
2
Affects Status Importance Assigned to Milestone
Ikarus Scheme
Fix Committed
Wishlist
Abdulaziz Ghuloum

Bug Description

... because of multi-byte encodings. The below error tells me byte 230 but I really want to know what character. When I tell my editor to go to character 230, it goes to "d" in the comment.

[d@eep:~/t6]-> cat source-location.ss
(import (rename (rnrs) (lambda λ)))
(define a (λ () 1))
(define b (λ () 1))
(define c (λ () 1))
(define d (λ () 1))
(define e (λ () 1))
(define f (λ () 1))
(define g (λ () 1))
(define h (λ () 1))
(define i (λ () 1))
(f oops) ;abcdefghijklmnopqrstuvwxyz

[d@eep:~/t6]-> ikarus --r6rs-script source-location.ss
Unhandled exception:
 Condition components:
   1. &who: oops
   2. &message: "unbound identifier"
   3. &undefined
   4. &source-information:
       file-name: "source-location-bug.ss"
       character: 230
   5. &trace: #<syntax oops [byte 230 of source-location-bug.ss]>

Related branches

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Use vi :-)

Seriously, in vim, ":goto 230" goes to oops. So, you either find a way to configure your editor, or I have to find a way to configure vi *and* fix this bug. What do you use anyways? Your code doesn't look like it was inflicted by emacs.

Revision history for this message
Michael D. Adams (mdmkolbe) wrote :

Or the error message could report both the character and byte position so users can just use the right one depending on whether they are using a broken and or a non-broken editor.

Revision history for this message
Derick Eddington (derick-eddington) wrote :

[Whoa, that's weird; I emailed a response to Aziz's comment 2 days ago but it seems LaunchPad lost it.]

-------- Forwarded Message --------
From: Derick Eddington <email address hidden>
To: Bug 226090 <email address hidden>
Subject: Re: [Bug 226090] Re: source location should be in characters not bytes
Date: Sat, 03 May 2008 04:56:57 -0700

On Sat, 2008-05-03 at 10:57 +0000, Abdulaziz Ghuloum wrote:
> Use vi :-)

I've tried, a number of times... :) Once the acceptable-looking
anti-aliased GTK2 version came along I really wanted to, but I couldn't
get over how much I hate its scripting language and how it doesn't have
the best S-expression intelligence (at least what I could find out
about). I also tried Cream but had the same two issues.

> Seriously, in vim, ":goto 230" goes to oops. So, you either find a way
> to configure your editor, or I have to find a way to configure vi *and*
> fix this bug.

But don't you think it makes more sense for it to be in terms of
Scheme/Unicode characters, since R6RS source code is specified to be
Unicode?

> What do you use anyways? Your code doesn't look like it
> was inflicted by emacs.

Hahaha. DrScheme. As it's nearing complete R6RS support +
*.IMPL.{ss,sls}, I can run my code in it, and use Dr's syntax checker,
debugger, macro stepper, and help system (which uses the R6RS docs),
and it's got pretty nice S-expression intelligence and syntax coloring
and formatting :)

If you post to ikarus-users about your Scheme-ing vim setup and how you
use it and maybe some of the custom debugging tools you might have, I'll
consider trying vim again :) Else, if this stays as bytes, I guess I'll ask the
PLT guys how to make a byte locator.

I'm not really concerned about this right now, but given we want the
whole world to use Ikarus and they'll want to use multi-byte characters
a lot more than me...

Revision history for this message
Derick Eddington (derick-eddington) wrote :

I asked the vim-multibyte mailing list how to go to character positions, and so far I've gotten this response:

==========================================
On 03/05/08 23:14, Derick Eddington wrote:

> I'm trying to figure out how to configure Vim so that ":goto X" will go
> to character X not byte X. If I have an external thing (in my case, an
> interpreter) telling me I need to look at character X, when the file is
> in a multi-byte encoding (typically UTF-8), I need to be able to tell
> Vim to go to character X. How can this be done?

> I searched around for the answer but couldn't find it, so thanks for any
> help.

":goto" will always count by bytes, but there's another way to do it:

        :set ww+=s ve=onemore
        :exe "normal gg" . (char_number - 1) . " "

don't forget the space at the end. When doing it at the keyboard you may
type just gg then the number (one less than the desired character
number) followed by a space: "exe 'normal'" is not necessary in that case.

see
        :help 'whichwrap'
        :help 'virtualedit

The ":set virtualedit=onemore" is necessary to count linebreaks (but
each of them as only one character even on Windows). That option value
doesn't exist in Vim 6 or earlier.

You can check the result with the Normal-mode command g Ctrl-G
==========================================

I've since asked about how to turn this into a Vim function/command available upon start-up. If you don't already know how, I hope to get a response, see the thread:

http://groups.google.com/group/vim_multibyte/browse_thread/thread/6a2b7a871faf851d

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Fixed in revision 1471.

Changed in ikarus:
assignee: nobody → aghuloum
importance: Undecided → Wishlist
status: New → Fix Committed
Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote : Re: [Bug 226090] Re: source location should be in characters not bytes

On May 5, 2008, at 12:48 PM, Derick Eddington wrote:
> [Whoa, that's weird; I emailed a response to Aziz's comment 2 days ago
> but it seems LaunchPad lost it.]

Launchpad has been doing that a lot lately.

> But don't you think it makes more sense for it to be in terms of
> Scheme/Unicode characters, since R6RS source code is specified to be
> Unicode?

Maybe. We'll get into more issues in the future as we go along since
there are some more transcoding/normalization/eol-style thorns just
around the corner. A byte was just simpler since we all agree on
what bytes are, but oh well, too late now. :-)

>> What do you use anyways? Your code doesn't look like it
>> was inflicted by emacs.
>
> Hahaha. DrScheme. As it's nearing complete R6RS support +
> *.IMPL.{ss,sls}, I can run my code in it, and use Dr's syntax checker,
> debugger, macro stepper, and help system (which uses the R6RS docs),
> and it's got pretty nice S-expression intelligence and syntax coloring
> and formatting :)

That's good if you've found it useful. I may be too old to use
something that was not first invented around the time I was born
(scheme:1975, vi=1976).

> If you post to ikarus-users about your Scheme-ing vim setup and how
> you
> use it and maybe some of the custom debugging tools you might have,
> I'll
> consider trying vim again :) Else, if this stays as bytes, I guess
> I'll ask the
> PLT guys how to make a byte locator.

Neah, I'll skip the tool advocacy/zealotry for now.

Aziz,,,

Revision history for this message
leppie (leppie) wrote :

> That's good if you've found it useful. I may be too old to use
> something that was not first invented around the time I was born
> (scheme:1975, vi=1976).

I was born in '75 and I do not have issues with newer tools :) Then again, I have only been programming seriously for 6-7 years.

Changed in ikarus:
milestone: none → 0.0.4
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.