dakrone / es-mode

An Emacs major mode for interacting with Elasticsearch
GNU General Public License v3.0
196 stars 34 forks source link

Use es-default-url as buffer local variable #17

Closed drorata closed 9 years ago

drorata commented 9 years ago

I set in my .emacs the variable es-default-url to a certain value that I use my default end point. However, in a certain org-mode buffer I want to have a different end point. I tried to set the the variable locally:

# -*- coding: utf-8; eval: (setq es-default-url "http://localhost:9200"); -*-

However, when trying to evaluate a babel-block it still uses the value defined in .emacs. I also tried to have a babel block:

#+BEGIN_SRC elisp
(setq es-default-url "http://localhost:9200")
#+END_SRC

But it didn't help as well.

Thanks in advance for any kind of help or ideas.

ljos commented 9 years ago

To set it for an org mode buffer I would use at the top of the file:

#+PROPERTY: header-args:es :url "http://localhost:9200"

I haven't tested this, but it should work, and if it doesn't then I need to fix that :D

I will look into how we should treat the es-default-url variable.

drorata commented 9 years ago

Seems to be the workaround I was after. Nevertheless, it seems like babel always refer to the globally defined es-default-url

ljos commented 9 years ago

What do you mean that it always refers to the globally defined es-default-url?

The problem with setting a variable with eval in the file is that then it is local for the current buffer, but when org-babel evaluates a src-block it opens a new buffer and starts es-mode. It doesn't inherit anything from the buffer that opens it. That is why we have the header arguments.

drorata commented 9 years ago

Now I understand. Thanks a lot!

ljos commented 9 years ago

No problem! I take that as the issue was resolved. Please reopen if I misunderstood.