From d4aaecab9b5c7bc0663dd37a8728ccc781309806 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Fri, 26 Mar 2021 13:46:17 +0100 Subject: [PATCH] [Emacs] Better org-mode visuals Now inline source blocks should be fontified We should also have better LaTeX handling as well as markers --- org/config/emacs.org | 282 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 258 insertions(+), 24 deletions(-) diff --git a/org/config/emacs.org b/org/config/emacs.org index d436de9..556816d 100644 --- a/org/config/emacs.org +++ b/org/config/emacs.org @@ -2416,10 +2416,13 @@ such as with this document. <> ;; Beautiful org <> - <> <> + <> + <> <> - <> + <> + <> + <> <> ;; Capture <> @@ -2629,46 +2632,219 @@ of: In order to make org-mode even sexier, let’s enable ~variable-pitch-mode~ for org-mode so we can get some proportional font. I’ll also remove ~auto-fill-mode~ -which seems to stick to Orgmode like hell and I don’t know why. A hook to -org-appear’s minor mode will also be added. +which seems to stick to Orgmode like hell and I don’t know why. #+NAME: beautiful-org-hooks #+BEGIN_SRC emacs-lisp (add-hook 'org-mode-hook 'visual-line-mode) (remove-hook 'org-mode-hook 'auto-fill-mode) (add-hook 'org-mode-hook 'variable-pitch-mode) (auto-fill-mode -1) - (add-hook 'org-mode-hook 'org-appear-mode) #+END_SRC You can then see the modified faces for org-mode [[#User-Configuration-Visual-configuration-Better-faces-Org-mode-07754177][here]]. -Some other tweaks will make Org-mode more beautiful. This includes a new folding -icon, some indentation that is not added whitespace. +By default, I would like my org-mode buffers to be indented and tables to be +aligned. #+NAME: beautiful-org-options #+BEGIN_SRC emacs-lisp (setq org-startup-indented t - org-startup-align-all-tables t - org-pretty-entities t - org-fontify-whole-heading-line t - org-fontify-done-headline t - org-fontify-quote-and-verse-blocks t - org-display-inline-images t - org-redisplay-inline-images t - org-startup-with-inline-images "inlineimages" - org-ellipsis "  ") + org-startup-align-all-tables t) #+END_SRC -Let’s limit the width of images inlined in org buffers to 550px. It roughly -corresponds to the width of a paragraph on which ~org-fill-paragraph~ is called. +***** Fontifying parts of org-mode +:PROPERTIES: +:CUSTOM_ID: User-Configuration-Emacs-builtins-Org-mode-Beautify-Org-mode-Fontifying-parts-of-org-mode-f690ee40 +:END: +Some blocks of org-mode should have their own face, such as the whole heading +line, the done headline, the quote and the verse blocks,… actually, let’s enable +that for all of them. +#+name: beautiful-org-fontify-blocks +#+BEGIN_SRC emacs-lisp +(setq org-pretty-entities t + org-fontify-whole-heading-line t + org-fontify-done-headline t + org-fontify-quote-and-verse-blocks t) +#+END_SRC + +***** Fontifying inline src blocks +:PROPERTIES: +:CUSTOM_ID: User-Configuration-Emacs-builtins-Org-mode-Beautify-Org-mode-Fontifying-inline-src-blocks-bf879724 +:END: +When it comes to source blocks in org-mode, Emacs handle them really well with +some beautiful syntax highlight thanks to the the languages’ major mode and +their font-locks. But inline src blocks are the forgotten child and get next to +no love, which is really sad ; I want it to feel loved, to stand out from the +crowd and to give me what its brother gives me already! + +Enters [[https://tecosaur.github.io/emacs-config/config.html#fontifying-inline-src][Tecosaur’s config]]! With ~org-src-font-lock-fontify-block~, anything’s +possible! And ~{{{results(...)}}}~ can also have the ~org-block~ face applied to +match and make org-mode even more beautiful! Let’s do it: +#+name: beautiful-org-fontify-inline +#+BEGIN_SRC emacs-lisp + (defvar org-prettify-inline-results t + "Whether to use (ab)use prettify-symbols-mode on + {{{results(...)}}}.") + + (defun org-fontify-inline-src-blocks (limit) + "Try to apply `org-fontify-inline-src-blocks-1'." + (condition-case nil + (org-fontify-inline-src-blocks-1 limit) + (error (message "Org mode fontification error in %S at %d" + (current-buffer) + (line-number-at-pos))))) + + (defun org-fontify-inline-src-blocks-1 (limit) + "Fontify inline src_LANG blocks, from `point' up to `LIMIT'." + (let ((case-fold-search t)) + (when + ; stolen from `org-element-inline-src-block-parser' + (re-search-forward "\\_