emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: "Sébastien Vauban" <wxhgmqzgwmuf@spammotel.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Re: Agenda view > Face for deadlines > PATCH
Date: Fri, 21 May 2010 16:37:40 +0200	[thread overview]
Message-ID: <8E1C97F0-8A90-4C39-A0A5-A2146E875795@gmail.com> (raw)
In-Reply-To: <877hmxaedn.fsf@mundaneum.com>


On May 21, 2010, at 9:43 AM, Sébastien Vauban wrote:

> Hi all,
>
> Sébastien Vauban wrote:
>> Sébastien Vauban wrote:
>>> In the same kind of thought, trying to enhance the way we (or I)  
>>> visualize
>>> tasks in the agenda, I have chosen some sort of "inverse video"  
>>> face for
>>> deadlines.
>>>
>>> (my-org-deadline-yesterday ((t (:foreground "white" :background  
>>> "#D80000" :weight bold))))
>>> (my-org-deadline-today ((t (:foreground "white" :background  
>>> "#E9A36A" :weight bold))))
>>> (my-org-deadline-tomorrow ((t (:foreground "black" :background  
>>> "#B4F1B3" :weight bold))))
>>> (my-org-deadline-later ((t (:foreground "black" :background  
>>> "#AACAFC"))))
>>>
>>> with the following code in my .emacs file:
>>>
>>> ;; faces for showing deadlines in the agenda
>>> (setq org-agenda-deadline-faces
>>>      '((1.01 . my-org-deadline-yesterday)
>>>        (0.99 . my-org-deadline-today)
>>>        (0.49 . my-org-deadline-tomorrow)
>>>        (0.00 . my-org-deadline-later)))
>>>
>>> The result is the following:
>>>
>>> Week-agenda (W20-W21):
>>> 2010-05-18 Tue  
>>> _________________________________________________________________
>>>  Personal:   17:15-17:20  
>>> Sarah!                                 :home::errands:
>>>  refile:     Sched. 2x:  TODO [#A] Update reservations  
>>> Scorpios       :refile::
>>> x Family: xxx In  -1 d.:  TODO [#A] Photos-reportage Andre  
>>> xxxx :home::computer:
>>>
>>> where `xxx' is just some textual way to represent background color.
>>>
>>> For the sake of clarity, I'd like the first 2 characters (in front  
>>> of
>>> `Family', in my example) not to be "impacted" by that face.  
>>> Otherwise, when
>>> in inverse video, they obfuscate the view of the day separators  
>>> and of the
>>> deadline lines.
>>
>> I was so disturbed by this, and have always wanted to become (and  
>> still
>> wants) enlightened in Emacs Lisp and in Org's code that I finally  
>> took the
>> time to try and understand how all this works.
>>
>> Not easy for me, I must admit. Cannot say I can follow the code,  
>> either,
>> because of lack of knowledge, on ELisp and on how to trace through  
>> the code.
>>
>> Though, I've been able to answer my own demand, by adding a  
>> function (code
>> stolen from `org-compat.el'):
>>
>> (defun org-add-props-from-2 (string plist &rest props)
>>  "Add text properties to string, from position 2 to end.
>> PLIST may be a list of properties, PROPS are individual properties  
>> and values
>> that will be added to PLIST.  Returns the string that was modified."
>>  (add-text-properties
>>   2 (length string) (if props (append plist props) plist) string)
>>  string)
>>
>> and changing one line of `org-agenda.el' (L4619, function
>> `org-agenda-get-deadlines'):
>>
>> 		(org-add-props txt props
>>
>> to
>>
>> 		(org-add-props-from-2 txt props
>>
>> Maybe that can be factored (much, much) more smartly?
>>
>> Can this be patched against the source code?
>
> After applying my patch, and playing a bit more with the results, I  
> observed
> that entering RET on such lines (where the 2 first characters are not
> highlighted anymore) does not work anymore: "command not allowed on  
> this
> line".
>
> Is there someone more knowledgeable than I am that could help?

`props' contains a text property with the marker that points to the  
origin of this entry.  Org tries to find this property at the  
beginning of the line and does not find it.

You would have to apply all properties to the full line, then remove  
the face property from the first two characters.

However, I am not sure if this will work, because when one of these  
lines changes, Org might spread the text properties again over the  
full line.  But maybe it will be OK, try it out.

- Carsten

  reply	other threads:[~2010-05-21 14:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-13  8:41 Agenda view > Day separator Sébastien Vauban
2010-05-13 15:06 ` Eric S Fraga
2010-05-13 18:27 ` Carsten Dominik
2010-05-13 19:34   ` Eric S Fraga
2010-05-17 11:23     ` Sébastien Vauban
2010-05-17 20:51       ` Markus Heller
2010-05-17 21:02         ` Nick Dokos
2010-05-17 21:14           ` Markus Heller
2010-05-18  7:39             ` Sébastien Vauban
2010-05-18  8:33               ` Štěpán Němec
2010-05-18 11:17                 ` Sébastien Vauban
2010-05-18 12:30                   ` Štěpán Němec
2010-05-18 12:06         ` J. David Boyd
2010-05-18  8:02 ` Agenda view > Face for deadlines Sébastien Vauban
2010-05-19 21:53   ` Agenda view > Face for deadlines > PATCH Sébastien Vauban
2010-05-21  7:43     ` Sébastien Vauban
2010-05-21 14:37       ` Carsten Dominik [this message]
2010-07-12 21:02         ` Sébastien Vauban
2010-08-12  8:34           ` Sébastien Vauban
2010-08-12 14:26             ` Bastien
2010-08-13 10:13               ` Sébastien Vauban
2010-08-16 19:51                 ` Bastien

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=8E1C97F0-8A90-4C39-A0A5-A2146E875795@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=wxhgmqzgwmuf@spammotel.com \
    /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).