简体   繁体   English

仅突出显示“*”,而不是org-mode,emacs中的整个标题行

[英]only highlight “*”, not the entire heading line in org-mode, emacs

How can I only highlight the * star, not the entire heading line, to keep texts in same color? 我怎样才能突出显示*星,而不是整个标题行,以保持文本颜色相同? In the great emacs org-mode 在伟大的emacs组织模式

thanks guys 多谢你们


excample (replace * by #, for cann't bold * in stack-overflow) 例子(用#替换*,因为在堆栈溢出时不能加粗*)

(not below) (不在下面)

# heading text #heading text

this is text body 这是文本正文

(but below) (但在下面)

# heading text 标题文本

this is text body 这是文本正文

Updated Answer 更新的答案

See the variable org-level-color-stars-only , which contains a doc-string that states: " Non-nil means fontify only the stars in each headline. When nil, the entire headline is fontified. Changing it requires restart of `font-lock-mode' to become effective also in regions already fontified. " 请参阅变量org-level-color-stars-only ,其中包含一个文档字符串,其中指出:“ 非零值表示仅标记每个标题中的星号。当为零时,整个标题都会被标记。更改它需要重新启动` “font-lock-mode”也将在已经完成的地区生效。

USAGE: (setq org-level-color-stars-only t) 用法:( (setq org-level-color-stars-only t)


Previous Answer 上一个答案

You can remove or add stars as you see fit -- this example uses two (2) stars together. 您可以根据需要移除或添加星星 - 此示例一起使用两(2)颗星。 If you do just one star, then that would also affect two (2) and three (3) stars together. 如果你只做一颗星,那么它也会影响两颗星(2颗星和三颗星)。 Maybe one of our forum local regexp experts could please give us the code for one star ( but not more than one star ) :) 也许我们的论坛本地regexp专家可以请给我们一个明星的代码( 但不超过一颗星 ):)

(defvar bumble-bee (make-face 'bumble-bee))

(set-face-attribute 'bumble-bee nil :background "black" :foreground "yellow")

(font-lock-add-keywords 'org-mode (list

    (list (concat "\\*\\*")
        '(0 bumble-bee t))

   ))

These control the title of tasks -- you could set them all the same or make them different. 它们控制着任务的标题 - 您可以将它们设置为相同或使它们不同。 Anything you don't want, just set to nil or set to the same color as whatever your regular font is. 任何你不想要的东西,只需设置为nil或设置为与常规字体相同的颜色。

(custom-set-faces

  '(org-level-1 ((t (:foreground "orange" :bold t))))

  '(org-level-2 ((t (:foreground "black" :bold t))))

  '(org-level-3 ((t (:foreground "pink" :bold t))))

  '(org-level-4 ((t (:foreground "cyan" :bold t))))

  )

The other components of the first line are usually: org-tag ; 第一行的其他组件通常是: org-tag ; org-tag-faces ; org-tag-faces ; org-todo-keyword-faces ; org-todo-keyword-faces ; org-priority-faces ; org-priority-faces ; and org-warning : org-warning

(setq org-todo-keyword-faces '(
  ("Active" . (:foreground "red"))
  ("Next Action" . (:foreground "ForestGreen"))
  ("Reference" . (:foreground "purple"))
  ("Someday" . (:foreground "gray65"))
  ("None" . (:foreground "green"))
  ("Delegated" . (:foreground "cyan")) ))

(setq org-tag-faces '(
  ("TODO" . org-warning)
  ))

(setq org-priority-faces '(
  (?A . (:foreground "firebrick" :weight bold))
  (?B . (:foreground "orange"))
  (?C . (:foreground "green"))
  (?D . (:foreground "purple"))
  (?E . (:foreground "blue")) ))

(custom-set-faces
  '(org-tag ((t (:background "gray97" :foreground "gray50"
    :box (:line-width 1 :color "black") :weight regular))))
  '(org-warning ((t (:foreground "black"))))
  )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM