emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [elpa] 02/04: company-clang: handle multibyte chars between bol and


From: Eli Zaretskii
Subject: Re: [elpa] 02/04: company-clang: handle multibyte chars between bol and point
Date: Wed, 19 Mar 2014 18:40:25 +0200

> From: Stefan <address@hidden>
> Date: Wed, 19 Mar 2014 09:15:27 -0400
> 
> > -            (- (point) (line-beginning-position) -1))))
> > +            (1+ (string-bytes (buffer-substring
> > +                               (line-beginning-position)
> > +                               (point)))))))
> 
> Instead of buffer-subtring composed with string-bytes, you could use
> position-bytes.  You might also like to add a comment like "Hack attack:
> assume the file's encoding is the same as Emacs's internal encoding".

Why assume such a thing?  It's bound to break some day, for some user.

I would suggest encoding the buffer substring using
buffer-file-coding-system, and then using (length string) on the
result (which will be a unibyte string, so there's no difference
between byte and character counts).  Then this code will be portable,
I think.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]