Emacs 组织模式8中的Fontify R代码块
我试图改变组织模式8中R代码块的背景色。在组织模式7中,我能够使用:Emacs 组织模式8中的Fontify R代码块,emacs,elisp,org-mode,Emacs,Elisp,Org Mode,我试图改变组织模式8中R代码块的背景色。在组织模式7中,我能够使用: (defface org-block-background '((t (:background "#dadada"))) "Face used for the source block background.") 但是org block background变量似乎在版本8中消失了 我试过: (defface org-block '((t (:background "#dadada"))) "Face
(defface org-block-background
'((t (:background "#dadada")))
"Face used for the source block background.")
但是
org block background
变量似乎在版本8中消失了
我试过:
(defface org-block
'((t (:background "#dadada")))
"Face used for the source block background.")
它的作用是:
#+BEGIN_SRC
#+END_SRC
及
但由于某种原因,当我指定一种语言时,背景色消失了,例如
#+BEGIN_SRC R
#+END_SRC
我正在mac上工作,运行Emacs 24.3,并已将组织模式升级为v8,使用:
cd ~/.emacs.d/lisp
git clone git://orgmode.org/org-mode.git
cd org-mode
make autoloads
make
make doc
以下是我的init.el文件中的配置:
;;;----- Startup ----------------------------;
;;; Add src directory to path
(add-to-list 'load-path "~/.emacs.d/lisp/")
;;;----- Org-Mode ---------------------------;
;;; Add upgraded org-mode to load path
(add-to-list 'load-path "~/.emacs.d/lisp/org-mode/lisp")
(add-to-list 'load-path "~/.emacs.d/lisp/org-mode/contrib/lisp" t)
;;; fontify code in code blocks
(setq org-src-fontify-natively t)
(defface org-block-begin-line
'((t (:foreground "#666666" :background "#dadada")))
"Face used for the line delimiting the begin of source blocks.")
(defface org-block
'((t (:background "#dadada")))
"Face used for the source block background.")
(defface org-block-end-line
'((t (:foreground "#666666" :background "#dadada")))
"Face used for the line delimiting the end of source blocks.")
(require 'org)
;;;----- ESS/R ------------------------------;
(add-to-list 'load-path "~/.emacs.d/lisp/ess/lisp/")
(load "ess-site")
;;;------ Babel ------------------------------;
;;; Support R
(org-babel-do-load-languages
'org-babel-load-languages
'((R . t)
(latex . t)))
;;;----- Look & feel ----------------------------;
;;; Set default theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'solarized-light t)
有什么想法吗
谢谢 我明白了。原来我克隆了一个旧的组织模式分支,它缺少
org block background
变量!已删除“我的组织模式”文件夹,并使用以下方式重新安装:
cd ~/.emacs.d/lisp
git clone https://github.com/Konubinix/org-mode.git
cd org-mode
make autoloads
make
make doc
然后将我的init.el修改为:
;;;----- Org-Mode ---------------------------;
;;; Add upgraded org-mode to load path
(add-to-list 'load-path "~/.emacs.d/lisp/org-mode/lisp")
(add-to-list 'load-path "~/.emacs.d/lisp/org-mode/contrib/lisp" t)
;;; fontify code in code blocks
(setq org-src-fontify-natively t)
(defface org-block-begin-line
'((t (:foreground "#666666" :background "#dadada")))
"Face used for the line delimiting the begin of source blocks.")
(defface org-block
'((t (:background "#dadada")))
"Face used for the source block background.")
(defface org-block-background
'((t (:background "#dadada")))
"Face used for the source block background.")
(defface org-block-end-line
'((t (:foreground "#666666" :background "#dadada")))
"Face used for the line delimiting the end of source blocks.")
(require 'org)
还有普雷斯托 FYI,在提交之后,这将不适用于当前版本的组织模式(来自Git master分支),至少在某些内容发生变化之前是如此。这已于2014年7月发布,并将继续对组织模式用户生效,例如参见(2015年4月)。任何致力于在本地恢复旧行为的人都可以从提交的diff中进行恢复-我还没有尝试过。组织模式的未来版本可能会恢复该功能,可能会以不同的方式进行。就目前而言,这是您所能获得的全部:
(上面的第一个SRC块从我设置的
org block
中获取背景)结果是org block background
面在提交f8b42e8
的org version 8.3.1中已被删除,因此出现了错误。理由似乎是
ps
export出现错误f8b42e8
中引入的更改。您可以在此处看到提交:
将光标放在要更改字体的点上,然后键入
C-u C-x=
,这将告诉您(除其他外)该点的字体名称。然后,您可以M-x自定义要更改的字体,或在.emacs
文件中手动更改。谢谢!当我将光标放在一个通用的#+BEGIN#u SRC/#+END#u SRC块上时,我得到一个。但是当我在一个#+BEGIN#u SRC R/#+END#u SRC块上做同样的事情时,我得到了。第二个似乎缺少face:org block
属性…?我想您已经找到了--继续尝试修改org block
(例如,“开始块中的面文本…”并查看这是否有助于--M-x在我的Emacs主干开发人员快照上自定义面RET-org block RET
,它显示继承阴影
。因此,您可以删除继承并将其设置为您想要的任何内容,或者改为修改shadow
。保存自定义项以备将来使用后,继续打开.emacs
文件,并根据您的决定查看如何自定义org block
或shadow
。然后,您可以将相关部分复制到init.el
中,如果init.el
中的所有内容都已存在,则可以删除.emacs
文件。当然要备份它(以防万一…),然后再掸灰尘。org block background
face已在org 8.3.1中删除。目前,如果使用旧版本,则恢复此行为的唯一方法似乎是手动撤消引入的更改。看看我的答案,这已经不是最新的了。看看我的答案。
;;;----- Org-Mode ---------------------------;
;;; Add upgraded org-mode to load path
(add-to-list 'load-path "~/.emacs.d/lisp/org-mode/lisp")
(add-to-list 'load-path "~/.emacs.d/lisp/org-mode/contrib/lisp" t)
;;; fontify code in code blocks
(setq org-src-fontify-natively t)
(defface org-block-begin-line
'((t (:foreground "#666666" :background "#dadada")))
"Face used for the line delimiting the begin of source blocks.")
(defface org-block
'((t (:background "#dadada")))
"Face used for the source block background.")
(defface org-block-background
'((t (:background "#dadada")))
"Face used for the source block background.")
(defface org-block-end-line
'((t (:foreground "#666666" :background "#dadada")))
"Face used for the line delimiting the end of source blocks.")
(require 'org)
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index e693dab..83453e8 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -537,9 +537,6 @@ follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword."
:group 'org-faces
:version "22.1")
-(defface org-block-background '((t ()))
- "Face used for the source block background.")
-
(org-copy-face 'org-meta-line 'org-block-begin-line
"Face used for the line delimiting the begin of source blocks.")
diff --git a/lisp/org.el b/lisp/org.el
index a153151..7e30061 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5930,15 +5930,7 @@ by a #."
(cond
((and lang (not (string= lang "")) org-src-fontify-natively)
(org-src-font-lock-fontify-block lang block-start block-end)
- ;; remove old background overlays
- (mapc (lambda (ov)
- (if (eq (overlay-get ov 'face) 'org-block-background)
- (delete-overlay ov)))
- (overlays-at (/ (+ beg1 block-end) 2)))
- ;; add a background overlay
- (setq ovl (make-overlay beg1 block-end))
- (overlay-put ovl 'face 'org-block-background)
- (overlay-put ovl 'evaporate t)) ; make it go away when empty
+ (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
@@ -21828,9 +21820,7 @@ and end of string."
When INSIDE is non-nil, don't consider we are within a src block
when point is at #+BEGIN_SRC or #+END_SRC."
(let ((case-fold-search t) ov)
- (or (and (setq ov (overlays-at (point)))
- (memq 'org-block-background
- (overlay-properties (car ov))))
+ (or (and (eq (get-char-property (point) 'src-block) t))
(and (not inside)
(save-match-data
(save-excursion