0

I want to pass a buffer's content into a list. I figured out how to read the content of the buffer I want to use but cannot figure out how to correctly capture the content and then use it as a list.

Let's say I have a buffer called "test" whose content is "A" "B" "C"

I've written the following to extract the content

(with-current-buffer "test"
(setq list-of-variables  (buffer-substring-no-properties (point-min)(point-max)))
)

(message "%S" list-of-variables)

The output I got so far literally is " \"A\" \"B\" \"C\" " which is clearly useless as it is not recognized as a proper list...

2
  • emacs.stackexchange.com/tags/elisp/info
    – Drew
    May 22, 2021 at 19:29
  • Please clarify the question, which starts out being about applying a function to a list of arguments, and talks about variables (there's no such function application, and there are no variables, in the rest of the question). Given acceptance of an answer, the question is really apparently about creating a list from bits of buffer text.
    – Drew
    May 22, 2021 at 19:31

1 Answer 1

0
(with-current-buffer "test"
(setq list-of-variables  (split-string (substring-no-properties (buffer-string))))
)

which renders

("\"A\"" "\"B\"" "\"C\"")

You can prefer

 (with-current-buffer "test"
    (setq list-of-variables  
       (split-string (substring-no-properties (buffer-string))"\"" t " "))
    ) 

which renders

("A" "B" "C")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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