Move Org source blocks with Eglot functionality to `oglot' library
This commit is contained in:
parent
a43104c2eb
commit
c81a45820e
45
README.org
45
README.org
@ -2988,8 +2988,8 @@ to add =HTML+CSS+JS= for ~mhtml-mode~:
|
|||||||
|
|
||||||
#+caption[Buffer properties]:
|
#+caption[Buffer properties]:
|
||||||
#+caption: Buffer properties.
|
#+caption: Buffer properties.
|
||||||
#+name: lst:buffer-properties
|
#+name: lst:buffer-properties-XXX
|
||||||
#+begin_src emacs-lisp -n :results silent
|
#+begin_src emacs-lisp -n :results silent :tangle no
|
||||||
(with-eval-after-load 'org
|
(with-eval-after-load 'org
|
||||||
(defconst prop-comments-link-re
|
(defconst prop-comments-link-re
|
||||||
"\\( :comments link$\\)\\|\\( *$\\)"
|
"\\( :comments link$\\)\\|\\( *$\\)"
|
||||||
@ -3008,20 +3008,24 @@ to add =HTML+CSS+JS= for ~mhtml-mode~:
|
|||||||
(format prop-ha-re-template "python")
|
(format prop-ha-re-template "python")
|
||||||
"Regexp to find `#+property:' Python header arguments.")
|
"Regexp to find `#+property:' Python header arguments.")
|
||||||
|
|
||||||
(defun prop-python-link-comments-toggle ()
|
(defun prop-python-comments-link-toggle ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(if (re-search-forward prop-python-ha-re nil 'noerror)
|
(if (re-search-forward prop-python-ha-re nil 'noerror)
|
||||||
(if (re-search-forward prop-comments-link-re nil t)
|
(when (re-search-forward prop-comments-link-re nil t)
|
||||||
(if (match-string 1)
|
(if (match-string 1)
|
||||||
(replace-match " ")
|
(replace-match " ")
|
||||||
(replace-match " :comments link"))
|
(replace-match " :comments link"))
|
||||||
(user-error "Found no python link comment"))
|
(org-ctrl-c-ctrl-c))
|
||||||
(user-error "Found no python header arguments property")))
|
(user-error "Found no python header arguments property")))))
|
||||||
(move-beginning-of-line 1)
|
#+end_src
|
||||||
(org-ctrl-c-ctrl-c))
|
|
||||||
|
|
||||||
|
#+caption[Buffer properties]:
|
||||||
|
#+caption: Buffer properties.
|
||||||
|
#+name: lst:buffer-properties
|
||||||
|
#+begin_src emacs-lisp -n :results silent
|
||||||
|
(with-eval-after-load 'org
|
||||||
(defun org-get-buffer-properties ()
|
(defun org-get-buffer-properties ()
|
||||||
"Get all properties in buffer."
|
"Get all properties in buffer."
|
||||||
(org-element-map (org-element-parse-buffer) 'keyword
|
(org-element-map (org-element-parse-buffer) 'keyword
|
||||||
@ -4779,7 +4783,7 @@ configuration:
|
|||||||
#+caption: 1st help to setup any =org-src-mode= buffers for =eglot=.
|
#+caption: 1st help to setup any =org-src-mode= buffers for =eglot=.
|
||||||
#+caption: Bad practice.
|
#+caption: Bad practice.
|
||||||
#+name: lst:help-setup-org-src-mode-for-eglot-1
|
#+name: lst:help-setup-org-src-mode-for-eglot-1
|
||||||
#+begin_src emacs-lisp -n :results silent
|
#+begin_src emacs-lisp -n :results silent :tangle no
|
||||||
;;; Begin: Eglot and Org Babel source blocks
|
;;; Begin: Eglot and Org Babel source blocks
|
||||||
|
|
||||||
;; https://www.reddit.com/r/emacs/comments/w4f4u3
|
;; https://www.reddit.com/r/emacs/comments/w4f4u3
|
||||||
@ -4824,7 +4828,7 @@ the Org-mode source block code before calling `eglot-ensure'."
|
|||||||
#+caption: 2nd help to setup any =org-src-mode= buffers for =eglot=.
|
#+caption: 2nd help to setup any =org-src-mode= buffers for =eglot=.
|
||||||
#+caption: Best practice.
|
#+caption: Best practice.
|
||||||
#+name: lst:help-setup-org-src-mode-for-eglot-2
|
#+name: lst:help-setup-org-src-mode-for-eglot-2
|
||||||
#+begin_src emacs-lisp -n :results silent
|
#+begin_src emacs-lisp -n :results silent :tangle no
|
||||||
;; https://www.reddit.com/r/emacs/comments/w4f4u3
|
;; https://www.reddit.com/r/emacs/comments/w4f4u3
|
||||||
;; /using_rustic_eglot_and_orgbabel_for_literate/
|
;; /using_rustic_eglot_and_orgbabel_for_literate/
|
||||||
(defun eglot-org-babel-edit-prep (info)
|
(defun eglot-org-babel-edit-prep (info)
|
||||||
@ -4871,7 +4875,7 @@ the Org-mode source block code before calling `eglot-ensure'."
|
|||||||
#+caption: 3rd help to setup any =org-src-mode= buffers for =eglot=.
|
#+caption: 3rd help to setup any =org-src-mode= buffers for =eglot=.
|
||||||
#+caption: Good practice.
|
#+caption: Good practice.
|
||||||
#+name: lst:help-setup-org-src-mode-for-eglot-3
|
#+name: lst:help-setup-org-src-mode-for-eglot-3
|
||||||
#+begin_src emacs-lisp -n :results silent
|
#+begin_src emacs-lisp -n :results silent :tangle no
|
||||||
;; https://www.reddit.com/r/emacs/comments/w4f4u3
|
;; https://www.reddit.com/r/emacs/comments/w4f4u3
|
||||||
;; /using_rustic_eglot_and_orgbabel_for_literate/
|
;; /using_rustic_eglot_and_orgbabel_for_literate/
|
||||||
(defun eglot-org-babel-edit-prep-if-let (info)
|
(defun eglot-org-babel-edit-prep-if-let (info)
|
||||||
@ -4919,7 +4923,7 @@ the Org-mode source block code before calling `eglot-ensure'."
|
|||||||
#+caption[Setup Python =org-src-mode= buffers for =eglot=]:
|
#+caption[Setup Python =org-src-mode= buffers for =eglot=]:
|
||||||
#+caption: Setup Python =org-src-mode= buffers for =eglot=.
|
#+caption: Setup Python =org-src-mode= buffers for =eglot=.
|
||||||
#+name: lst:setup-python-org-src-mode-for-eglot
|
#+name: lst:setup-python-org-src-mode-for-eglot
|
||||||
#+begin_src emacs-lisp -n :results silent
|
#+begin_src emacs-lisp -n :results silent :tangle no
|
||||||
;; https://www.reddit.com/r/emacs/comments/w4f4u3
|
;; https://www.reddit.com/r/emacs/comments/w4f4u3
|
||||||
;; /using_rustic_eglot_and_orgbabel_for_literate/
|
;; /using_rustic_eglot_and_orgbabel_for_literate/
|
||||||
(defun org-babel-edit-prep:python (info)
|
(defun org-babel-edit-prep:python (info)
|
||||||
@ -4948,6 +4952,13 @@ This is to advice `org-edit-src-exit' and `org-edit-src-save'."
|
|||||||
|
|
||||||
(advice-add 'org-edit-src-exit :before #'undo-eglot-org-babel-edit-prep)
|
(advice-add 'org-edit-src-exit :before #'undo-eglot-org-babel-edit-prep)
|
||||||
(advice-add 'org-edit-src-save :before #'undo-eglot-org-babel-edit-prep)
|
(advice-add 'org-edit-src-save :before #'undo-eglot-org-babel-edit-prep)
|
||||||
|
|
||||||
|
;;; End: Eglot and Org Babel source blocks
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp -n :results silent
|
||||||
|
(when (package-installed-p 'oglot)
|
||||||
|
(require 'oglot))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+caption[Start =eglot= in case of a proper =dir-local-variables-alist=]:
|
#+caption[Start =eglot= in case of a proper =dir-local-variables-alist=]:
|
||||||
@ -4955,7 +4966,7 @@ This is to advice `org-edit-src-exit' and `org-edit-src-save'."
|
|||||||
#+name: lst:eglot-maybe-ensure
|
#+name: lst:eglot-maybe-ensure
|
||||||
#+begin_src emacs-lisp -n :results silent
|
#+begin_src emacs-lisp -n :results silent
|
||||||
(defun eglot-maybe-ensure ()
|
(defun eglot-maybe-ensure ()
|
||||||
(when (and (apply #'derived-mode-p eglot-maybe-ensure-modes)
|
(when (and (apply #'derived-mode-p '(python-mode))
|
||||||
(assoc 'eglot-workspace-configuration dir-local-variables-alist))
|
(assoc 'eglot-workspace-configuration dir-local-variables-alist))
|
||||||
(eglot-ensure)))
|
(eglot-ensure)))
|
||||||
|
|
||||||
@ -4963,8 +4974,6 @@ This is to advice `org-edit-src-exit' and `org-edit-src-save'."
|
|||||||
;; `hack-local-variables-hook' are OK, but language mode hooks like
|
;; `hack-local-variables-hook' are OK, but language mode hooks like
|
||||||
;; `python-mode-hook' are not.
|
;; `python-mode-hook' are not.
|
||||||
(add-hook 'after-change-major-mode-hook #'eglot-maybe-ensure)
|
(add-hook 'after-change-major-mode-hook #'eglot-maybe-ensure)
|
||||||
|
|
||||||
;;; End: Eglot and Org Babel source blocks
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+caption[Whiten Black]:
|
#+caption[Whiten Black]:
|
||||||
|
Loading…
Reference in New Issue
Block a user