Elsa
Elsa copied to clipboard
Using ELSA for Org-mode literate configs
I have a config file written in literate Org-mode. However, I'm beginning to see that literate Elisp is a second-class citizen when it comes to tooling, and so I'm considering rewriting it in a conventional style. Is it possible to use ELSA and flycheck in literate code blocks (which do not have a backing file)? Or should I just go back to .el files where everything will work normally?
Thanks!
I think if you bring the setup under Cask then at least if you edit the block with C-c ' it should work. It will never work in the org-mode buffer itself, I won't even accept pull requests for that because maintaining it would be hell.
We can make the support for the C-c ' dialogs as that should be fairly simple (something like setting up paths + default-directory).
@DamienCassou is working on making Elsa work without Cask so that might make it even easier, though for personal configs where you reference tons of packages something like Cask would be helpful.
OK I've just tried it out of curiosity on my https://github.com/Fuco1/.emacs.d config... there is some literal org files under the files directory.
After adding depends-on for elsa and trinary it does the analysis properly inside the C-c ' indirect buffers.
Note that my config uses Cask and pallet so this was pretty painless.
I'm not sure how that's possible. I have cask enabled and a Cask file with (depends-on "elsa").
Here is the predicate for flycheck-elsa:
(defun flycheck-elsa--enable-p ()
"Return non-nil if we can enable Elsa in current buffer.
We require that the project is managed by Cask and that Elsa is
listed as a dependency."
(when (and (buffer-file-name)
(not (seq-find (lambda (f) (string-match-p f (buffer-file-name)))
flycheck-elsa-ignored-files-regexps)))
(when-let ((cask-file (locate-dominating-file (buffer-file-name) "Cask")))
(let ((bundle (cask-initialize (file-name-directory cask-file))))
(cask-find-dependency bundle 'elsa)))))
Note that (buffer-file-name) is a requirement. But using C-c ' in a block gives you a buffer where (buffer-file-name) is nil.
It returns a file for me, maybe I have different org version.
Oh really? That's interesting...which file does it return for you? An .el file?
My version:
Org mode version 9.1.14 (release_9.1.14-1024-gbfb946 @ /home/matt/.emacs.d/straight/build/org/)
So my file is in /home/matus/.emacs.d/files/org-defs.org. I go to the code block, do C-c ' and then it pops up a separate buffer in emacs lisp mode. When I evaluate (buffer-file-name) inside it I get
/home/matus/.emacs.d/files/org-defs.org[*Org Src org-defs.org[ elisp ]*]
My org version is Org mode version 9.1.6 (9.1.6-48-gfe7619-elpaplus @ /home/matus/.emacs.d/.cask/25.2/elpa/org-plus-contrib-20180212/)
That's really interesting! Looks like your buffers are being temporarily (?) persisted to files with the same name.
Not the same name, there's that extra [*Org Src org-defs.org[ elisp ]*] suffix. I think you can actually set the "visiting file" to any buffer without that file even existing.
What flycheck does is it saves the buffer into a separate file for analysis anyway (something like flycheck_original-name.el).
Okay, I've advised my source function, which passes the predicate. I can't verify for some reason though because my ELSA install is giving me Some dependencies were not available: dash.
You might need to add that to the cask file, I'm not sure why it sometimes can't get the dependencies automatically.