emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Terje Larsen <terlar@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Add customization to fontify TODO headlines
Date: Sun, 01 Dec 2019 21:27:27 +0100	[thread overview]
Message-ID: <871rtniyfk.fsf@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 450 bytes --]

This adds a feature similar to the org-fontify-done-headline, but
instead for the TODO headlines.

This is enabled with the boolean customization org-fontify-todo-headline
and can be themed via the face org-headline-todo.

I was missing this when I wanted to distinguish more clearly between the
TODO headlines and the other headlines (more so than the highlighted
TODO keyword(s)).

Hope someone else finds this useful.

Best regards,
Terje Larsen


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org: Add customization to fontify TODO headlines --]
[-- Type: text/x-patch, Size: 3707 bytes --]

From 57dd1fca737794f4c20d439d1fbf288511b1e44f Mon Sep 17 00:00:00 2001
From: Terje Larsen <terlar@gmail.com>
Date: Sun, 1 Dec 2019 20:20:55 +0100
Subject: [PATCH] org: Add customization to fontify TODO headlines

* lisp/org (org-fontify-todo-headline): Add new boolean customization to
  toggle this behavior.
* lisp/org (org-set-font-lock-defaults): Apply face org-headline-todo to
  lines starting with keywords in org-not-done-keywords.
* lisp/org-faces (org-headline-todo): Add new face to customize look of
  todo headlines.
---
 etc/ORG-NEWS      |  5 +++++
 lisp/org-faces.el |  9 +++++++++
 lisp/org.el       | 18 ++++++++++++++++++
 3 files changed, 32 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 689a07871..872cebf76 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -20,6 +20,11 @@ work also for this level.  In other words; defining things in a
 property drawer before the first headline will make them "inheritable"
 for all headlines.
 
+*** Fontify whole TODO headlines
+This feature is the same as =org-fontify-done-headline=, but for TODO
+headlines instead. This allows you to distinguish TODO headlines from
+normal headlines. The face can be customized via =org-headline-todo=.
+
 * Version 9.3
 
 ** Incompatible changes
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index a97d4dc4a..416f49b52 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -243,6 +243,15 @@ is of course immediately visible, but for example a passed deadline is
 of the frame, for example."
   :group 'org-faces)
 
+(defface org-headline-todo	  ;Copied from `font-lock-string-face'
+  '((((class color) (min-colors 16) (background light)) (:foreground "Red4"))
+    (((class color) (min-colors 16) (background dark)) (:foreground "Pink2"))
+    (((class color) (min-colors 8)  (background light)) (:bold t)))
+  "Face used to indicate that a headline is marked as TODO.
+This face is only used if `org-fontify-todo-headline' is set.  If applies
+to the part of the headline after the TODO keyword."
+  :group 'org-faces)
+
 (defface org-headline-done	  ;Copied from `font-lock-string-face'
   '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
     (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
diff --git a/lisp/org.el b/lisp/org.el
index 20c263f74..53bc47641 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3686,6 +3686,15 @@ hide them with `org-toggle-custom-properties-visibility'."
   :version "24.3"
   :type '(repeat (string :tag "Property Name")))
 
+(defcustom org-fontify-todo-headline nil
+  "Non-nil means change the face of a headline if it is marked as TODO.
+Normally, only the TODO/DONE keyword indicates the state of a headline.
+When this is non-nil, the headline after the keyword is set to the
+`org-headline-todo' as an additional indication."
+  :group 'org-appearance
+  :package-version '(Org . "9.4")
+  :type 'boolean)
+
 (defcustom org-fontify-done-headline nil
   "Non-nil means change the face of a headline if it is marked DONE.
 Normally, only the TODO/DONE keyword indicates the state of a headline.
@@ -5652,6 +5661,15 @@ needs to be inserted at a specific position in the font-lock sequence.")
 	   (list (format org-heading-keyword-regexp-format
 			 org-todo-regexp)
 		 '(2 (org-get-todo-face 2) t))
+	   ;; TODO
+	   (if org-fontify-todo-headline
+	       (list (format org-heading-keyword-regexp-format
+			     (concat
+			      "\\(?:"
+			      (mapconcat 'regexp-quote org-not-done-keywords "\\|")
+			      "\\)"))
+		     '(2 'org-headline-todo t))
+	     nil)
 	   ;; DONE
 	   (if org-fontify-done-headline
 	       (list (format org-heading-keyword-regexp-format
-- 
2.24.0


             reply	other threads:[~2019-12-01 20:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-01 20:27 Terje Larsen [this message]
2019-12-22 15:02 ` [PATCH] Add customization to fontify TODO headlines Nicolas Goaziou

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=871rtniyfk.fsf@gmail.com \
    --to=terlar@gmail.com \
    --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).