I'm trying to read a value of variable context from the config file. I use something like this (but have got an error..):

(insert-file-contents "/home/user/liquibase.properties")
(keep-lines "contexts" point-min point-max)

The file /home/user/liquibase.properties has the following structure:

logLevel: off
contexts: my_context

Give me a direction please. How to read the content of properties-file, filter it and store some value into a variable? To have the same result as after a call:

(setq ctx "my_context")
  • 1
    Point-min and point-max should be function calls. After that you need to parse the line maybe with regular expression or substring. Commented Oct 20, 2016 at 12:49
  • Thanks, John. I've changed point-min/max to (point-min/max). Now it prints the value to the current buffer. How could I parse it and save into var, instead of printing to the buffer?
    – egor7
    Commented Oct 20, 2016 at 16:05

1 Answer 1


Try this:

  (insert-file-contents "config.dat")
  (keep-lines "contexts" (point-min) (point-max)) 
  (setq ctx (when (string-match "contexts: \\(.*\\)" (buffer-string))
          (match-string 1 (buffer-string)))))

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.