I am trying to modify the string that is to yanked
My goal is to modify certains paths before yanking, in order to transform them in relative to path actual buffer file.
Following this post, I tried this simple script :
(setq tmp (car kill-ring-yank-pointer)) ;;(message tmp) (defun replace-in-string (what with in) (replace-regexp-in-string (regexp-quote what) with in nil 'literal)) (replace-in-string "C:\\Users\\Julien Fernandez\\Dropbox\\JULIEN" "../.." tmp) (message tmp)
kill-ring, I have right now :
C:\Users\Julien Fernandez\Dropbox\JULIEN\Screenshots\Emacs\2021-02-03_16-48-43 - Code.png
I get as a result :
Where the file name has been modified, but obviously not as intended.
What should I do ?
PS : I discovered that I did not have to substitute every
\ in `'/' in the path, something like :
works fine ...