GNU bug report logs - #75776
30.0.50; Displaying image slice in the right margin

Previous Next

Package: emacs;

Reported by: Evgeny Zajcev <lg.zevlg <at> gmail.com>

Date: Thu, 23 Jan 2025 07:11:01 UTC

Severity: normal

Found in version 30.0.50

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 75776 in the body.
You can then email your comments to 75776 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#75776; Package emacs. (Thu, 23 Jan 2025 07:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Evgeny Zajcev <lg.zevlg <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 23 Jan 2025 07:11:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Evgeny Zajcev <lg.zevlg <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; Displaying image slice in the right margin
Date: Thu, 23 Jan 2025 10:10:05 +0300
[Message part 1 (text/plain, inline)]
I'm having problem displaying an image slice in the right margin.  To
reproduce this, download
https://www.gnu.org/software/emacs/images/emacs.png to your ~/Downloads
folder.  Activate right margin with M-x visual-fill-column RET.  And
consider three pieces of code:

1. (insert
     (propertize "E" 'display `((slice 0 0 1.0 20) ,(create-image
     "~/Downloads/emacs.png" nil nil :scale 1.0))))

   Displays image slice in the buffer as expected.

2. (insert
     (propertize "E" 'display `((margin right-margin) ,(create-image
     "~/Downloads/emacs.png" nil nil :scale 1.0))))

   Displays image in the right margin as expected.

3. (insert
     (propertize "E" 'display `((margin right-margin)
      ((slice 0 0 1.0 20)
      ,(create-image "~/Downloads/emacs.png" nil nil :scale 1.0)))))

   Displays "E"

Documentation say that ((margin right-margin) SPEC) can be used to
display image in the right margin, and SPEC is totally valid in the
3. because 2. works.

Is this a bug?

Thanks

In GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version
 3.24.20, cairo version 1.16.0) of 2023-11-16 built on x1
Repository revision: 26b1ce77f355e3d0f84c26dabe35067ad8e07170
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12009000
System Description: Ubuntu 20.04.1 LTS

Configured using:
 'configure --with-modules --with-xwidgets --with-tree-sitter'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND
SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM
XINPUT2 XPM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LC_MONETARY: ru_RU.UTF-8
  value of $LC_NUMERIC: ru_RU.UTF-8
  value of $LC_TIME: ru_RU.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tracking-mode: t
  global-telega-mnz-mode: t
  global-telega-url-shorten-mode: t
  telega-emacs-stories-mode: t
  telega-root-auto-fill-mode: t
  telega-contact-birthdays-mode: t
  telega-recognize-voice-message-mode: t
  telega-active-video-chats-mode: t
  telega-active-locations-mode: t
  telega-my-location-mode: t
  telega-patrons-mode: t
  global-telega-squash-message-mode: t
  telega-autoplay-mode: t
  telega-appindicator-mode: t
  telega-mode-line-mode: t
  telega-notifications-mode: t
  telega-active-stories-mode: t
  visual-fill-column-mode: t
  company-mode: t
  reverse-im-mode: t
  recentf-mode: t
  desktop-save-mode: t
  magit-todos-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  global-paren-face-mode: t
  paren-face-mode: t
  dot-mode: t
  which-function-mode: t
  save-place-mode: t
  server-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  icomplete-mode: t
  disable-mouse-global-mode: t
  override-global-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
~/github/eukleides.el/eukleides hides ~/github/emacs-stuff/eukleides
/home/lg/.emacs.d/elpa/git-commit-20210328.1730/git-commit hides
/home/lg/.emacs.d/elpa/magit-20241219.1744/git-commit
~/github/totp.el/totp-auth hides
/home/lg/.emacs.d/elpa/totp-auth-20240227.1841/totp-auth
~/github/totp.el/base32 hides
/home/lg/.emacs.d/elpa/base32-20240227.1821/base32
/home/lg/.emacs.d/elpa/vertico-20241208.2233/vertico hides
/home/lg/.emacs.d/elpa/vertico-0.11/vertico
/home/lg/.emacs.d/elpa/vertico-20241208.2233/vertico-pkg hides
/home/lg/.emacs.d/elpa/vertico-0.11/vertico-pkg
/home/lg/.emacs.d/elpa/vertico-20241208.2233/vertico-autoloads hides
/home/lg/.emacs.d/elpa/vertico-0.11/vertico-autoloads
/home/lg/.emacs.d/elpa/bind-key-20210210.1609/bind-key hides
/usr/local/share/emacs/30.0.50/lisp/bind-key
/home/lg/.emacs.d/elpa/transient-20241219.1713/transient hides
/usr/local/share/emacs/30.0.50/lisp/transient
/home/lg/.emacs.d/elpa/use-package-20210207.1926/use-package hides
/usr/local/share/emacs/30.0.50/lisp/use-package/use-package
/home/lg/.emacs.d/elpa/use-package-20210207.1926/use-package-diminish hides
/usr/local/share/emacs/30.0.50/lisp/use-package/use-package-diminish
/home/lg/.emacs.d/elpa/use-package-20210207.1926/use-package-core hides
/usr/local/share/emacs/30.0.50/lisp/use-package/use-package-core
/home/lg/.emacs.d/elpa/use-package-20210207.1926/use-package-ensure hides
/usr/local/share/emacs/30.0.50/lisp/use-package/use-package-ensure
/home/lg/.emacs.d/elpa/use-package-20210207.1926/use-package-bind-key hides
/usr/local/share/emacs/30.0.50/lisp/use-package/use-package-bind-key
/home/lg/.emacs.d/elpa/use-package-20210207.1926/use-package-lint hides
/usr/local/share/emacs/30.0.50/lisp/use-package/use-package-lint
/home/lg/.emacs.d/elpa/use-package-20210207.1926/use-package-delight hides
/usr/local/share/emacs/30.0.50/lisp/use-package/use-package-delight
/home/lg/.emacs.d/elpa/use-package-20210207.1926/use-package-jump hides
/usr/local/share/emacs/30.0.50/lisp/use-package/use-package-jump

Features:
(shadow sort mail-extr conf-mode lua-mode ispell tabify man tramp-cmds
tramp-cache time-stamp completion battery nroff-mode crdt sql view
rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc rng-uri
rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns
nxml-mode nxml-outln nxml-rap sgml-mode facemenu nxml-util nxml-enc
xmltok ruby-mode yaml-mode make-mode memory-report two-column descr-text
treesitter-context-focus treesitter-context treesitter-context-toml
treesitter-context-yaml treesitter-context-typescript
treesitter-context-javascript treesitter-context-json
treesitter-context-go treesitter-context-rust treesitter-context-cpp
treesitter-context-c treesitter-context-python treesitter-context-java
treesitter-context-common misc json-mode json-reformat json-snatcher js
json-ts-mode rect wordfreq shr-color textsec uni-scripts idna-mapping
ucs-normalize uni-confusable textsec-check multitran cmake-mode rst
cython-mode python-mode info-look hideshow hippie-exp markdown-mode
apropos shortdoc comp comp-cstr goto-last-change image-converter
org-journal org-crypt cal-iso holidays holiday-loaddefs cal-move
yaml-ts-mode totp-interop dabbrev vertico-mouse skeleton help-fns
cl-print vertico-multiform vertico-posframe-autoloads vertico-flat
vertico vertico-autoloads loaddefs-gen radix-tree tar-mode arc-mode
archive-mode mm-archive network-stream url-cache display-line-numbers
wgrep thai-util thai-word hl-line tracking shorten telega-adblock
telega-mnz ol-telega telega-url-shorten telega-emacs-stories
telega-dashboard telega-live-location geo-simulate geo telega-obsolete
telega telega-tdlib-events telega-match telega-root telega-info
telega-chat telega-modes telega-company telega-emoji telega-user
telega-notifications notifications telega-voip telega-msg telega-story
telega-webpage visual-fill-column telega-tme telega-sticker
telega-vvnote telega-ffplay telega-i18n telega-sort telega-filter
telega-ins telega-inline telega-util telega-folders telega-topic
telega-media telega-tdlib dired-aux telega-server telega-core
telega-customize cus-edit cus-start cus-load emacsbug vterm
magit-bookmark bookmark vterm-module vc-hg vc-bzr vc-src vc-sccs vc-svn
vc-cvs vc-rcs log-view bug-reference magit-extras misearch multi-isearch
company-org-block org-indent org-element org-persist org-id org-refile
avl-tree oc-basic ol-eww eww url-queue mm-url ol-rmail ol-mhe ol-irc
ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view mml-smime smime
gnutls dig gnus-sum shr pixel-fill kinsoku url-file svg dom gnus-group
gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail
mail-source utf7 nnoo gnus-spec gnus-int gnus-range gnus-win ol-docview
doc-view jka-compr image-mode exif ol-bibtex bibtex ol-bbdb ol-w3m
ol-doi org-link-doi mule-util face-remap c++-ts-mode c-ts-mode
c-ts-common eglot external-completion jsonrpc flymake ert pp ewoc debug
backtrace warnings python vc-git company-keywords company-dabbrev-code
company-dabbrev company-files company-clang company-template
company-cmake company-posframe posframe company eat term/xterm xterm
term disp-table ehelp reverse-im avy quail dockerfile-mode sh-script
smie treesit executable dashboard dashboard-widgets all-the-icons
all-the-icons-faces data-material data-weathericons data-octicons
data-fileicons data-faicons data-alltheicons recentf tree-widget ffap
home lichess lichess-runtime lichess-api lichess-util sound-wav deferred
request cider cider-debug cider-browse-ns cider-mode cider-inspector
cider-completion cider-profile cider-eval cider-repl-history pulse
cider-repl cider-resolve cider-test cider-overlays cider-stacktrace
cider-doc cider-browse-spec cider-clojuredocs cider-eldoc cider-client
cider-common etags fileloop generator xref project cider-connection
cider-util thingatpt cider-popup sesman-browser nrepl-client queue
nrepl-dict cider-compat spinner sesman vc vc-dispatcher clojure-mode
lisp-mnt align parseedn parseclj-parser parseclj-lex a desktop frameset
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs gnus nnheader range wid-edit autoinsert magit-todos
pcre2el rxt re-builder magit-submodule magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone
magit-remote magit-commit magit-sequence magit-notes magit-worktree
magit-tag magit-merge magit-branch magit-reset magit-files magit-refs
magit-status magit magit-repos magit-apply magit-wip magit-log
magit-diff smerge-mode diff-mode git-commit log-edit message sendmail
yank-media rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util mm-decode mm-bodies mm-encode mailabbrev mail-utils gmm-utils
mailheader pcvs-util add-log magit-core magit-autorevert autorevert
filenotify magit-margin magit-transient magit-process with-editor
magit-mode transient benchmark magit-git magit-base magit-section
cursor-sensor crm compat hl-todo f s dash async grep compile
text-property-search paren-face dot-mode which-func imenu totp-auth
bindat hmac base32 gist-org saveplace tramp-sh tramp trampver
tramp-integration files-x tramp-message tramp-compat xdg shell
parse-time iso8601 tramp-loaddefs gist dired dired-loaddefs gh-gist
gh-oauth gh-api logito gh-cache pcache gh-auth gh-common marshal gh-url
url-http url-auth mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr url-gw nsm puny gh-profile timezone eieio-base server time
google-translate google-translate-default-ui google-translate-core-ui
color popup google-translate-core google-translate-tk
google-translate-backend whitespace undo-tree diff ido icomplete avoid
disable-mouse page-break-lines ibuffer-vc ibuf-ext ibuffer
ibuffer-loaddefs org-bullets org ob ob-tangle ob-ref ob-lob ob-table
ob-exp org-macro org-src ob-comint org-pcomplete pcomplete comint
ansi-osc ansi-color ring org-list org-footnote org-faces org-entities
time-date noutline outline icons ob-emacs-lisp ob-core ob-eval org-cycle
org-table ol org-fold org-fold-core org-keys oc org-loaddefs find-func
cal-menu calendar cal-loaddefs org-version org-compat org-macs
format-spec edmacro kmacro advice browse-kill-ring delsel cl-extra
help-mode use-package use-package-ensure use-package-delight
use-package-diminish use-package-bind-key bind-key use-package-core
finder-inf adaptive-wrap-autoloads all-the-icons-autoloads tex-site
closql-autoloads company-box-autoloads company-org-block-autoloads
company-posframe-autoloads corfu-autoloads dashboard-autoloads
devdocs-autoloads embark-autoloads esxml-autoloads frame-local-autoloads
gist-autoloads gh-autoloads rx kv-autoloads magit-todos-autoloads
magit-autoloads pcase magit-section-autoloads page-break-lines-autoloads
pcre2el-autoloads persist-autoloads poly-org-autoloads
polymode-autoloads company-autoloads pyvenv-auto-autoloads easy-mmode
shackle-autoloads taxy-autoloads totp-auth-autoloads base32-autoloads
transient-autoloads compat-autoloads w3m-load wgrep-autoloads info
yaml-autoloads zig-mode-autoloads reformatter-autoloads package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs password-cache
json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs
cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt
fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode
register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads xwidget-internal dbusbind inotify dynamic-setting
system-font-setting font-render-setting cairo gtk x-toolkit xinput2 x
multi-tty move-toolbar make-network-process emacs)

Memory information:
((conses 16 24053588 10726299) (symbols 48 107204 7)
 (strings 32 1689337 382021) (string-bytes 1 67604757)
 (vectors 16 238666) (vector-slots 8 4748919 8061340)
 (floats 8 54565 48892) (intervals 56 3948215 94544) (buffers 992 577))

-- 
lg
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75776; Package emacs. (Thu, 23 Jan 2025 10:03:02 GMT) Full text and rfc822 format available.

Message #8 received at 75776 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Evgeny Zajcev <lg.zevlg <at> gmail.com>
Cc: 75776 <at> debbugs.gnu.org
Subject: Re: bug#75776: 30.0.50; Displaying image slice in the right margin
Date: Thu, 23 Jan 2025 12:01:43 +0200
> From: Evgeny Zajcev <lg.zevlg <at> gmail.com>
> Date: Thu, 23 Jan 2025 10:10:05 +0300
> 
> I'm having problem displaying an image slice in the right margin.  To
> reproduce this, download
> https://www.gnu.org/software/emacs/images/emacs.png to your ~/Downloads
> folder.  Activate right margin with M-x visual-fill-column RET.  And consider three pieces of code:
> 
> 1. (insert
>      (propertize "E" 'display `((slice 0 0 1.0 20) ,(create-image
>      "~/Downloads/emacs.png" nil nil :scale 1.0))))
> 
>    Displays image slice in the buffer as expected.
> 
> 2. (insert
>      (propertize "E" 'display `((margin right-margin) ,(create-image
>      "~/Downloads/emacs.png" nil nil :scale 1.0))))
>   
>    Displays image in the right margin as expected.
> 
> 3. (insert
>      (propertize "E" 'display `((margin right-margin)
>       ((slice 0 0 1.0 20)
>       ,(create-image "~/Downloads/emacs.png" nil nil :scale 1.0)))))
> 
>    Displays "E"
> 
> Documentation say that ((margin right-margin) SPEC) can be used to
> display image in the right margin, and SPEC is totally valid in the
> 3. because 2. works.
> 
> Is this a bug?

You need to construct the display property in a different order:

  (insert
     (propertize "E" 'display
                     `((slice 0 0 1.0 20)
		       ((margin left-margin)
		        ,(create-image "~/Downloads/emacs.png"
			  nil nil :scale 1.0)))))

This might be confusing, but the root cause is that 'slice' is not
valid in an image descriptor, it's a display spec.  Whereas the
documentation of marginal display says:

     A margin display specification looks like ‘((margin right-margin)
  SPEC)’ or ‘((margin left-margin) SPEC)’.  Here, SPEC is another display
  specification that says what to display in the margin.  Typically it is
  a string of text to display, or an image descriptor.

So Emacs wants an image descriptor, and that cannot include 'slice'.

In addition, you should use set-window-margins to ensure the margin is
wide enough to allow the display of the slice, because the Emacs
display engine crops images to the width of the available horizontal
screen estate.  So if the margin is not wide enough, you will see
empty space with your slice parameters, since the top-level corner of
the emacs.png image is just empty space.  I assume your real-life use
includes setting the window margins, because otherwise you will se no
margins at all.

Let me also point out the existing function insert-sliced-image, which
you could use to avoid all this low-level stuff.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75776; Package emacs. (Thu, 23 Jan 2025 10:42:01 GMT) Full text and rfc822 format available.

Message #11 received at 75776 <at> debbugs.gnu.org (full text, mbox):

From: Evgeny Zajcev <lg.zevlg <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 75776 <at> debbugs.gnu.org
Subject: Re: bug#75776: 30.0.50; Displaying image slice in the right margin
Date: Thu, 23 Jan 2025 13:41:24 +0300
[Message part 1 (text/plain, inline)]
чт, 23 янв. 2025 г. в 13:02, Eli Zaretskii <eliz <at> gnu.org>:

> > From: Evgeny Zajcev <lg.zevlg <at> gmail.com>
> > Date: Thu, 23 Jan 2025 10:10:05 +0300
> >
> > I'm having problem displaying an image slice in the right margin.  To
> > reproduce this, download
> > https://www.gnu.org/software/emacs/images/emacs.png to your ~/Downloads
> > folder.  Activate right margin with M-x visual-fill-column RET.  And
> consider three pieces of code:
> >
> > 1. (insert
> >      (propertize "E" 'display `((slice 0 0 1.0 20) ,(create-image
> >      "~/Downloads/emacs.png" nil nil :scale 1.0))))
> >
> >    Displays image slice in the buffer as expected.
> >
> > 2. (insert
> >      (propertize "E" 'display `((margin right-margin) ,(create-image
> >      "~/Downloads/emacs.png" nil nil :scale 1.0))))
> >
> >    Displays image in the right margin as expected.
> >
> > 3. (insert
> >      (propertize "E" 'display `((margin right-margin)
> >       ((slice 0 0 1.0 20)
> >       ,(create-image "~/Downloads/emacs.png" nil nil :scale 1.0)))))
> >
> >    Displays "E"
> >
> > Documentation say that ((margin right-margin) SPEC) can be used to
> > display image in the right margin, and SPEC is totally valid in the
> > 3. because 2. works.
> >
> > Is this a bug?
>
> You need to construct the display property in a different order:
>
>   (insert
>      (propertize "E" 'display
>                      `((slice 0 0 1.0 20)
>                        ((margin left-margin)
>                         ,(create-image "~/Downloads/emacs.png"
>                           nil nil :scale 1.0)))))


This works perfectly!  Thanks for your reply and comprehensive explanation

-- 
lg
[Message part 2 (text/html, inline)]

Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Sat, 25 Jan 2025 00:19:03 GMT) Full text and rfc822 format available.

Notification sent to Evgeny Zajcev <lg.zevlg <at> gmail.com>:
bug acknowledged by developer. (Sat, 25 Jan 2025 00:19:03 GMT) Full text and rfc822 format available.

Message #16 received at 75776-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Evgeny Zajcev <lg.zevlg <at> gmail.com>
Cc: 75776-done <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#75776: 30.0.50; Displaying image slice in the right margin
Date: Fri, 24 Jan 2025 18:18:08 -0600
Evgeny Zajcev <lg.zevlg <at> gmail.com> writes:

> This works perfectly!  Thanks for your reply and comprehensive explanation

I'm therefore closing this bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 22 Feb 2025 12:24:31 GMT) Full text and rfc822 format available.

This bug report was last modified 169 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.