emacs

Gent Krasniqi 2026-02-17T09:29:27.059989Z

Does anyone know if there's an inbuilt way to insert either the last kill or another buffer as an escaped string in the current buffer? Seems like one of those things that is probably there, but I can't find, because emacs names it differently compared to anything else 😄.

ska 2026-02-17T10:42:28.768609Z

Escaped according to what? Clojure strings? URL encoding? Something else?

Gent Krasniqi 2026-02-17T11:18:32.403489Z

elisp strings I guess

Gent Krasniqi 2026-02-17T11:22:30.405969Z

In any case I mostly mean things like \n \t \"

Gent Krasniqi 2026-02-17T12:48:27.767539Z

The trouble I had with everything I tried is that for example evaling (`M-:`) (insert ...) would again unescape the string.

ska 2026-02-17T12:48:38.317089Z

Just as a starting point:

(defun my-insert-elisp-string ()
  (interactive)
  (insert
   (prin1-to-string
    (substring-no-properties
     (or
      (gui-get-selection)
      (gui-get-primary-selection))))))

Gent Krasniqi 2026-02-17T12:50:14.938099Z

(substring-no-properties (current-kill 0)) yep just was trying that, and it works well enough from a scratch buffer with pp-eval-last-sexp

Gent Krasniqi 2026-02-17T17:55:23.643699Z

For posterity, I see that there is a pp-eval-expression that I could use in the original workflow I had in mind, as a stand-in replacement for M-: (eval-expression) when I have this occasional need.