emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Question about org-search-view and org-occur-in-agenda-files
@ 2011-07-23 17:36 suvayu ali
  2011-07-25 18:29 ` Darlan Cavalcante Moreira
  0 siblings, 1 reply; 7+ messages in thread
From: suvayu ali @ 2011-07-23 17:36 UTC (permalink / raw)
  To: org-mode mailing list

Hi Orgers,

I know that I can use `org-search-view' or `org-occur-in-agenda-files'
from the agenda to search for some string on all my agenda files. And I
can customise `org-agenda-text-search-extra-files' to include extra text
files.

These search functions are quite powerful in general, so I was wondering
if these functions can be used to do a search restricted to say a list
of files or to org files within a directory. If I could wrap these in my
own functions, even that would be amazingly helpful.

To illustrate a use case, I recently switched research projects[1]. I
keep all my files related to the OLDPROJ under ~/org/OLDPROJ/ and all my
files related to the NEWPROJ under ~/org/NEWPROJ/[2]. Now when I perform
a text search I want to include only the NEWPROJ along with my agenda
files (located in ~/org/). Now I would like to have an interface (either
through the agenda menu or through some interactively called function)
to perform a search _only_ on the OLDPROJ files when necessary. Is that
possible?

Any hints as to how I can achieve this would be amazingly helpful.
Thanks. :)


Footnotes:

[1] I am using the word project rather loosely to describe a
    super-project with several sub-projects which are rather significant
    by themselves.

[2] These project directories have their own structure based on
    sub-projects and other needs.

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: Question about org-search-view and org-occur-in-agenda-files
  2011-07-23 17:36 Question about org-search-view and org-occur-in-agenda-files suvayu ali
@ 2011-07-25 18:29 ` Darlan Cavalcante Moreira
  2011-07-25 20:07   ` suvayu ali
  0 siblings, 1 reply; 7+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-07-25 18:29 UTC (permalink / raw)
  To: suvayu ali; +Cc: org-mode mailing list


You can probably use custom agenda commands for this. See the documentation
for the org-agenda-custom-commands and the corresponding section in the
manual [1]. You can set the org-agenda-files and
org-agenda-text-search-extra-files to point to the old project for some
custom search.

For instance, I use
--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp
  (setq org-agenda-custom-commands
        (quote (
                ... Some custom commands
                ("N" . "Search in notes.org")
                ("Nw" search ""
                ((org-agenda-files '("~/org/notes.org"))
                 (org-agenda-text-search-extra-files nil)))
                ("Nt" tags ""
                ((org-agenda-files '("~/org/notes.org"))
                 (org-agenda-text-search-extra-files nil)))
                ... Some more custom commands
                )))
#+end_src
--8<---------------cut here---------------end--------------->8---

This allows-me to perform a search only in my org/notes.org file without
actually changing my org-agenda-files.

--
Darlan

[1] - http://orgmode.org/org.html#Custom-agenda-views


At Sat, 23 Jul 2011 19:36:16 +0200,
suvayu ali <fatkasuvayu+linux@gmail.com> wrote:
> 
> Hi Orgers,
> 
> I know that I can use `org-search-view' or `org-occur-in-agenda-files'
> from the agenda to search for some string on all my agenda files. And I
> can customise `org-agenda-text-search-extra-files' to include extra text
> files.
> 
> These search functions are quite powerful in general, so I was wondering
> if these functions can be used to do a search restricted to say a list
> of files or to org files within a directory. If I could wrap these in my
> own functions, even that would be amazingly helpful.
> 
> To illustrate a use case, I recently switched research projects[1]. I
> keep all my files related to the OLDPROJ under ~/org/OLDPROJ/ and all my
> files related to the NEWPROJ under ~/org/NEWPROJ/[2]. Now when I perform
> a text search I want to include only the NEWPROJ along with my agenda
> files (located in ~/org/). Now I would like to have an interface (either
> through the agenda menu or through some interactively called function)
> to perform a search _only_ on the OLDPROJ files when necessary. Is that
> possible?
> 
> Any hints as to how I can achieve this would be amazingly helpful.
> Thanks. :)
> 
> 
> Footnotes:
> 
> [1] I am using the word project rather loosely to describe a
>     super-project with several sub-projects which are rather significant
>     by themselves.
> 
> [2] These project directories have their own structure based on
>     sub-projects and other needs.
> 
> -- 
> Suvayu
> 
> Open source is the future. It sets us free.
> 

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

* Re: Question about org-search-view and org-occur-in-agenda-files
  2011-07-25 18:29 ` Darlan Cavalcante Moreira
@ 2011-07-25 20:07   ` suvayu ali
  2011-07-26  1:20     ` Bernt Hansen
  2011-07-26  3:09     ` Matt Lundin
  0 siblings, 2 replies; 7+ messages in thread
From: suvayu ali @ 2011-07-25 20:07 UTC (permalink / raw)
  To: Darlan Cavalcante Moreira; +Cc: org-mode mailing list

Hi Darlan,

On Mon, Jul 25, 2011 at 8:29 PM, Darlan Cavalcante Moreira
<darcamo@gmail.com> wrote:
> You can probably use custom agenda commands for this. See the documentation
> for the org-agenda-custom-commands and the corresponding section in the
> manual [1].

Custom agenda commands do not support prompting for search phrases.

> You can set the org-agenda-files and
> org-agenda-text-search-extra-files to point to the old project for
> some custom search.
>

However the above comment gave me an idea. I could use a custom function
to wrap  around the search  functions and use let  to bind the  value of
agenda-files and org-agenda-text-search-extra-files as needed.

Thank you very much!

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: Question about org-search-view and org-occur-in-agenda-files
  2011-07-25 20:07   ` suvayu ali
@ 2011-07-26  1:20     ` Bernt Hansen
  2011-07-26  2:04       ` suvayu ali
  2011-07-26  3:09     ` Matt Lundin
  1 sibling, 1 reply; 7+ messages in thread
From: Bernt Hansen @ 2011-07-26  1:20 UTC (permalink / raw)
  To: suvayu ali; +Cc: org-mode mailing list

suvayu ali <fatkasuvayu+linux@gmail.com> writes:

> Hi Darlan,
>
> On Mon, Jul 25, 2011 at 8:29 PM, Darlan Cavalcante Moreira
> <darcamo@gmail.com> wrote:
>> You can probably use custom agenda commands for this. See the documentation
>> for the org-agenda-custom-commands and the corresponding section in the
>> manual [1].
>
> Custom agenda commands do not support prompting for search phrases.
>
>> You can set the org-agenda-files and
>> org-agenda-text-search-extra-files to point to the old project for
>> some custom search.
>>

You can also restrict agenda to a single file with C-u C-c C-x <.
Subsequent agenda commands and searches will only use the current file
until you remove the restriction with C-c C-x >

-Bernt


>>
>
> However the above comment gave me an idea. I could use a custom function
> to wrap  around the search  functions and use let  to bind the  value of
> agenda-files and org-agenda-text-search-extra-files as needed.
>
> Thank you very much!

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

* Re: Question about org-search-view and org-occur-in-agenda-files
  2011-07-26  1:20     ` Bernt Hansen
@ 2011-07-26  2:04       ` suvayu ali
  0 siblings, 0 replies; 7+ messages in thread
From: suvayu ali @ 2011-07-26  2:04 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: org-mode mailing list

Hi Bernt,

On Tue, Jul 26, 2011 at 3:20 AM, Bernt Hansen <bernt@norang.ca> wrote:
>>> You can set the org-agenda-files and
>>> org-agenda-text-search-extra-files to point to the old project for
>>> some custom search.
>>>
>
> You can also restrict agenda to a single file with C-u C-c C-x <.
> Subsequent agenda commands and searches will only use the current file
> until you remove the restriction with C-c C-x >
>

My problem was I wanted to search a whole slew of files in a directory
tree. Also I was misreading some of the the org-agenda documentation.
After reading the article on custom agenda commands on Worg, many of my
misconceptions were resolved. Now I have written a function to find org
files recursively from a directory tree and I use this list to
selectively search project directories.

e.g.:

(setq org-agenda-custom-commands
      '(("W" "Search tutorials on Worg" search ""
	 ((org-agenda-files nil)
	  (org-agenda-text-search-extra-files
	   (find-org-file-recursively "~/org/Worg/org-tutorials"))))))

> -Bernt

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: Question about org-search-view and org-occur-in-agenda-files
  2011-07-25 20:07   ` suvayu ali
  2011-07-26  1:20     ` Bernt Hansen
@ 2011-07-26  3:09     ` Matt Lundin
  2011-07-26  9:50       ` suvayu ali
  1 sibling, 1 reply; 7+ messages in thread
From: Matt Lundin @ 2011-07-26  3:09 UTC (permalink / raw)
  To: suvayu ali; +Cc: org-mode mailing list

suvayu ali <fatkasuvayu+linux@gmail.com> writes:

> Hi Darlan,
>
> On Mon, Jul 25, 2011 at 8:29 PM, Darlan Cavalcante Moreira
> <darcamo@gmail.com> wrote:
>> You can probably use custom agenda commands for this. See the documentation
>> for the org-agenda-custom-commands and the corresponding section in the
>> manual [1].
>
> Custom agenda commands do not support prompting for search phrases.

The following custom agenda command offers a prompt:

--8<---------------cut here---------------start------------->8---
(org-add-agenda-custom-command
 '("x" "Search special files" search ""
   ((org-agenda-files '("~/special/")))))
--8<---------------cut here---------------end--------------->8---

Best,
Matt

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

* Re: Question about org-search-view and org-occur-in-agenda-files
  2011-07-26  3:09     ` Matt Lundin
@ 2011-07-26  9:50       ` suvayu ali
  0 siblings, 0 replies; 7+ messages in thread
From: suvayu ali @ 2011-07-26  9:50 UTC (permalink / raw)
  To: Matt Lundin; +Cc: org-mode mailing list

Hi Matt,

On Tue, Jul 26, 2011 at 5:09 AM, Matt Lundin <mdl@imapmail.org> wrote:
>> Custom agenda commands do not support prompting for search phrases.
>
> The following custom agenda command offers a prompt:
>
> --8<---------------cut here---------------start------------->8---
> (org-add-agenda-custom-command
>  '("x" "Search special files" search ""
>   ((org-agenda-files '("~/special/")))))
> --8<---------------cut here---------------end--------------->8---
>

Yes, that was one of my misconceptions from my reading of the
org-agenda-custom-commands docs. The docs say:

[...]

match    What to search for:
          - a single keyword for TODO keyword searches
          - a tags match expression for tags searches
          - a word search expression for text searches.
          - a regular expression for occur searches
          For all other commands, this should be the empty string.

And the following example is given,

       (search "match" settings files)

I erroneously assumed the string cannot be an empty string until I read
the article on Worg. I also realised I can use let to set any variable
to whatever I need and wrap around any of the search functions. I can
then have prompts for any kind of search with these. Thanks everyone for
pointing me in the right direction. :)

> Best,
> Matt

Thanks,

-- 
Suvayu

Open source is the future. It sets us free.

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

end of thread, other threads:[~2011-07-26  9:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-23 17:36 Question about org-search-view and org-occur-in-agenda-files suvayu ali
2011-07-25 18:29 ` Darlan Cavalcante Moreira
2011-07-25 20:07   ` suvayu ali
2011-07-26  1:20     ` Bernt Hansen
2011-07-26  2:04       ` suvayu ali
2011-07-26  3:09     ` Matt Lundin
2011-07-26  9:50       ` suvayu ali

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