1

I am using GNU Emacs to display the cover of the album mpd is currently playing, inserting it into a *jukebox* buffer with this code:

(put-image (create-image albumartname 'imagemagick nil :width 1022) 0 albumartname)

(The window is maximized and the screen is 1024 pixels wide.)

I would like to have that image fill the entire width of Emacs' window, but a column of empty space always appears to the right of the image:

Picture in buffer, empty column to the right

The width of this column depends on the font size - if I turn down the font size to 1, there is just a tiny column of empty space. If I turn the font size up to 38, it is much wider.

I have tried both (visual-line-mode 1) and (toggle-truncate-lines 1), without any luck. I have turned scrollbars and fringes off.

Is there a way to coerce Emacs into not showing that column of empty space?

Update:

Some more information:

Here is a screenshot if I do:

(add-to-list 'default-frame-alist '(font . "URW Gothic L-1"))

(I have changed the background-color):

enter image description here

I tried the suggestion of setting

 (setq frame-resize-pixelwise t)

but that didn't help.

I have also tried to add an overlay with a face with height 1 to the picture, which I couldn't make work either.

Could it be a column reserved for the "truncate char"? If I make the window narrower, it looks like this:

enter image description here

Notice how the column has a "$" below the image, where the line is longer than the screen, so Emacs definitely can paint there.

Update 2

I have gotten a little further. If I set the default font size to 1:

(add-to-list 'default-frame-alist '(font . "URW Gothic L-1"))

and I define a face:

(defface jukebox-cover
  '((t (:family "URW Gothic L" :height 380 :foundry "urw" :slant normal :weight normal :width normal)))
  "Jukebox cover workaround face"
  :group 'jukebox-mode)

And then after displaying the image and putting the text in the buffer:

    (put-image (create-image albumartname 'imagemagick nil :width 1020) 1 albumartname)
    (insert (format "\n%s\n%s\n%s " title album artist))

I then add and overlay with the face I defined:

        (overlay-put (make-overlay (point-min) (point-max)) 'face 'jukebox-cover)

then it looks like this:

enter image description here

Now I just need to figure out how to make the minibuffer font readable again as well.

  • Could it be the "fringe"? (which you can change with M-x set-fringe-style) – Stefan Mar 10 at 2:14
  • I have turned the fringes off - and I don't think the fringe size adjusts with font size? It's like Emacs adds a 1-char wide column "on top". I couldn't figure out how to set the font-size to 1 on the line with the image, that would [almost] work around the problem. – asjo Mar 10 at 9:53
  • Is it possible that what you are seeing is because Emacs actually computes its display size in whole lines, and some padding is added by the GUI shell that hosts the editor? – wvxvw Mar 10 at 12:06
  • Indeed, I think wvxvw might be right: it might just be due to frame sizes being computed in multiple of chars by default. Try setting frame-resize-pixelwise! – Stefan Mar 10 at 17:15
  • Because setting the fontsize of the default font to 1 makes the unwanred column (almost) disappar, I have tried to add an overlay on the picture setting a face with size 1, but that doesn't help (neither does adding a face property to the image overlay) [with the caveat that I have never played with overlays before]. I have tried setting frame-resize-pixelwise to 't, but that didn't change anything either, unfortunately. Could it be a column for displaying the $ of truncated lines, added because the image is too wide? – asjo Mar 10 at 21:26
0

Ok, I finally got a work around that [almost] works. This is what I had to do:

1 Set the font size to 1

(add-to-list 'default-frame-alist '(font . "URW Gothic L-1"))

2 Add an overlay to the entire buffer that increases the font size

(defface jukebox-cover
  '((t (:family "URW Gothic L" :height 380 :foundry "urw" :slant normal :weight normal :width normal)))
  "Jukebox cover workaround face"
  :group 'jukebox-mode)

and

(overlay-put (make-overlay (point-min) (point-max)) 'face 'jukebox-cover)

3 Add a hack to increase the font size in the minibuffer (from http://ergoemacs.org/emacs/emacs_minibuffer_font_size.html):

(dolist
    (buf (list " *Minibuf-0*" " *Minibuf-1*" " *Echo Area 0*" " *Echo Area 1*" "*Quail Completions*"))
  (when (get-buffer buf)
    (with-current-buffer buf
      (setq-local face-remapping-alist '((default (:height 380)))))))

The result looks like this:

enter image description here

I call it a work around because it's not elegant, and there is still a 1 pixel column to the very right of the image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.