From: Eli Zaretskii <eliz@gnu.org>
To: Stefan <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: [elpa] 02/04: company-clang: handle multibyte chars between bol and point
Date: Wed, 19 Mar 2014 18:40:25 +0200 [thread overview]
Message-ID: <837g7q9m6e.fsf@gnu.org> (raw)
In-Reply-To: <jwvvbvaz5z4.fsf-monnier+emacsdiffs@gnu.org>
> From: Stefan <monnier@iro.umontreal.ca>
> 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.
prev parent reply other threads:[~2014-03-19 16:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20140319033013.17542.14344@vcs.savannah.gnu.org>
[not found] ` <E1WQ7Co-0004c8-Lo@vcs.savannah.gnu.org>
2014-03-19 13:15 ` [elpa] 02/04: company-clang: handle multibyte chars between bol and point Stefan
2014-03-19 14:08 ` Dmitry Gutov
2014-03-19 16:54 ` Eli Zaretskii
2014-03-19 17:56 ` Dmitry Gutov
2014-03-19 18:33 ` Eli Zaretskii
2014-03-19 21:15 ` Dmitry Gutov
2014-03-20 2:56 ` Dmitry Gutov
2014-03-20 3:58 ` Eli Zaretskii
2014-03-20 4:10 ` Dmitry Gutov
2014-03-20 16:11 ` Eli Zaretskii
2014-03-20 18:58 ` Richard Stallman
2014-03-20 19:04 ` Dmitry Gutov
2014-03-21 12:15 ` Richard Stallman
2014-03-21 3:47 ` Dmitry Gutov
2014-03-21 8:04 ` Eli Zaretskii
2014-03-20 3:47 ` Eli Zaretskii
2014-03-19 16:40 ` Eli Zaretskii [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=837g7q9m6e.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.