unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alexander Miller <alexanderm@web.de>
To: akrl@sdf.org
Cc: 45342@debbugs.gnu.org
Subject: bug#45342: 28.0.50; Native compiled function returns raw bytes, not string
Date: Mon, 21 Dec 2020 14:45:04 +0100	[thread overview]
Message-ID: <830eaec4-a2f7-c3cf-14f2-e0a3574a1e8b@web.de> (raw)
In-Reply-To: <b6f2922c-00e7-7bf3-84eb-92c347450343@web.de>

Hi Andrea,

I can confirm that 72c1a41573 fixes the issue.

However there's still another problem that I thought was related, but
apparently it isn't. (I can open another bug for it if you like).

It looks like eval-when-compile is not working as expected. I am also
using small xpms for my modeline that are defined like this:

(defconst selected-window-xpm
    (eval-when-compile (doom-modeline--make-xpm 'modeline-xpm-face 5 30)))

The generating code looks like this:

(defun doom-modeline--make-xpm (face width height)
   "Create an XPM bitmap via FACE, WIDTH and HEIGHT. Inspired by 
`powerline''s `pl/make-xpm'."
   (when (and (display-graphic-p)
              (image-type-available-p 'xpm))
     (propertize
      " " 'display
      (let ((data (make-list height (make-list width 1)))
            (color (or (face-background face nil t) "None")))
        (ignore-errors
          (create-image
           (concat
            (format
             "/* XPM */\nstatic char * percent[] = {\n\"%i %i 2 
1\",\n\". c %s\",\n\"  c %s\","
             (length (car data)) (length data) color color)
            (apply #'concat
                   (cl-loop with idx = 0
                            with len = (length data)
                            for dl in data
                            do (cl-incf idx)
                            collect
                            (concat
                             "\""
                             (cl-loop for d in dl
                                      if (= d 0) collect (string-to-char 
" ")
                                      else collect (string-to-char "."))
                             (if (eq idx len) "\"};" "\",\n")))))
   'xpm t :ascent 'center))))))

When native-compiling I only get nil, with byte-compiling it works
without problems. The correct value should look like this:

#(" " 0 1
(display
(image :type xpm :data "/* XPM */
static char * percent[] = {
\"5 30 2 1\",
\". c #559955\",
\" c #559955\",\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\"};" :scale 1 :ascent center)))


  parent reply	other threads:[~2020-12-21 13:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-20 17:36 bug#45342: 28.0.50; Native compiled function returns raw bytes, not string Alexander Miller
2020-12-20 17:56 ` Eli Zaretskii
2020-12-20 20:24 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-12-21 13:45 ` Alexander Miller [this message]
2020-12-21 15:34   ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-12-21 19:36 ` bug#45342: closed (Re: bug#45342: 28.0.50; Native compiled function returns raw bytes, not string) Alexander Miller
2020-12-21 20:01   ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=830eaec4-a2f7-c3cf-14f2-e0a3574a1e8b@web.de \
    --to=alexanderm@web.de \
    --cc=45342@debbugs.gnu.org \
    --cc=akrl@sdf.org \
    /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).