bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#78037: 30.1; Insert link when using org-yank regardless if file alre


From: Thomas Ramsauer
Subject: bug#78037: 30.1; Insert link when using org-yank regardless if file already exists
Date: Thu, 24 Apr 2025 08:27:54 +0000

The new org-yank functionality for attaching e.g. screenshots to
org-documents is really nice.
But sometimes an image would need to be linked to in different
documents.
With the following settings however, a second linking is not possible as a "File
already exists" error is triggered before the link is created.

  (when (>= emacs-major-version 30)
      (setq org-yank-dnd-method 'attach)
      (setq org-yank-dnd-default-attach-method 'cp)
      (setq org-yank-image-save-method tr/org-download-directory))

I guess this is triggered in org--image-yank-media-handler.

An error check for existence and still insertion of the link would be
much appreciated for this situation.

Could something like this work? I am not very good in writing lisp code:


---
      ;; DATA is a raw image.  Tell Emacs to write it raw, without
      ;; trying to auto-detect the coding system.
    + (condition-case err
        (let ((coding-system-for-write 'emacs-internal))
          (with-temp-file absname
              (insert data)))
    +  (message "File already exists in %s" org-yank-image-save-method))
        
-----

Best regards
Tom



In GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.49,
cairo version 1.18.4)
Windowing system distributor 'The X.Org Foundation', version 11.0.12101016
System Description: Manjaro Linux

Configured using:
 'configure --with-x-toolkit=gtk3 --sysconfdir=/etc --prefix=/usr
 --libexecdir=/usr/lib --localstatedir=/var --disable-build-details
 --with-cairo --with-harfbuzz --with-libsystemd --with-modules
 --with-native-compilation=aot --with-tree-sitter 'CFLAGS=-march=x86-64
 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3
 -Wformat -Werror=format-security -fstack-clash-protection
 -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g
 -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs -flto=auto'
 'LDFLAGS=-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro
 -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LC_MONETARY: de_DE.UTF-8
  value of $LC_TIME: de_DE.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8

Major mode: Org

Minor modes in effect:
  global-aggressive-indent-mode: t
  windmove-mode: t
  denote-menu-bar-mode: t
  org-roam-db-autosync-mode: t
  compile-angel-on-save-mode: t
  compile-angel-on-load-mode: t
  citar-embark-mode: t
  smartparens-global-mode: t
  smartparens-mode: t
  pdf-occur-global-minor-mode: t
  beacon-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  pcre-mode: t
  server-mode: t
  which-key-mode: t
  recentf-mode: t
  ultra-scroll-mode: t
  pixel-scroll-precision-mode: t
  all-the-icons-completion-mode: t
  marginalia-mode: t
  vertico-mode: t
  olivetti-mode: t
  org-indent-mode: t
  global-jinx-mode: t
  jinx-mode: t
  auto-dark-mode: t
  doom-modeline-mode: t
  dired-async-mode: t
  spacious-padding-mode: t
  org-bullets-mode: t
  corfu-popupinfo-mode: t
  global-corfu-mode: t
  corfu-mode: t
  savehist-mode: t
  desktop-save-mode: t
  global-evil-surround-mode: t
  evil-surround-mode: t
  evil-escape-mode: t
  global-evil-collection-unimpaired-mode: t
  evil-collection-unimpaired-mode: t
  evil-mode: t
  evil-local-mode: t
  general-override-mode: t
  gcmh-mode: t
  global-auto-revert-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  visual-line-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  abbrev-mode: t

Load-path shadows:
/home/tom/.emacs.d/elpa/ef-themes-1.8.0/theme-loaddefs hides 
/home/tom/.emacs.d/elpa/modus-themes-20241107.816/theme-loaddefs
/home/tom/.emacs.d/elpa/transient-20241111.1438/transient hides 
/usr/share/emacs/30.1/lisp/transient
/home/tom/.emacs.d/elpa/which-key-20240620.2145/which-key hides 
/usr/share/emacs/30.1/lisp/which-key
/home/tom/.emacs.d/elpa/ef-themes-1.8.0/theme-loaddefs hides 
/usr/share/emacs/30.1/lisp/theme-loaddefs

Features:
(shadow emacsbug char-fold org-archive yaml-mode denote-rename-buffer
aggressive-indent windmove citar-org image-file image-converter
tramp-cache shortdoc dired-x gnus-dired nerd-icons-dired misearch
multi-isearch org-colview org-crypt org-ctags org-mouse org-plot ox-md
ox-texinfo org-ref-natbib-bbl-citeproc view ace-window cal-iso cal-move
undo-fu time-stamp denote tabify org-roam-protocol org-protocol org-ref
org-ref-core openalex request org-ref-glossary org-ref-bibtex sgml-mode
avy doi-utils org-ref-utils org-ref-export ox-pandoc ht ox-org
org-ref-misc-links org-ref-label-link org-ref-ref-links
org-ref-citation-links xref org-ref-bibliography-links bibtex-completion
biblio biblio-download biblio-dissemin biblio-ieee biblio-hal
biblio-dblp biblio-crossref biblio-arxiv timezone biblio-doi biblio-core
org-roam-dailies org-roam-migrate org-roam-log org-roam-mode
org-roam-capture org-roam-id org-roam-node org-roam-db
emacsql-sqlite-builtin sqlite org-roam-utils org-roam-compat org-roam
emacsql-sqlite emacsql-sqlite-common emacsql emacsql-compiler shr-color
sort gnus-cite smiley mm-archive mail-extr qp textsec uni-scripts
idna-mapping ucs-normalize uni-confusable textsec-check cl-print
help-fns radix-tree woman man pulse color sphinx-doc python-mode
info-look tramp-sh hideshow hippie-exp flymake ert ewoc debug backtrace
cc-cmds cc-engine cc-vars cc-defs org-pdftools pdf-annot facemenu
org-noter org-noter-djvu org-noter-nov org-noter-pdf org-noter-core
org-alert alert log4e gntp org-rich-yank compile-angel citar-embark
embark-org embark-consult embark ffap languagetool languagetool-server
languagetool-console languagetool-java languagetool-issue
languagetool-correction languagetool-core ispell anki-editor ox-odt
rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse
nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar ox-html table
ox-ascii ox-publish ox smartparens pdf-occur ibuf-ext ibuffer
ibuffer-loaddefs tablist tablist-filter semantic/wisent/comp
semantic/wisent semantic/wisent/wisent semantic/util-modes semantic/util
semantic semantic/tag semantic/lex semantic/fw mode-local cedet
pdf-isearch pdf-misc pdf-tools cus-edit cus-start cus-load pdf-view
pdf-cache pdf-info tq pdf-util pdf-macs cape consult-mu consult
mu4e-icalendar gnus-icalendar org-capture icalendar diary-lib
diary-loaddefs beacon rainbow-delimiters org-ql peg ts org-duration
magit-bookmark 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 which-func imenu
magit-diff smerge-mode diff diff-mode track-changes git-commit log-edit
pcvs-util add-log magit-core magit-autorevert magit-margin
magit-transient magit-process with-editor magit-mode transient benchmark
magit-git magit-base magit-section cursor-sensor evil-collection-mu4e
mu4e mu4e-org mu4e-notification notifications mu4e-main smtpmail
mu4e-view mu4e-mime-parts crm mu4e-headers mu4e-thread mu4e-actions
mu4e-compose mu4e-draft gnus-msg mu4e-search mu4e-lists mu4e-bookmarks
mu4e-mark mu4e-message flow-fill mule-util mu4e-contacts mu4e-update
pcre2el rxt re-builder mu4e-folders mu4e-context mu4e-query-items
mu4e-server mu4e-modeline mu4e-vars mu4e-helpers mu4e-config mu4e-window
bookmark pp ido mu4e-obsolete hide-mode-line server which-key recentf
tree-widget ultra-scroll pixel-scroll cua-base all-the-icons-completion
marginalia orderless vertico tramp-ftp tramp trampver tramp-integration
files-x tramp-message tramp-compat tramp-loaddefs loadhist citar-capf
oc-csl citeproc citeproc-itemgetters citeproc-cite citeproc-biblatex
citeproc-bibtex citeproc-subbibs citeproc-sort citeproc-name
citeproc-formatters citeproc-proc citeproc-disamb citeproc-itemdata
citeproc-generic-elements citeproc-macro citeproc-choose citeproc-date
citeproc-number rst citeproc-context citeproc-prange citeproc-style
citeproc-locale citeproc-term citeproc-rt citeproc-lib citeproc-s
let-alist queue citar citar-file citar-cache citar-format parsebib
olivetti face-remap org-indent oc-basic disp-table 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
gnus-cloud nnimap nnmail mail-source utf7 nnoo parse-time gnus-spec
gnus-int gnus-range message sendmail yank-media rfc822 mml mml-sec epa
derived epg rfc6068 epg-config mm-decode mm-bodies mm-encode mailabbrev
gmm-utils mailheader gnus-win gnus nnheader gnus-util mail-utils range
wid-edit ol-docview doc-view jka-compr image-mode exif ol-bibtex bibtex
iso8601 ol-bbdb ol-w3m ol-doi org-link-doi jinx doom-tokyo-night-theme
doom-themes-ext-org doom-themes doom-themes-base ef-kassio-theme
ef-themes auto-dark doom-modeline doom-modeline-segments
doom-modeline-env doom-modeline-core shrink-path f s nerd-icons
nerd-icons-faces nerd-icons-data nerd-icons-data-mdicon
nerd-icons-data-flicon nerd-icons-data-codicon nerd-icons-data-devicon
nerd-icons-data-sucicon nerd-icons-data-wicon nerd-icons-data-faicon
nerd-icons-data-powerline nerd-icons-data-octicon
nerd-icons-data-pomicon nerd-icons-data-ipsicon all-the-icons-dired
all-the-icons all-the-icons-faces data-material data-weathericons
data-octicons data-fileicons data-faicons data-alltheicons wgrep grep
dired-narrow delsel dired-hacks-utils dash dired-async dired-aux dired
dired-loaddefs spacious-padding hl-line solar cal-dst org-habit
ob-plantuml ob-ditaa ob-latex ob-shell shell ob-python python project
ob-R noflet cl-indent org-bullets org-clock dbus compile
text-property-search xml org-download org-attach org-agenda org-element
org-persist xdg org-id org-element-ast inline avl-tree generator
org-refile org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-src sh-script smie treesit executable ob-comint org-pcomplete
pcomplete comint ansi-osc ansi-color org-list org-footnote org-faces
org-entities time-date noutline outline ob-emacs-lisp ob-core ob-eval
org-version org-cycle org-table ol org-fold org-fold-core org-keys
org-loaddefs advice find-func url-http url-auth mail-parse rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw nsm puny async oc
org-compat org-macs format-spec corfu-popupinfo corfu compat savehist
evil-collection-calendar cal-menu calendar cal-loaddefs
display-line-numbers desktop frameset evil-surround diminish evil-escape
evil-collection-unimpaired evil-collection evil-integration annalist
evil evil-keybindings evil-maps evil-commands reveal evil-jumps
evil-command-window evil-types evil-search evil-ex evil-macros
evil-repeat evil-states evil-core comp comp-cstr warnings comp-run
comp-common rx evil-common thingatpt rect evil-vars edmacro kmacro hydra
ring lv general gcmh cl-extra help-mode autorevert filenotify
use-package-ensure-system-package system-packages use-package
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode vc-use-package use-package-ensure use-package-core
academic-phrases-autoloads ace-jump-mode-autoloads ace-window-autoloads
ag-autoloads aggressive-indent-autoloads
all-the-icons-completion-autoloads all-the-icons-dired-autoloads
all-the-icons-autoloads anki-editor-autoloads auctex-autoloads tex-site
auto-dark-autoloads beacon-autoloads cape-autoloads
catppuccin-theme-autoloads citar-embark-autoloads citar-autoloads
compile-angel-autoloads conda-autoloads consult-dir-autoloads
corfu-autoloads denote-autoloads diminish-autoloads
dired-narrow-autoloads dired-sidebar-autoloads dired-subtree-autoloads
dired-hacks-utils-autoloads dirvish-autoloads
discover-my-major-autoloads dockerfile-mode-autoloads
doom-modeline-autoloads doom-themes-autoloads dracula-theme-autoloads
dwim-shell-command-autoloads eat-autoloads ef-themes-autoloads
eldoc-box-autoloads embark-consult-autoloads consult-autoloads
embark-autoloads esup-autoloads evil-collection-autoloads
annalist-autoloads evil-escape-autoloads evil-surround-autoloads
evil-autoloads expand-region-autoloads fill-column-indicator-autoloads
flycheck-ledger-autoloads flycheck-autoloads fringe-helper-autoloads
gcmh-autoloads general-autoloads finder-inf goto-chg-autoloads
helm-org-rifle-autoloads helm-autoloads helm-core-autoloads
hide-mode-line-autoloads highlight-indent-guides-autoloads
imenu-list-autoloads jinx-autoloads kind-icon-autoloads
languagetool-autoloads ledger-mode-autoloads magit-todos-autoloads
magit-autoloads pcase hl-todo-autoloads makey-autoloads
marginalia-autoloads markdown-mode-autoloads modus-themes-autoloads
multi-web-mode-autoloads nerd-icons-dired-autoloads nerd-icons-autoloads
noflet-autoloads nord-theme-autoloads olivetti-autoloads
orderless-autoloads org-alert-autoloads org-analyzer-autoloads
org-bullets-autoloads org-clock-convenience-autoloads
org-download-autoloads async-autoloads org-drill-autoloads
org-pdftools-autoloads org-noter-autoloads org-pomodoro-autoloads
alert-autoloads log4e-autoloads gntp-autoloads org-present-autoloads
org-ql-autoloads org-ref-autoloads citeproc-autoloads
bibtex-completion-autoloads biblio-autoloads biblio-core-autoloads
avy-autoloads hydra-autoloads lv-autoloads org-rich-yank-autoloads
org-roam-autoloads magit-section-autoloads emacsql-autoloads
org-super-agenda-autoloads org-transclusion-autoloads
org-web-tools-autoloads esxml-autoloads kv-autoloads ov-autoloads
ox-clip-autoloads htmlize-autoloads ox-pandoc-autoloads ht-autoloads
pandoc-autoloads parsebib-autoloads pcre2el-autoloads
pdf-tools-autoloads persist-autoloads plz-autoloads
python-mode-autoloads pythonic-autoloads qrencode-autoloads
queue-autoloads rainbow-delimiters-autoloads rainbow-mode-autoloads
ready-player-autoloads request-autoloads shrink-path-autoloads
f-autoloads smartparens-autoloads spacious-padding-autoloads
sphinx-doc-autoloads string-inflection-autoloads svg-lib-autoloads
synosaurus-autoloads system-packages-autoloads tablist-autoloads
transient-autoloads ts-autoloads s-autoloads dash-autoloads
ultra-scroll-autoloads undo-fu-autoloads vc-use-package-autoloads
vcard-autoloads vertico-autoloads visual-fill-column-autoloads
wc-mode-autoloads wfnames-autoloads wgrep-autoloads which-key-autoloads
info with-editor-autoloads writegood-mode-autoloads xclip-autoloads
xresources-theme-autoloads yaml-mode-autoloads yankpad-autoloads
yasnippet-snippets-autoloads yasnippet-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 icons 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 dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process native-compile emacs)

Memory information:
((conses 16 2791978 3804094) (symbols 48 69619 279) (strings 32 437390 95624)
 (string-bytes 1 14869440) (vectors 16 189796) (vector-slots 8 3028976 1916563)
 (floats 8 2652 13996) (intervals 56 222294 40023) (buffers 992 112))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]