문제

I would like to enable auto-complete for Babel code blocks in org-mode:

#+begin_src emacs-lisp
(setq )                 <--- language-aware auto-completion here
#+end_src

What do I need to add to my .emacs file in order to configure auto-complete to do this?

도움이 되었습니까?

해결책 3

The most robust (and entirely not org-mode specific) way to do this involves an indirect buffer. Here's a blog post that explains indirect buffers in depth. Basically an indirect buffer mirrors the contents of a section of another buffer.

(defun narrow-to-region-indirect (start end)
  "Restrict editing in this buffer to the current region, indirectly."
  (interactive "r")
  (deactivate-mark)
  (let ((buf (clone-indirect-buffer nil nil)))
    (with-current-buffer buf
      (narrow-to-region start end))
      (switch-to-buffer buf)))

At this point, you will have a new buffer that contains the region you previously made. You can enable a major mode for that buffer and edit to your satisfaction--the changes you make are (like any good mirror should do) reflected in the original document.

다른 팁

Late to the party but today the default (and recommended way without other hacks) is to switch to the dedicated elisp buffer for that "hunk" using 'org-edit-special which today is mapped to

C-c- '

Hit the same to return to your org file editing.

You can switch to a dedicated session with the right mode and auto-completion simply with C-c C-v z when you are in a code block.

C-c C-v z or C-c C-v org-babel-switch-to-session-with-code

Check the org-documentation 14.11 Key bindings and useful functions for more information.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top