emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add customization to fontify TODO headlines
@ 2019-12-01 20:27 Terje Larsen
  2019-12-22 15:02 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Terje Larsen @ 2019-12-01 20:27 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Add customization to fontify TODO headlines
  2019-12-01 20:27 [PATCH] Add customization to fontify TODO headlines Terje Larsen
@ 2019-12-22 15:02 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2019-12-22 15:02 UTC (permalink / raw)
  To: Terje Larsen; +Cc: emacs-orgmode

Hello,

Terje Larsen <terlar@gmail.com> writes:

> 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)).

Applied. Thank you.

I added a TINYCHANGE cookie at the end of the commit message since
I don't know if signed FSF papers already. If you did, please let me
know.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-22 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-01 20:27 [PATCH] Add customization to fontify TODO headlines Terje Larsen
2019-12-22 15:02 ` Nicolas Goaziou

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).