I have a yasnippet that is intended to create a footnote in org-mode format and automatically insert the contents of the clipboard.
# -*- mode: snippet -*-
# name: footnote
# key: fn
# --
[fn:: `(clipboard-yank)`]
This worked correctly until this week. Desired output is this:
[fn:: foo]
But now when I do it, it truncates the contents and adds a Y, such that when the clipboard contains foo
, entering fn <TAB>
results in this output:
[fn:: ooY]
UPDATE/CLARIFICATION
My yasnippet for org-mode footnotes actually uses not clipboard-yank
but my own custom function pasteboard-paste-no-spaces.
# -*- mode: snippet -*-
# name: footnote
# key: fn
# --
[fn:: `(pasteboard-paste-no-spaces)`]
For simplicity, I mentioned clipboard-yank
since I tested it and it has the same problem. But since I use a custom function, switching to current-kill
won't work for me.
Here's pasteboard-paste-no-spaces
:
(defun pasteboard-paste-no-spaces ()
"Paste from OS X system pasteboard via `pbpaste' to point."
(interactive)
(let ((start (point))
(end (if mark-active
(mark)
(point))))
(shell-command-on-region start end
"pbpaste | perl -p -e 's/\r$//' | tr '\r' '\n'"
nil t)
(save-excursion
)))
UPDATE #2
Thanks for all the help. I'm having the same problem with tiny-expand. I tried using the (with-temp-buffer)
approach you suggested to create a new function yas/tiny-expand
, but it doesn't work:
(defun yas/tiny-expand (&rest args)
"Return the string that `tiny-expand' would insert."
(with-temp-buffer
(apply #'tiny-expand args)
(buffer-string)))
Here is the relevant yasnippet where I tried to use (with-temp-buffer)
: https://gist.github.com/5a799834ddf948ce65a7def95a834401
Here's the original version: https://gist.github.com/1c947de20a1b7790d04d69ac39884f22