org-fontify-meta-lines-and-blocks-1: Fontify src blocks without lang

* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Allow fontifying
src blocks with language specification missing.
* lisp/org-src.el (org-src-block-faces): Clarify in the docstring that
"" language name referes to src blocks with no language.  Remove
redundant :version tag.
* etc/ORG-NEWS (~org-src-block-faces~ now accepts empty string ~""~ as
language name): Announce the change.

Link: https://orgmode.org/list/99388ff3711696091f0312a5c3f0bcbd@kragelund.me
This commit is contained in:
Ihor Radchenko 2023-02-17 15:17:04 +03:00
parent 2289739ed4
commit c2ffc6b602
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
3 changed files with 19 additions and 4 deletions

View File

@ -24,6 +24,21 @@ consider [[https://gitlab.com/jackkamm/ob-python-mode-mode][ob-python-mode-mode]
has been ported to. has been ported to.
** New and changed options ** New and changed options
*** ~org-src-block-faces~ now accepts empty string ~""~ as language name
It is now possible to customize face of source blocks without language specifier.
: #+begin_src
: Source block with no language
: #+end_src
For example, to set ~highlight~ face, use
#+begin_src emacs-lisp
(setq org-src-fontify-natively t)
(add-to-list 'org-src-block-faces '("" highlight))
#+end_src
*** New ~org-cite-natbib-export-bibliography~ option defining fallback bibliography style *** New ~org-cite-natbib-export-bibliography~ option defining fallback bibliography style
~natbib~ citation export processor now uses ~natbib~ citation export processor now uses

View File

@ -233,7 +233,8 @@ Each element is a cell of the format
(\"language\" FACE) (\"language\" FACE)
Where FACE is either a defined face or an anonymous face. Where FACE is either a defined face or an anonymous face. Empty
language string refers to source blocks without specified language.
For instance, the following would color the background of For instance, the following would color the background of
emacs-lisp source blocks and python source blocks in purple and emacs-lisp source blocks and python source blocks in purple and
@ -247,7 +248,6 @@ green, respectability.
(choice (choice
(face :tag "Face") (face :tag "Face")
(sexp :tag "Anonymous face")))) (sexp :tag "Anonymous face"))))
:version "26.1"
:package-version '(Org . "9.0")) :package-version '(Org . "9.0"))
(defcustom org-src-tab-acts-natively t (defcustom org-src-tab-acts-natively t

View File

@ -5415,9 +5415,9 @@ by a #."
(org-remove-flyspell-overlays-in beg bol-after-beginline) (org-remove-flyspell-overlays-in beg bol-after-beginline)
(org-remove-flyspell-overlays-in nl-before-endline end-of-endline) (org-remove-flyspell-overlays-in nl-before-endline end-of-endline)
(cond (cond
((and lang (not (string= lang "")) org-src-fontify-natively) (org-src-fontify-natively
(save-match-data (save-match-data
(org-src-font-lock-fontify-block lang block-start block-end)) (org-src-font-lock-fontify-block (or lang "") block-start block-end))
(add-text-properties bol-after-beginline block-end '(src-block t))) (add-text-properties bol-after-beginline block-end '(src-block t)))
(quoting (quoting
(add-text-properties (add-text-properties