From af497c839144a5add9e85b689fc25c4b3dc8daa3 Mon Sep 17 00:00:00 2001 From: Adrien Date: Mon, 13 Jun 2022 08:16:01 +0200 Subject: [PATCH] Update org mode configuration (cleanup/add ANSI color escaping management) Remove unused org-chef package. Set the number of lines for block outputs from which begin_exemple is used (100 lines). Add ANSI color escaping management for the org babel ouput blocks. Update org-fancy-priorities. --- lisp/modes/org.el | 93 ++++++++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 37 deletions(-) diff --git a/lisp/modes/org.el b/lisp/modes/org.el index e60023c..5c6df4b 100644 --- a/lisp/modes/org.el +++ b/lisp/modes/org.el @@ -2,6 +2,8 @@ ;;; Commentary: ;;; Code: +(require 'ob) + (defconst *user-org-data-directory* (path-join *user-data-directory* "org") "Path to user's org data store.") @@ -128,6 +130,17 @@ ;; (interactive) ;; (cancel-timer user/org-mobile-sync-timer)) +;; From https://emacs.stackexchange.com/questions/44664/apply-ansi-color-escape-sequences-for-org-babel-results +(defun user--babel-ansi () + "Add ANSI escaping commands." + (when-let ((beg (org-babel-where-is-src-block-result nil nil))) + (save-excursion + (goto-char beg) + (when (looking-at org-babel-result-regexp) + (let ((end (org-babel-result-end)) + (ansi-color-context-region nil)) + (ansi-color-apply-on-region beg end)))))) + (use-package org :init @@ -336,8 +349,16 @@ org-id-locations-file (path-join *user-org-data-directory* "org-id-locations"))) + ;; https://github.com/rougier/svg-tag-mode + ;; A minor mode for Emacs that replace keywords with nice SVG labels + ;; (use-package svg-tag-mode + ;; :ensure t + ;; :config + ;; (setq svg-tag-tags '(("TODO" . ((lambda (tag) (svg-tag-make "TODO")))))) + ;; ) + ;; https://github.com/grugrut/helm-books/tree/625aadec1541a5ca36951e4ce1301f4b6fe2bf3f - ;; Book search interface for emacs helm. + ;; Book search interface for emacs helm. (use-package helm-books :disabled :config @@ -347,18 +368,6 @@ (file (concat org-directory "book.org")) "* %(helm-books)"))) - ;; https://github.com/Chobbes/org-chef - ;; A package for making a cookbook and managing recipes with org-mode. - (use-package org-chef - :disabled - :config - (add-to-list - 'org-capture-templates - `("c" "Cookbook" entry - (file ,(path-join *user-org-data-directory* "cookbook.org")) - "%(org-chef-get-recipe-from-url)" - :empty-lines 1))) - ;; https://github.com/waymondo/org-repo-todo ;; Simple repository todo management with org-mode (use-package org-repo-todo)) @@ -367,10 +376,15 @@ ;; Working with Code Blocks (use-package ob-core :ensure nil + :hook + ((org-babel-after-execute-hook . user--babel-ansi)) :config (validate-setq ;; Don't ask for validation. - org-confirm-babel-evaluate nil) + org-confirm-babel-evaluate nil + ;; Set the number of lines for block outputs from which it'll placed + ;; in a #+begin_example...#+end_example block + org-babel-min-lines-for-block-output 100) (add-many-to-list 'org-babel-load-languages @@ -381,39 +395,41 @@ (let ((to-load '((emacs-lisp . t) (shell . t)))) (with-executable 'g++ - (push '(C . t) to-load) - ;; Use of lsp-clangd for C/C++ - (setq org-babel-C++-compiler "bear g++")) + (push '(C . t) to-load) + ;; Use of lsp-clangd for C/C++ + (setq org-babel-C++-compiler "bear g++")) (with-executable 'dot - (push '(dot . t) to-load)) + (push '(dot . t) to-load)) (with-executable 'ghc - (push '(haskell . t) to-load)) + (push '(haskell . t) to-load)) (with-executable 'gnuplot - (push '(gnuplot . t) to-load)) + (push '(gnuplot . t) to-load)) (with-executable 'latex - (push '(latex . t) to-load)) + (push '(latex . t) to-load)) (with-executable 'perl - (push '(perl . t) to-load)) + (push '(perl . t) to-load)) + (with-executable 'php + (push '(php . t) to-load)) (with-executable 'python - (push '(python . t) to-load)) + (push '(python . t) to-load)) (with-executable 'R - (push '(R . t) to-load)) + (push '(R . t) to-load)) (with-executable 'ruby - (push '(ruby . t) to-load)) - + (push '(ruby . t) to-load)) + (when (feature-p 'plantuml-mode) - ;; https://github.com/skuro/plantuml-mode - ;; A major mode for editing PlantUML sources in Emacs - (use-package ob-plantuml - :ensure nil - :after modes/plantuml - :config - (validate-setq - org-plantuml-jar-path *user-plantuml-jar-path*)) - (push '(plantuml . t) to-load)) + ;; https://github.com/skuro/plantuml-mode + ;; A major mode for editing PlantUML sources in Emacs + (use-package ob-plantuml + :ensure nil + :after modes/plantuml + :config + (validate-setq + org-plantuml-jar-path *user-plantuml-jar-path*)) + (push '(plantuml . t) to-load)) (org-babel-do-load-languages 'org-babel-load-languages to-load)) - + ;; https://github.com/dfeich/helm-lib-babel/tree/41bc0cdea8a604c6c8dc83ed5066644d33688fad ;; Emacs helm extension for inserting a reference to an org source block function (use-package helm-lib-babel) @@ -658,7 +674,10 @@ ;; https://github.com/harrybournis/org-fancy-priorities ;; Display Org Mode priorities as custom strings (use-package org-fancy-priorities - :hook (org-mode-hook . org-fancy-priorities-mode)) + :hook + (org-mode-hook . org-fancy-priorities-mode) + :config + (setq org-fancy-priorities-list '("HIGH" "MID" "LOW" "OPTIONAL"))) ;; https://github.com/calvinwyoung/org-autolist ;; Making it even easier to edit lists in org-mode! (use-package org-autolist