From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: Changing org-block background with org-src-fontify-natively
Date: Thu, 09 Jun 2016 17:05:22 +0200 [thread overview]
Message-ID: <87h9d2z9l9.fsf@gmx.us> (raw)
In-Reply-To: oluegdjp7eb.fsf@med.uni-goettingen.de
[-- Attachment #1: Type: text/plain, Size: 377 bytes --]
Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> My Org mode experience would also benefit a lot from having source block
> backgrounds again and with per-language configurable background colour.
That’s possible with the attache patch. An example of the horrors you can
subject yourself to is also attached.
--
Lasciate ogni speranza, voi che leggete questo.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-src-Allow-per-language-block-face.patch --]
[-- Type: text/x-diff, Size: 2357 bytes --]
From 5d39108d319dc321af95e22c6cb25164dd61e891 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Thu, 9 Jun 2016 16:52:05 +0200
Subject: [PATCH] org-src: Allow per language block face
* lisp/org-src.el (org-src-font-lock-fontify-block):
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Allow per-block
face.
---
lisp/org-src.el | 9 ++++++---
lisp/org.el | 4 +++-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 2f96fdf..d8c0541 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -494,7 +494,10 @@ as `org-src-fontify-natively' is non-nil."
(when (fboundp lang-mode)
(let ((string (buffer-substring-no-properties start end))
(modified (buffer-modified-p))
- (org-buffer (current-buffer)))
+ (org-buffer (current-buffer))
+ (block-faces (let ((face-name (intern (format "org-block-%s" lang))))
+ (append (and (facep face-name) (list face-name))
+ '(org-block)))))
(remove-text-properties start end '(face nil))
(with-current-buffer
(get-buffer-create
@@ -510,12 +513,12 @@ as `org-src-fontify-natively' is non-nil."
(put-text-property
(+ start (1- pos)) (1- (+ start next)) 'face
(list :inherit (append (and new-face (list new-face))
- (list 'org-block)))
+ block-faces))
org-buffer))
(setq pos next))
;; Add the face to the remaining part of the text.
(put-text-property (1- (+ start pos)) end 'face
- '(:inherit org-block) org-buffer)))
+ (list :inherit block-faces) org-buffer)))
(add-text-properties
start end
'(font-lock-fontified t fontified t font-lock-multiline t))
diff --git a/lisp/org.el b/lisp/org.el
index 206ebad..d00de1e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5976,7 +5976,9 @@ by a #."
(add-text-properties beg1 block-end '(src-block t)))
(quoting
(add-text-properties beg1 (min (point-max) (1+ end1))
- '(face org-block))) ; end of source block
+ (let ((face-name (intern (format "org-block-%s" lang))))
+ (append (and (facep face-name) (list face-name))
+ '(face org-block))))) ; end of source block
((not org-fontify-quote-and-verse-blocks))
((string= block-type "quote")
(add-text-properties beg1 (min (point-max) (1+ end1)) '(face org-quote)))
--
2.8.3
[-- Attachment #3: Screenshot from 2016-06-09 16-51-27.png --]
[-- Type: image/png, Size: 70940 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: test.org --]
[-- Type: text/org, Size: 766 bytes --]
#+BEGIN_SRC emacs-lisp :eval never
;; setup
(set-face-attribute 'org-block nil :background
(color-darken-name
(face-attribute 'default :background) 3))
(defface org-block-R
`((t (:background ,(color-lighten-name "#455EB3" 50))))
"Face for R src blocks")
(defface org-block-emacs-lisp
`((t (:background ,(color-lighten-name "#7F5AB6" 30))))
"Face for elisp src blocks")
(defface org-block-python
`((t (:background ,(color-lighten-name "#00FF00" 30))))
"Face for python blocks")
#+END_SRC
#+BEGIN_SRC emacs-lisp :var x=1
(defun x () 1 )
#+END_SRC
#+BEGIN_SRC R
x <- function () 1
#+END_SRC
#+BEGIN_SRC python
def x:
return(1)
#+END_SRC
#+BEGIN_SRC shell
echo 1
#+END_SRC
next prev parent reply other threads:[~2016-06-09 15:08 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-26 19:09 Changing org-block background with org-src-fontify-natively Karl Voit
2015-12-26 21:17 ` Karl Voit
2015-12-27 5:55 ` Xebar Saram
2015-12-27 9:42 ` Karl Voit
2016-01-03 17:06 ` John Kitchin
2016-01-12 9:52 ` Karl Voit
2016-01-12 11:37 ` John Kitchin
2016-01-12 11:53 ` Karl Voit
2016-01-12 13:26 ` John Kitchin
2016-01-13 4:33 ` Nick Dokos
2016-01-13 12:27 ` John Kitchin
2016-01-14 16:59 ` Karl Voit
2016-01-15 0:47 ` John Kitchin
2016-01-15 8:35 ` Andreas Leha
2016-06-09 15:05 ` Rasmus [this message]
2016-06-10 5:24 ` Samuel W. Flint
2016-06-10 5:32 ` Xebar Saram
2016-06-11 11:40 ` Rasmus
2016-06-11 14:44 ` Samuel W. Flint
2016-06-12 0:30 ` Ken Mankoff
2016-06-12 22:06 ` Rasmus
2016-06-13 12:34 ` Alan Schmitt
2016-06-13 17:12 ` Rasmus
2016-06-14 15:23 ` Alan Schmitt
2016-06-10 23:33 ` John Kitchin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h9d2z9l9.fsf@gmx.us \
--to=rasmus@gmx.us \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).