emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: nicholas.dokos@hp.com
Cc: Org Mode <emacs-orgmode@gnu.org>,
	Marcelo de Moraes Serpa <celoserpa@gmail.com>
Subject: Re: [agenda] Case-insensitive tag search
Date: Tue, 11 Oct 2011 08:22:15 +0200	[thread overview]
Message-ID: <7DC4ED7B-7E74-48DD-B174-80F5AA62D812@gmail.com> (raw)
In-Reply-To: <4619.1318294561@alphaville.dokosmarshall.org>


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

> suvayu ali <fatkasuvayu+linux@gmail.com> wrote:
> 
>> Hi Marcelo,
>> 
>> On Mon, Oct 10, 2011 at 10:54 PM, Marcelo de Moraes Serpa
>> <celoserpa@gmail.com> 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 output."
 
 		 ;; 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	other threads:[~2011-10-11  6:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-09  2:25 [agenda] Case-insensitive tag search Marcelo de Moraes Serpa
2011-10-10 15:48 ` Marcelo de Moraes Serpa
2011-10-10 19:16   ` Carsten Dominik
2011-10-10 20:54     ` Marcelo de Moraes Serpa
2011-10-10 22:20       ` suvayu ali
2011-10-11  0:42         ` Marcelo de Moraes Serpa
2011-10-11  0:56         ` Nick Dokos
2011-10-11  6:22           ` Carsten Dominik [this message]
2011-10-11  7:39             ` Christian Moe

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=7DC4ED7B-7E74-48DD-B174-80F5AA62D812@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=celoserpa@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=nicholas.dokos@hp.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).