Elisp: Convert String to Buffer Text
If you got a long string, and need to insert or delete parts often, it's much more efficient to use buffer data type.
You can put into a buffer by using
with-temp-buffer
, then insert your string, process it, then use buffer-string
to get the whole buffer content.
;; process string in a temp buffer (with-temp-buffer (insert bigString) (goto-char (point-min)) ;; code to manipulate string. eg delete char, etc ;; return whole buffer string (buffer-string))