emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Marcelo de Moraes Serpa <celoserpa@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [hack/extension] org-mode/emacs regexp
Date: Mon, 16 Nov 2009 13:45:27 -0600	[thread overview]
Message-ID: <1e5bcefd0911161145ubdb4cc6w3ea40bcfcdeeb225@mail.gmail.com> (raw)
In-Reply-To: <1e5bcefd0911161010w448c73d6yb2082b49348c4ea6@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 4132 bytes --]

Ok, I'm sorry, I actually had to research a little bit more before posting
:)

Well, what I need to know now is how to make the overlay work. The code to
match is working, but I'm receiving the following error:

Error during redisplay: (wrong-number-of-arguments match-beginning 0)

Here's the full code: http://pastie.org/701448

(Thanks to Tim O'Calaghan for the original contribution)

Marcelo.

Also, how can I debug it? I tried debug-on-entry but it is not working :S


On Mon, Nov 16, 2009 at 12:10 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

> Hello,
>
> I started writing an extension to org that actually applies a custom face
> to an item tagges as CATEGORY or PROJECT. The thing is I'm really having a
> hard time understanding the regexp. The code is adapted from the
> org-action-verb.el by Tim O'Calaghan, basically using the same structure
> since my elisp knowledge is very basic. I have managed to get it to work to
> a basic level, but it is applying the face to the whole tree instead of
> applying to only one item.
>
> (defface org-gtd-default-category-face
>   '((((class color) (background light)) (:foreground "purple" :bold t
> :underline t))
>     (((class color) (background dark)) (:foreground "purple" :bold t
> :underline t))
>     (t (:bold t :underline t)))
>   "Used by org-color-by-tag for items tagged with :CATEGORY:")
>
> (defface org-gtd-default-project-face
>   '((((class color) (background light)) (:foreground "purple" :bold t
> :underline t))
>     (((class color) (background dark)) (:foreground "purple" :bold t
> :underline t))
>     (t (:bold t :underline t)))
>   "Used by org-color-by-tag for items tagged with :PROJECT:")
>
> (defvar org-gtd-tags '("PROJECT" "CATEGORY"))
>
> (defun org-font-lock-add-tag-faces (limit)
>   "Add the faces to corresponding items depending on the TAG."
>   (let (rtn a)
>     ;; check variable is set, and buffer left to search
>     (when (and (not rtn) org-gtd-tags)
>       ;; for each todo/action verb set
>       (dolist (tag org-gtd-tags)
>         ;; build regexps
>         (let ((tag-keywords-regexp
>
>                        (regexp-opt (cdr tag) 'word)))
>
>           ;; while we can find a todo keyword
>           (while (re-search-forward ":PROJECT:" limit t)
>             ;; check for action verb
>
>
>                    ;; apply new overlay
>                   (let ((overlay (make-overlay (match-beginning 1)
> (match-end 1) nil t nil)))
>                     (overlay-put overlay 'face
> 'org-gtd-default-project-face)
>                     ;;(overlay-put overlay 'mouse-face mouse-face)
>                     (overlay-put overlay 'org-action-overlay t)
>                     (overlay-put overlay 'evaporate t)
>                     (overlay-put overlay 'help-echo "mouse-2: correct word
> at point")
>                     overlay)
>
>
>             ;; reset search point?
>             (backward-char 1)))))
>     rtn))
>
> (org-font-lock-add-tag-faces 10)
>
> (defun org-mode-color-by-tag-hook ()
>   "Initalise org-color-by-tag."
>   (interactive)
>   (font-lock-add-keywords nil '((org-font-lock-add-tag-faces)))
>   )
>
> ;; Turn on action verb font locking.
> (add-hook 'org-mode-hook 'org-mode-color-by-tag-hook)
>
> As you can see, I'm in the debug phase, and I'm not even using the list of
> strings (PROJECT CATEGORY) I've created. I'm just trying to search for
> occurrences of the PROJECT tag and trying to apply the face. I've removed
> the regexp string that Tim used, which were:
>
> "^\\*+[     ]+"
>
> Was used here:
>         (let ((todo-keywords-regexp
>                (concat "^\\*+[     ]+"
>                        (regexp-opt (car todo) 'words)))
>               (todo-action-verbs-regexp
>                (concat "[     ]+" (regexp-opt (cdr todo) 'words))))
>
>
> And:  "[     ]+\\(\\<\\w\\w+\\>\\)"
>
> Used in: (looking-at "[     ]+\\(\\<\\w\\w+\\>\\)")
>
> What I want to do is: Search for items tagged as PROJECT or CATEGORY and
> apply the corresponding face to them.
>
> If someone could explain me the role of  "[    ]", and w, I would be
> grateful :)
>
> Thanks,
>
> Marcelo.
>
>

[-- Attachment #1.2: Type: text/html, Size: 5021 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2009-11-16 19:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-16 18:10 [hack/extension] org-mode/emacs regexp Marcelo de Moraes Serpa
2009-11-16 19:45 ` Marcelo de Moraes Serpa [this message]
2009-11-17 11:49   ` Tim O'Callaghan

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=1e5bcefd0911161145ubdb4cc6w3ea40bcfcdeeb225@mail.gmail.com \
    --to=celoserpa@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).