emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Directly search for Headlines?
@ 2014-07-07 14:06 John Durden
  2014-07-07 15:19 ` Nick Dokos
  0 siblings, 1 reply; 10+ messages in thread
From: John Durden @ 2014-07-07 14:06 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Can you search directly for headlines in all agenda-files, with the name of the headline, not tags? If so, how? If not, wouldn't this be useful?

Thanks for answers

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

* Re: Directly search for Headlines?
  2014-07-07 14:06 Directly search for Headlines? John Durden
@ 2014-07-07 15:19 ` Nick Dokos
  2014-07-07 15:59   ` Ken Mankoff
  0 siblings, 1 reply; 10+ messages in thread
From: Nick Dokos @ 2014-07-07 15:19 UTC (permalink / raw)
  To: emacs-orgmode

John Durden <johndurden@yandex.com> writes:

> Hello,
>
> Can you search directly for headlines in all agenda-files, with the
> name of the headline, not tags? If so, how? If not, wouldn't this be
> useful?
>

Try `s' in the agenda perhaps?
---
Nick

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

* Re: Directly search for Headlines?
  2014-07-07 15:19 ` Nick Dokos
@ 2014-07-07 15:59   ` Ken Mankoff
  2014-07-07 17:54     ` Thorsten Jolitz
                       ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Ken Mankoff @ 2014-07-07 15:59 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode


On 2014-07-07 at 11:19, Nick Dokos wrote:
> John Durden <johndurden@yandex.com> writes:
>
>> Can you search directly for headlines in all agenda-files, with the
>> name of the headline, not tags? If so, how? If not, wouldn't this be
>> useful?
>>
>
> Try `s' in the agenda perhaps?

Yes this feature would be useful. 

"s" in agenda just saves all Org Buffers for me.

My work-around is to search for "* Foo", but this doesn't find headlines
with TODO items.

  -k.

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

* Re: Directly search for Headlines?
  2014-07-07 15:59   ` Ken Mankoff
@ 2014-07-07 17:54     ` Thorsten Jolitz
  2014-07-07 19:11     ` Nick Dokos
  2014-07-08 21:01     ` Samuel Wales
  2 siblings, 0 replies; 10+ messages in thread
From: Thorsten Jolitz @ 2014-07-07 17:54 UTC (permalink / raw)
  To: emacs-orgmode

Ken Mankoff <mankoff@gmail.com> writes:

> On 2014-07-07 at 11:19, Nick Dokos wrote:
>> John Durden <johndurden@yandex.com> writes:
>>
>>> Can you search directly for headlines in all agenda-files, with the
>>> name of the headline, not tags? If so, how? If not, wouldn't this be
>>> useful?
>>>
>>
>> Try `s' in the agenda perhaps?
>
> Yes this feature would be useful. 
>
> "s" in agenda just saves all Org Buffers for me.

for me too

> My work-around is to search for "* Foo", but this doesn't find headlines
> with TODO items.

Internally, the necessary functionality already exists:

,----[ C-h f org-map-entries RET ]
| org-map-entries is a compiled Lisp function in `org.el'.
| 
| (org-map-entries FUNC &optional MATCH SCOPE &rest SKIP)
| 
| Call FUNC at each headline selected by MATCH in SCOPE.
| 
| [...] 
| MATCH is a tags/property/todo match as it is used in the agenda tags view.
| Only headlines that are matched by this query will be considered during
| the iteration.  When MATCH is nil or t, all headlines will be
| visited by the iteration.
| 
| SCOPE determines the scope of this command.  It can be any of:
| 
| nil     The current buffer, respecting the restriction if any
| tree    The subtree started with the entry at point
| region  The entries within the active region, if any
| region-start-level
|         The entries within the active region, but only those at
|         the same level than the first one.
| file    The current buffer, without restriction
| file-with-archives
|         The current buffer, and any archives associated with it
| agenda  All agenda files
| agenda-with-archives
|         All agenda files with any archive files associated with them
| (file1 file2 ...)
|         If this is a list, all files in the list will be scanned [...]
`----

or

,----[ C-h f org-element-map RET ]
| org-element-map is a compiled Lisp function in `org-element.el'.
| 
| (org-element-map DATA TYPES FUN &optional INFO FIRST-MATCH
| NO-RECURSION WITH-AFFILIATED)
| 
| Map a function on selected elements or objects.
| 
| DATA is a parse tree, an element, an object, a string, or a list
| of such constructs.  TYPES is a symbol or list of symbols of
| elements or objects types (see `org-element-all-elements' and
| `org-element-all-objects' for a complete list of types).  FUN is
| the function called on the matching element or object.  It has to
| accept one argument: the element or object itself.
| [...]
`----

One could either use something like this

#+begin_src emacs-lisp
  (defun tj/match-true-headlines-1 ()
    (interactive)
    (org-element-map
        (org-element-parse-buffer 'headline) 'headline
      (lambda (--entry)
        (let ((true-headline (org-element-property :title --entry)))
          (when (string-match "world" true-headline)
            true-headline)))))
#+end_src

#+results:
: tj/match-true-headlines-1

or like this

#+begin_src emacs-lisp
  (defun tj/match-true-headlines-2 ()
    (interactive)
    (org-map-entries
     (lambda ()
       (when (looking-at org-complex-heading-regexp)
         (let ((true-headline (match-string 4)))
           (when (string-match "world" true-headline)
             (org-no-properties true-headline)))))))
#+end_src

#+results:
: tj/match-true-headlines-2

Lets try some test headlines after evaluating the above src_blocks.

* Hello world
** What a wonderful world
** Nice work if you can get it
*** Don't get around much anymore
*** World music

#+begin_src emacs-lisp :results table
(tj/match-true-headlines-1)
#+end_src

#+results:
| Hello world | What a wonderful world | World music |


#+begin_src emacs-lisp :results table
  (delq nil (tj/match-true-headlines-2))
#+end_src

#+results:
| Hello world | What a wonderful world | World music |

So both versions match the correct headlines in this
*outorg-edit-buffer* (where I write my message-mode email in full
org-mode). 

I don't know if this can be done with existing Org Agenda
functionality (as always, its quite likely...)

If not, to be useful this should be integrated in the Org Agenda
framework. 

-- 
cheers,
Thorsten

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

* Re: Directly search for Headlines?
  2014-07-07 15:59   ` Ken Mankoff
  2014-07-07 17:54     ` Thorsten Jolitz
@ 2014-07-07 19:11     ` Nick Dokos
  2014-07-07 19:58       ` Ken Mankoff
  2014-07-08 21:01     ` Samuel Wales
  2 siblings, 1 reply; 10+ messages in thread
From: Nick Dokos @ 2014-07-07 19:11 UTC (permalink / raw)
  To: emacs-orgmode

Ken Mankoff <mankoff@gmail.com> writes:

> On 2014-07-07 at 11:19, Nick Dokos wrote:
>> John Durden <johndurden@yandex.com> writes:
>>
>>> Can you search directly for headlines in all agenda-files, with the
>>> name of the headline, not tags? If so, how? If not, wouldn't this be
>>> useful?
>>>
>>
>> Try `s' in the agenda perhaps?
>
> Yes this feature would be useful. 
>
> "s" in agenda just saves all Org Buffers for me.
>

Sorry, I meant `s' in the agenda dispatcher:

       C-c a s

> My work-around is to search for "* Foo", but this doesn't find headlines
> with TODO items.
>
>   -k.

    C-c a S

perhaps?

Nick

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

* Re: Directly search for Headlines?
  2014-07-07 19:11     ` Nick Dokos
@ 2014-07-07 19:58       ` Ken Mankoff
  2014-07-07 21:24         ` Nick Dokos
  0 siblings, 1 reply; 10+ messages in thread
From: Ken Mankoff @ 2014-07-07 19:58 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode


On 2014-07-07 at 15:11, Nick Dokos wrote:
> Ken Mankoff <mankoff@gmail.com> writes:
>
>> On 2014-07-07 at 11:19, Nick Dokos wrote:
>>> John Durden <johndurden@yandex.com> writes:
>>>
>>>> Can you search directly for headlines in all agenda-files, with the
>>>> name of the headline, not tags? If so, how? If not, wouldn't this be
>>>> useful?
>>>>
>>>
>>> Try `s' in the agenda perhaps?
>
> Sorry, I meant `s' in the agenda dispatcher:
>
>     C-c a s
>     C-c a S
>

I use the key combos you suggest all the time, but the OP wanted to just
search HEADLINES. Maybe the above methods work if you use regex and
exploit the fact that all headlines have "*" characters in them, but
this use of regex seems a bit overly complex.

  -k.

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

* Re: Directly search for Headlines?
  2014-07-07 19:58       ` Ken Mankoff
@ 2014-07-07 21:24         ` Nick Dokos
  0 siblings, 0 replies; 10+ messages in thread
From: Nick Dokos @ 2014-07-07 21:24 UTC (permalink / raw)
  To: emacs-orgmode

Ken Mankoff <mankoff@gmail.com> writes:

> On 2014-07-07 at 15:11, Nick Dokos wrote:
>> Ken Mankoff <mankoff@gmail.com> writes:
>>
>>> On 2014-07-07 at 11:19, Nick Dokos wrote:
>>>> John Durden <johndurden@yandex.com> writes:
>>>>
>>>>> Can you search directly for headlines in all agenda-files, with the
>>>>> name of the headline, not tags? If so, how? If not, wouldn't this be
>>>>> useful?
>>>>>
>>>>
>>>> Try `s' in the agenda perhaps?
>>
>> Sorry, I meant `s' in the agenda dispatcher:
>>
>>     C-c a s
>>     C-c a S
>>
>
> I use the key combos you suggest all the time, but the OP wanted to just
> search HEADLINES. Maybe the above methods work if you use regex and
> exploit the fact that all headlines have "*" characters in them, but
> this use of regex seems a bit overly complex.
>

Yes, I understand that, but limiting the search space with C-c a s seems
to me to be a good solution for keyword searching. If there are too many
results, you can then do C-s of the same keyword in the resulting
results buffer and step exactly through the headlines that match.

It's not hard to write a more specialized tool either. I think an
application of org-map-entries could easily do what the OP wanted
(although the devil *will* be in the details). The question is whether
it's worth it, or whether the current tools adequately meet the need.

Nick

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

* Re: Directly search for Headlines?
  2014-07-07 15:59   ` Ken Mankoff
  2014-07-07 17:54     ` Thorsten Jolitz
  2014-07-07 19:11     ` Nick Dokos
@ 2014-07-08 21:01     ` Samuel Wales
  2014-07-08 21:31       ` Ken Mankoff
  2 siblings, 1 reply; 10+ messages in thread
From: Samuel Wales @ 2014-07-08 21:01 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: Nick Dokos, emacs-orgmode

On 7/7/14, Ken Mankoff <mankoff@gmail.com> wrote:
> "s" in agenda just saves all Org Buffers for me.

c-c a s

> My work-around is to search for "* Foo", but this doesn't find headlines
> with TODO items.

it should.

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

The disease DOES progress.  MANY people have died from it.  And
ANYBODY can get it.

Denmark: free Karina Hansen NOW.

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

* Re: Directly search for Headlines?
  2014-07-08 21:01     ` Samuel Wales
@ 2014-07-08 21:31       ` Ken Mankoff
  2014-07-28 17:56         ` Fabrice Niessen
  0 siblings, 1 reply; 10+ messages in thread
From: Ken Mankoff @ 2014-07-08 21:31 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Nick Dokos, emacs-orgmode


On 2014-07-08 at 17:01, Samuel Wales wrote:
> On 7/7/14, Ken Mankoff <mankoff@gmail.com> wrote:
>> "s" in agenda just saves all Org Buffers for me.
>
> c-c a s
>
>> My work-around is to search for "* Foo", but this doesn't find headlines
>> with TODO items.
>
> it should.

You're right. It does! Not sure why I thought it didn't. 

OP issue solved, I think, with this.

  -k.

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

* Re: Directly search for Headlines?
  2014-07-08 21:31       ` Ken Mankoff
@ 2014-07-28 17:56         ` Fabrice Niessen
  0 siblings, 0 replies; 10+ messages in thread
From: Fabrice Niessen @ 2014-07-28 17:56 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Ken Mankoff wrote:
> On 2014-07-08 at 17:01, Samuel Wales wrote:
>> On 7/7/14, Ken Mankoff <mankoff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>> "s" in agenda just saves all Org Buffers for me.
>>
>> c-c a s
>>
>>> My work-around is to search for "* Foo", but this doesn't find headlines
>>> with TODO items.
>>
>> it should.
>
> You're right. It does! Not sure why I thought it didn't. 
>
> OP issue solved, I think, with this.

More info on http://orgmode.org/worg/org-tutorials/advanced-searching.html
about the different syntax (*, !, :).

Fabrice Niessen

-- 
Fabrice Niessen
Leuven, Belgium
http://www.pirilampo.org/

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

end of thread, other threads:[~2014-07-28 17:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-07 14:06 Directly search for Headlines? John Durden
2014-07-07 15:19 ` Nick Dokos
2014-07-07 15:59   ` Ken Mankoff
2014-07-07 17:54     ` Thorsten Jolitz
2014-07-07 19:11     ` Nick Dokos
2014-07-07 19:58       ` Ken Mankoff
2014-07-07 21:24         ` Nick Dokos
2014-07-08 21:01     ` Samuel Wales
2014-07-08 21:31       ` Ken Mankoff
2014-07-28 17:56         ` Fabrice Niessen

Code repositories for project(s) associated with this 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).