emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Trying to use a custom face for highlighting tags used in agenda filtering
@ 2011-10-26 20:22 Sebastien Vauban
  2011-10-27 21:20 ` Sebastien Vauban
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastien Vauban @ 2011-10-26 20:22 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

I tried modifying the lines of defun org-agenda-set-mode-name, line 6764, so
that tags are highlighted in the mode-line.

#+begin_src emacs-lisp
	      (if (or org-agenda-filter (get 'org-agenda-filter
					     :preset-filter))
		  '(:eval (concat " {" (propertize (mapconcat
						    'identity
						    (append (get 'org-agenda-filter
								 :preset-filter)
							    org-agenda-filter) "")
						   'face 'compilation-warning
						   'help-echo "Tags used in filtering"
						   )
				  "}")
			  )
		"")
#+end_src

While my code seems correct, it is not applied -- or, maybe, the face is
overwritten by another one, in which case I don't know how to debug: I can't
do C-u C-x = on the mode-line...

Any idea?

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: Trying to use a custom face for highlighting tags used in agenda filtering
  2011-10-26 20:22 Trying to use a custom face for highlighting tags used in agenda filtering Sebastien Vauban
@ 2011-10-27 21:20 ` Sebastien Vauban
  2011-10-29 11:25   ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastien Vauban @ 2011-10-27 21:20 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

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

Hello,

Please find a (very useful ;-)) patch for highlighting (in the mode-line) the
tags which are used to filter the agenda.

I'd like even to be able to put in one color the "positive" tags and in
another the "negative" ones, but that's above my current knowledge of
text-properties...

Anyway, here is a usable first version -- where all tags are in the same
color, much more easily to spot (before you wonder why you have so few lines
in your agenda!).

Best regards,
  Seb

-- 
Sebastien Vauban

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Add-custom-face-for-highlighting-tags-used-in-agenda.patch --]
[-- Type: text/x-patch, Size: 2153 bytes --]

From 9492f3a5defeae992685d90e187ceb441c2ebea1 Mon Sep 17 00:00:00 2001
From: Sebastien Vauban <sva-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
Date: Thu, 27 Oct 2011 23:08:04 +0200
Subject: [PATCH 2/2] Add custom face for highlighting tags used in agenda
 filtering.

---
 lisp/org-agenda.el |   17 ++++++++++++-----
 lisp/org-faces.el  |    7 +++++++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 66686f9..fe26b11 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6761,13 +6761,20 @@ When called with a prefix argument, include all archive files as well."
 	       ((eq org-agenda-show-log 'clockcheck) " ClkCk")
 	       (org-agenda-show-log " Log")
 	       (t ""))
+	      ;; show tags used for filtering in a custom face
 	      (if (or org-agenda-filter (get 'org-agenda-filter
 					     :preset-filter))
-		  (concat " {" (mapconcat
-				'identity
-				(append (get 'org-agenda-filter
-					     :preset-filter)
-					org-agenda-filter) "") "}")
+		  '(:eval (propertize
+			   (concat " {"
+				   (mapconcat
+				    'identity
+				    (append
+				     (get 'org-agenda-filter :preset-filter)
+				     org-agenda-filter)
+				    "")
+				   "}")
+			   'face 'org-agenda-filter-tags
+			   'help-echo "Tags used in filtering"))
 		"")
 	      (if org-agenda-archives-mode
 		  (if (eq org-agenda-archives-mode t)
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index aac82c9..519c858 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -672,6 +672,13 @@ month and 365.24 days for a year)."
   "Face for showing the agenda restriction lock."
   :group 'org-faces)
 
+(defface org-agenda-filter-tags
+  (org-compatible-face nil
+    '((((background light)) (:foreground "orange"))
+      (((background dark))  (:foreground "orange"))))
+  "Face for showing the tags (in the mode-line) which are used in the agenda filtering."
+  :group 'org-faces)
+
 (defface org-time-grid ;; originally copied from font-lock-variable-name-face
   (org-compatible-face nil
     '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
-- 
1.7.5.1


[-- Attachment #3: ChangeLog --]
[-- Type: application/octet-stream, Size: 206 bytes --]

2011-10-27  Seb Vauban  <sva@mygooglest.com>

	* org-agenda.el (org-agenda-set-mode-name): Highlight tags
	used for filtering (shown in the mode-line).

	* org-faces.el: Add face `org-agenda-filter-tags'.


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

* Re: Trying to use a custom face for highlighting tags used in agenda filtering
  2011-10-27 21:20 ` Sebastien Vauban
@ 2011-10-29 11:25   ` Bastien
  2011-10-29 19:36     ` Sebastien Vauban
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2011-10-29 11:25 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

Hi Sébastien,

"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:

> Please find a (very useful ;-)) patch for highlighting (in the mode-line) the
> tags which are used to filter the agenda.

Applied thanks.

I've updated the patch using org-propertize instead of propertize 
and using a better default for the face :)

> I'd like even to be able to put in one color the "positive" tags and in
> another the "negative" ones, but that's above my current knowledge of
> text-properties...

Maybe you can start by replacing the 'identity function in the
(mapconcat ...) by some (lambda (f) (if ...)) to check whether 
each tag filter starts with a + or a -.  Just an idea.

> Anyway, here is a usable first version -- where all tags are in the same
> color, much more easily to spot (before you wonder why you have so few lines
> in your agenda!).

Yes, it might be useful to some people -- thanks for this!

-- 
 Bastien

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

* Re: Trying to use a custom face for highlighting tags used in agenda filtering
  2011-10-29 11:25   ` Bastien
@ 2011-10-29 19:36     ` Sebastien Vauban
  2011-10-29 23:39       ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastien Vauban @ 2011-10-29 19:36 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Bastien,

Bastien wrote:
> "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>
>> Please find a (very useful ;-)) patch for highlighting (in the mode-line)
>> the tags which are used to filter the agenda.
>
> Applied thanks.

Thanks.

> I've updated the patch using org-propertize instead of propertize

OK, for better XEmacs support, if I understand well.

> and using a better default for the face :)

Well, I wouldn't call org-default a better default, but that's fine with me. I
mean: if org-default is black for the majority of the people, they won't even
see that you can customize that aspect of the modeline (in a light scheme).
So, I prefer some color (I chose orange) that everybody can customize, and
that makes everybody be aware of the tags used for filtering (in this case).
But, as said, I don't mind the default: I'll customize it anyway for my own
usage.

>> I'd like even to be able to put in one color the "positive" tags and in
>> another the "negative" ones, but that's above my current knowledge of
>> text-properties...
>
> Maybe you can start by replacing the 'identity function in the (mapconcat
> ...) by some (lambda (f) (if ...)) to check whether each tag filter starts
> with a + or a -. Just an idea.

Just that I'm still to ignorant of the inner working of property list. But
it's nice to give me a hint. That could help me to quicklier come with a
working solution.

>> Anyway, here is a usable first version -- where all tags are in the same
>> color, much more easily to spot (before you wonder why you have so few
>> lines in your agenda!).
>
> Yes, it might be useful to some people -- thanks for this!

Glad if it's of use.

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: Trying to use a custom face for highlighting tags used in agenda filtering
  2011-10-29 19:36     ` Sebastien Vauban
@ 2011-10-29 23:39       ` Bastien
  2011-12-08 13:49         ` Sebastien Vauban
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2011-10-29 23:39 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

Hi Sébastien,

"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:

>> I've updated the patch using org-propertize instead of propertize
>
> OK, for better XEmacs support, if I understand well.

Yes.

>> and using a better default for the face :)
>
> Well, I wouldn't call org-default a better default, but that's fine with me. I
> mean: if org-default is black for the majority of the people, they won't even
> see that you can customize that aspect of the modeline (in a light
> scheme).

Well, org-default is *not* a good default, 'modeline is.  I've pushed a
fix for this.

> So, I prefer some color (I chose orange) that everybody can customize, and
> that makes everybody be aware of the tags used for filtering (in this case).
> But, as said, I don't mind the default: I'll customize it anyway for my own
> usage.

One advantage of making the use of a face visible is to let people 
know they can change it.  In this case, changing the weight or using 
a different color may be an option -- let's see if people come up 
with good ideas.

>>> I'd like even to be able to put in one color the "positive" tags and in
>>> another the "negative" ones, but that's above my current knowledge of
>>> text-properties...
>>
>> Maybe you can start by replacing the 'identity function in the (mapconcat
>> ...) by some (lambda (f) (if ...)) to check whether each tag filter starts
>> with a + or a -. Just an idea.
>
> Just that I'm still to ignorant of the inner working of property list. But
> it's nice to give me a hint. That could help me to quicklier come with a
> working solution.

Thanks for your time in digging into this!

Best,

-- 
 Bastien

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

* Re: Trying to use a custom face for highlighting tags used in agenda filtering
  2011-10-29 23:39       ` Bastien
@ 2011-12-08 13:49         ` Sebastien Vauban
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastien Vauban @ 2011-12-08 13:49 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Bastien,

Bastien wrote:
>>> using a better default for the face :)
>>
>> Well, I wouldn't call org-default a better default, but that's fine with
>> me. I mean: if org-default is black for the majority of the people, they
>> won't even see that you can customize that aspect of the modeline (in a
>> light scheme).
>
> Well, org-default is *not* a good default, 'modeline is. I've pushed a fix
> for this:
>
> (defface org-agenda-filter-tags
>   (org-compatible-face 'modeline
>     nil)
>   "Face for tag(s) in the mode-line when filtering the agenda."
>   :group 'org-faces)

AFAIK, `modeline' is the facename used in XEmacs. In GNU Emacs, it is
`mode-line'.

>> So, I prefer some color (I chose orange) that everybody can customize, and
>> that makes everybody be aware of the tags used for filtering (in this
>> case). But, as said, I don't mind the default: I'll customize it anyway for
>> my own usage.
>
> One advantage of making the use of a face visible is to let people know they
> can change it. In this case, changing the weight or using a different color
> may be an option -- let's see if people come up with good ideas.

Using `mode-line' as the default face for highlighting the tags is contrary to
my intended goal: the filters simply won't be different from any information
shown in the mode-line. Hence:

- there is no highlighting by default, and
- nobody even knows that it's customizable...

I think the best choice, if you want to use an already existing face, is then
to choose `mode-line-emphasis'. At least, that one is, by default, bold, so
that one sees something different without any specific customization.

What do you think?

Best regards,
  Seb

-- 
Sebastien Vauban

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

end of thread, other threads:[~2011-12-08 13:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-26 20:22 Trying to use a custom face for highlighting tags used in agenda filtering Sebastien Vauban
2011-10-27 21:20 ` Sebastien Vauban
2011-10-29 11:25   ` Bastien
2011-10-29 19:36     ` Sebastien Vauban
2011-10-29 23:39       ` Bastien
2011-12-08 13:49         ` Sebastien Vauban

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