From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Obsolete string-to-multibyte hard to replace
Date: Mon, 29 May 2017 20:21:01 -0400 [thread overview]
Message-ID: <CAM-tV--CskdGmy8Or=50HZ_LyV0D9S73gVNHbi-=b8oognx3Zw@mail.gmail.com> (raw)
In-Reply-To: <jwvk24zj09b.fsf-monnier+emacs@gnu.org>
On Mon, May 29, 2017 at 9:01 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
> I was looking at ruler-mode.el's bytecomp warning about string-to-multibyte
> and it seems like there is no good way to write cleaner code here:
>
> (let (...
> (ruler
> (propertize
> (string-to-multibyte
> (make-string w ruler-mode-basic-graduation-char))
> ...))
> ...)
> [...]
> (aset ruler k (aref c (setq m (1- m))))
>
> Here, the problem is as follows: make-string returns a unibyte string if
> the initial char is ASCII and a multibyte string otherwise.
> Seems innucuous, but it means that if the initial char
> (ruler-mode-basic-graduation-char above) is ASCII, you can't later
> insert a multibyte char into that string with `aset`.
We could the collect the characters in a vector and then only convert
to string at the end. Haven't you said that strings should ideally be
treated as immutable?
next prev parent reply other threads:[~2017-05-30 0:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-29 13:01 Obsolete string-to-multibyte hard to replace Stefan Monnier
2017-05-29 17:45 ` Eli Zaretskii
2017-05-30 4:03 ` Stefan Monnier
2017-05-30 0:21 ` Noam Postavsky [this message]
2017-05-30 3:28 ` Stefan Monnier
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAM-tV--CskdGmy8Or=50HZ_LyV0D9S73gVNHbi-=b8oognx3Zw@mail.gmail.com' \
--to=npostavs@users.sourceforge.net \
--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 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).