1

What is the "standard" way to store some text obtained from a buffer into a variable?

The only way I could think of was to use something along the lines of (let ((beg (point))) (end-of-line) (copy-region-as-kill beg (point))) and then store it with something like (setq var1 (car kill-ring)).

That feels somehow "hacky" and I was wondering if there is another function to do this, that I overlooked?

1

See C-hig (elisp)Buffer Contents

In short, use one of the following:

  • buffer-string
  • buffer-substring
  • buffer-substring-no-properties

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.