[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [agenda] Case-insensitive tag search

From: Carsten Dominik
Subject: Re: [O] [agenda] Case-insensitive tag search
Date: Tue, 11 Oct 2011 08:22:15 +0200

On 11.10.2011, at 02:56, Nick Dokos wrote:

> suvayu ali <address@hidden> wrote:
>> Hi Marcelo,
>> On Mon, Oct 10, 2011 at 10:54 PM, Marcelo de Moraes Serpa
>> <address@hidden> wrote:
>>> Would it be hard to add such feature, considering I'm just beginning with
>>> elisp? Might be a candidate for my first patch to orgmode :)
>> Since you mention lisp, I think you can have an easy solution with a
>> custom agenda command. As far as I can see there could be two
>> possibilities, bind `case-fold-search' to t or `downcase' your search
>> query before performing a regular tags search.
>> I haven't looked at any code before making these suggestions. So you
>> will have to figure out which, if any at all, is viable.
> My first thought was advising the function as above but it didn't work
> when I tried it, so I did look at the code: org-tags-view calls
> org-scan-tags which sets case-fold-search to nil unconditionally, hence
> the advice failure (I think). But I also tried to set it to t (in a git
> branch) and that too did not work for me - I gave up at that point
> (however, I didn't try very hard so it is quite conceivable that I
> misunderstood the code or did something wrong.)

Matching tags in the scanner is not using search (which would
be influenced by case-fold-search).  Instead, it uses
membership tests, which is case-insensitive.

Here is a patch which does make this match case-insensitive.
Changes at master
        Modified lisp/org.el
diff --git a/lisp/org.el b/lisp/org.el
index b26e1a3..083e7dd 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12656,7 +12656,9 @@ only lines with a TODO keyword are included in the 
                 ;; eval matcher only when the todo condition is OK
                 (and (or (not todo-only) (member todo org-not-done-keywords))
-                     (let ((case-fold-search t)) (eval matcher)))
+                     (let ((case-fold-search t)
+                           (tags-list (mapcar 'downcase tags-list)))
+                       (eval matcher)))
                 ;; Call the skipper, but return t if it does not skip,
                 ;; so that the `and' form continues evaluating


However, tags are treated case-sensitively also by the functions
setting tags. For example, if an entry has the tag :aa:, you
can still set a tag :Aa:. To be on the safe side, my suggestion
would be to apply a function to your files which would
downcase all the tags present in the buffer.

Marcelo, maybe this is a nice task to try your elisp on?
With perl, it would be a one-liner....

- Carsten

reply via email to

[Prev in Thread] Current Thread [Next in Thread]