emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* A simple way to search only headlines
@ 2013-06-01 16:35 Xebar Saram
  2013-06-01 20:10 ` Tassilo Horn
  0 siblings, 1 reply; 19+ messages in thread
From: Xebar Saram @ 2013-06-01 16:35 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 190 bytes --]

Hi guys

i was wondering if anyone knew of a way to search for text only in
headlines and not the whole document? if not is it something one can put a
feature request for?

kind regards

z.

[-- Attachment #2: Type: text/html, Size: 314 bytes --]

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

* Re: A simple way to search only headlines
  2013-06-01 16:35 A simple way to search only headlines Xebar Saram
@ 2013-06-01 20:10 ` Tassilo Horn
  2013-06-03  7:48   ` Sebastien Vauban
  0 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2013-06-01 20:10 UTC (permalink / raw)
  To: emacs-orgmode

Xebar Saram <zeltakc@gmail.com> writes:

> i was wondering if anyone knew of a way to search for text only in
> headlines and not the whole document? if not is it something one can
> put a feature request for?

Use regular expression search or isearch.  The latter would be:

  C-u C-s \*+.*<your-search-prase>

Bye,
Tassilo

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

* Re: A simple way to search only headlines
  2013-06-01 20:10 ` Tassilo Horn
@ 2013-06-03  7:48   ` Sebastien Vauban
  2013-06-03 12:16     ` Xebar Saram
  0 siblings, 1 reply; 19+ messages in thread
From: Sebastien Vauban @ 2013-06-03  7:48 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Tassilo Horn wrote:
> Xebar Saram <zeltakc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
>> i was wondering if anyone knew of a way to search for text only in
>> headlines and not the whole document? if not is it something one can
>> put a feature request for?
>
> Use regular expression search or isearch.  The latter would be:
>
>   C-u C-s \*+.*<your-search-prase>

Or, for a "pure" Org solution:

  C-c a < s *salsa dance

searches for terms appearing only *in the headline* (including tags).

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: A simple way to search only headlines
  2013-06-03  7:48   ` Sebastien Vauban
@ 2013-06-03 12:16     ` Xebar Saram
  2013-06-04  7:18       ` Thorsten Jolitz
  2013-06-04  7:50       ` Sebastien Vauban
  0 siblings, 2 replies; 19+ messages in thread
From: Xebar Saram @ 2013-06-03 12:16 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: org mode

[-- Attachment #1: Type: text/plain, Size: 778 bytes --]

Thx Seb and Tassilo

That's great ,i appreciate it!

Seb, is there a way to quick bind a key to the above series of commands?

best

Z


On Mon, Jun 3, 2013 at 3:48 AM, Sebastien Vauban <sva-news@mygooglest.com>wrote:

> Tassilo Horn wrote:
> > Xebar Saram <zeltakc@gmail.com> writes:
> >
> >> i was wondering if anyone knew of a way to search for text only in
> >> headlines and not the whole document? if not is it something one can
> >> put a feature request for?
> >
> > Use regular expression search or isearch.  The latter would be:
> >
> >   C-u C-s \*+.*<your-search-prase>
>
> Or, for a "pure" Org solution:
>
>   C-c a < s *salsa dance
>
> searches for terms appearing only *in the headline* (including tags).
>
> Best regards,
>   Seb
>
> --
> Sebastien Vauban
>
>
>

[-- Attachment #2: Type: text/html, Size: 1620 bytes --]

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

* Re: A simple way to search only headlines
  2013-06-03 12:16     ` Xebar Saram
@ 2013-06-04  7:18       ` Thorsten Jolitz
  2013-06-04  7:50       ` Sebastien Vauban
  1 sibling, 0 replies; 19+ messages in thread
From: Thorsten Jolitz @ 2013-06-04  7:18 UTC (permalink / raw)
  To: emacs-orgmode

Xebar Saram <zeltakc@gmail.com> writes:

> Thx Seb and Tassilo
>
> That's great ,i appreciate it!
>
> Seb, is there a way to quick bind a key to the above series of commands?

Just to add another method to search only headlines: use navi-mode.el

,-----------------------------
| https://github.com/tj64/navi
`-----------------------------

There is a tutorial on Worg:

,-----------------------------------------------------------
| http://orgmode.org/worg/org-tutorials/org-outside-org.html
`-----------------------------------------------------------

Using the 'org-outside-org.org' file of this tutorial as an example, if
you do (after installation of course)

,-------------------------
| (navi-search-and-switch)
| It is bound to M-s n.
`-------------------------

on this file, a (Occur like) *Navi* buffer pops up showing you the first
level headlines:

,----------------------------------------------------
| 3 matches for "^\* " in buffer: org-outside-org.org
|      15:* Introduction
|      46:* Org-mode everywhere
|     926:* Screencasts
`----------------------------------------------------

Typing '4' in the *Navi* buffer shows you the headlines up to level 4:

,--------------------------------------------------------------
| 30 matches for "^\*\*?\*?\*? " in buffer: org-outside-org.org
|      15:* Introduction
|      46:* Org-mode everywhere
|      50:** File Structuring
|      54:*** Orgstruct
|      94:*** Outline with Outshine
|      99:**** History and Credits
|     129:**** Installation
|     190:**** Outshine's fundamental idea
|     234:**** Fontification, Navigation and Structure Editing
|     285:** Subtree and Comment Editing
|     289:*** Introduction
|     308:*** Outorg
|     313:**** Introduction and Installation
|     337:**** Usage
|     392:**** Outorg vs Poporg
|     419:*** Poporg
|     428:**** Introduction
|     452:**** Installation
|     480:**** Usage
|     523:**** Known bugs
|     559:**** Caveats
|     590:**** History
|     614:**** Other tools
|     644:**** Python
|     711:** Remote Buffer Control
|     751:*** Navi-mode
|     756:**** About navi-mode
|     774:**** Installation
|     795:**** Usage
|     926:* Screencasts
`--------------------------------------------------------------

Since these headlines are the result of grep searches, they are *not*
folded outline (Org-mode) subtrees but just single lines of text, so you
can easily search them with the basic Emacs search commands (C-s and C-r
e.g.).

Of course you can do much more things in addition to searching
headlines. Just to give you two examples:

1. type 'E' in the *Navi* buffer and the buffer is put in *Navi-Edit*
mode, i.e.you can edit the headline in the *Navi* buffer and all edits
are immediately applied to the associated Org-mode file. This is perfect
for runnung Emacs keyboard macros only on the headlines of an Org-mode
(or outshine) buffer. Type 'C-c C-c' to go back to read-only *Navi*
mode.

2. with point on a headline in the *Navi* buffer, type 'e' and the
subtree at point will be offered for editing in a temporary Org-mode
buffer. This makes no sense for an .org file, of course, but is great
when you structure your source code files (e.g. Emacs Lisp files) with
headlines and use outshine.el, because then you can write all comment
sections in Org-mode instead of as outcommented text in a source code
buffer.

--
cheers,
Thorsten

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

* Re: A simple way to search only headlines
  2013-06-03 12:16     ` Xebar Saram
  2013-06-04  7:18       ` Thorsten Jolitz
@ 2013-06-04  7:50       ` Sebastien Vauban
  2013-06-07 20:31         ` Xebar Saram
  1 sibling, 1 reply; 19+ messages in thread
From: Sebastien Vauban @ 2013-06-04  7:50 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello Xebar,

>> Or, for a "pure" Org solution:
>>
>>   C-c a < s *salsa dance
>>
>> searches for terms appearing only *in the headline* (including tags).
>
> That's great ,i appreciate it!
>
> Seb, is there a way to quick bind a key to the above series of commands?

The programming equivalent to C-c a s is:

    (org-agenda nil "s")

That's what you'd have to bind to a key (using a "lambda" function).

What you want is the restriction to the current buffer as well. You should
update the above, looking at the doc of `org-agenda' (sorry, no time now to do
it).

BTW, how to find that you have to bind `org-agenda'?  Simply `C-h k', followed
by the key binding for which you want to know more (here, `C-c a'), such as:
which function does it call?

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: A simple way to search only headlines
  2013-06-04  7:50       ` Sebastien Vauban
@ 2013-06-07 20:31         ` Xebar Saram
  2013-06-07 21:50           ` Richard Lawrence
  0 siblings, 1 reply; 19+ messages in thread
From: Xebar Saram @ 2013-06-07 20:31 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: org mode

[-- Attachment #1: Type: text/plain, Size: 1274 bytes --]

Thank you both Thorsten and Seb, i really appreciate the help!

Seb, you wrote: The programming equivalent to C-c a s is:

    (org-agenda nil "s")

That's what you'd have to bind to a key (using a "lambda" function).

im a complete neewb and dont really have any idea on how to do the above,
can you show me an example?

Best

Z


On Tue, Jun 4, 2013 at 3:50 AM, Sebastien Vauban <sva-news@mygooglest.com>wrote:

> Hello Xebar,
>
> >> Or, for a "pure" Org solution:
> >>
> >>   C-c a < s *salsa dance
> >>
> >> searches for terms appearing only *in the headline* (including tags).
> >
> > That's great ,i appreciate it!
> >
> > Seb, is there a way to quick bind a key to the above series of commands?
>
> The programming equivalent to C-c a s is:
>
>     (org-agenda nil "s")
>
> That's what you'd have to bind to a key (using a "lambda" function).
>
> What you want is the restriction to the current buffer as well. You should
> update the above, looking at the doc of `org-agenda' (sorry, no time now
> to do
> it).
>
> BTW, how to find that you have to bind `org-agenda'?  Simply `C-h k',
> followed
> by the key binding for which you want to know more (here, `C-c a'), such
> as:
> which function does it call?
>
> Best regards,
>   Seb
>
> --
> Sebastien Vauban
>
>
>

[-- Attachment #2: Type: text/html, Size: 3197 bytes --]

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

* Re: A simple way to search only headlines
  2013-06-07 20:31         ` Xebar Saram
@ 2013-06-07 21:50           ` Richard Lawrence
  2013-06-08  0:05             ` Xebar Saram
  2013-06-08  5:25             ` Nick Dokos
  0 siblings, 2 replies; 19+ messages in thread
From: Richard Lawrence @ 2013-06-07 21:50 UTC (permalink / raw)
  To: emacs-orgmode

Xebar Saram <zeltakc@gmail.com> writes:

> Thank you both Thorsten and Seb, i really appreciate the help!
>
> Seb, you wrote: The programming equivalent to C-c a s is:
>
>     (org-agenda nil "s")
>
> That's what you'd have to bind to a key (using a "lambda" function).
>
> im a complete neewb and dont really have any idea on how to do the above,
> can you show me an example?

I think you're looking for something like:

(define-key org-mode-map (kbd "C-M-h") (lambda () (org-agenda nil "s" "<")))

You could put a line like that in your .emacs.  Here's what it does:
#+BEGIN_SRC emacs-lisp
(define-key    ;; insert a new keybinding
  org-mode-map ;; into the Org mode map (so this won't affect bindings in non-Org buffers)

  ;; This is the key we're binding: C-M-h, for "headline" search
  ;; You can use whatever key you like, but you might want to check first that it isn't
  ;; already bound to something else (e.g., via C-h k from an Org buffer).
  ;; The kbd macro converts a string representation to the appropriate key code.
  (kbd "C-M-h")
  
  ;; This is the function to run when the key is pressed.  The lambda
  ;; form creates an anonymous function which calls org-agenda with
  ;; the "s" argument and a restriction to current buffer.
  (lambda () (org-agenda nil "s" "<")))
#+END_SRC

Best,
Richard

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

* Re: A simple way to search only headlines
  2013-06-07 21:50           ` Richard Lawrence
@ 2013-06-08  0:05             ` Xebar Saram
  2013-06-08  0:34               ` Richard Lawrence
  2013-06-08  5:25             ` Nick Dokos
  1 sibling, 1 reply; 19+ messages in thread
From: Xebar Saram @ 2013-06-08  0:05 UTC (permalink / raw)
  To: Richard Lawrence; +Cc: org mode

[-- Attachment #1: Type: text/plain, Size: 1730 bytes --]

Hi Richard

Fantastic, thx alot for the code snippet and detailed explanation, it
really helps to understand what goes on. unfortunately i get an error:

Wrong type argument: commandp, (lambda nil (org-agenda nil "s" "<"))

any clue?

best

Z.


On Fri, Jun 7, 2013 at 5:50 PM, Richard Lawrence <
richard.lawrence@berkeley.edu> wrote:

> Xebar Saram <zeltakc@gmail.com> writes:
>
> > Thank you both Thorsten and Seb, i really appreciate the help!
> >
> > Seb, you wrote: The programming equivalent to C-c a s is:
> >
> >     (org-agenda nil "s")
> >
> > That's what you'd have to bind to a key (using a "lambda" function).
> >
> > im a complete neewb and dont really have any idea on how to do the above,
> > can you show me an example?
>
> I think you're looking for something like:
>
> (define-key org-mode-map (kbd "C-M-h") (lambda () (org-agenda nil "s"
> "<")))
>
> You could put a line like that in your .emacs.  Here's what it does:
> #+BEGIN_SRC emacs-lisp
> (define-key    ;; insert a new keybinding
>   org-mode-map ;; into the Org mode map (so this won't affect bindings in
> non-Org buffers)
>
>   ;; This is the key we're binding: C-M-h, for "headline" search
>   ;; You can use whatever key you like, but you might want to check first
> that it isn't
>   ;; already bound to something else (e.g., via C-h k from an Org buffer).
>   ;; The kbd macro converts a string representation to the appropriate key
> code.
>   (kbd "C-M-h")
>
>   ;; This is the function to run when the key is pressed.  The lambda
>   ;; form creates an anonymous function which calls org-agenda with
>   ;; the "s" argument and a restriction to current buffer.
>   (lambda () (org-agenda nil "s" "<")))
> #+END_SRC
>
> Best,
> Richard
>
>
>

[-- Attachment #2: Type: text/html, Size: 2587 bytes --]

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

* Re: A simple way to search only headlines
  2013-06-08  0:05             ` Xebar Saram
@ 2013-06-08  0:34               ` Richard Lawrence
  0 siblings, 0 replies; 19+ messages in thread
From: Richard Lawrence @ 2013-06-08  0:34 UTC (permalink / raw)
  To: emacs-orgmode

Xebar Saram <zeltakc@gmail.com> writes:

> Hi Richard
>
> Fantastic, thx alot for the code snippet and detailed explanation, it
> really helps to understand what goes on. unfortunately i get an error:
>
> Wrong type argument: commandp, (lambda nil (org-agenda nil "s" "<"))

Ah, sorry about that, should have tested my code before I sent it!

The problem is that you have to give a /command/ to define-key (i.e., a
function with a call to `interactive' in its definition).

This should do it:

(define-key org-mode-map (kbd "C-M-h") (lambda () (interactive) (org-agenda nil "s" "<")))

Best,
Richard

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

* Re: A simple way to search only headlines
  2013-06-07 21:50           ` Richard Lawrence
  2013-06-08  0:05             ` Xebar Saram
@ 2013-06-08  5:25             ` Nick Dokos
  2013-06-10  7:34               ` Sebastien Vauban
  1 sibling, 1 reply; 19+ messages in thread
From: Nick Dokos @ 2013-06-08  5:25 UTC (permalink / raw)
  To: emacs-orgmode

Richard Lawrence <richard.lawrence@berkeley.edu> writes:

> Xebar Saram <zeltakc@gmail.com> writes:
>
>> Thank you both Thorsten and Seb, i really appreciate the help!
>>
>> Seb, you wrote: The programming equivalent to C-c a s is:
>>
>>     (org-agenda nil "s")
>>
>> That's what you'd have to bind to a key (using a "lambda" function).
>>
>> im a complete neewb and dont really have any idea on how to do the above,
>> can you show me an example?
>
> I think you're looking for something like:
>
> (define-key org-mode-map (kbd "C-M-h") (lambda () (org-agenda nil "s" "<")))
>
> You could put a line like that in your .emacs.

The OP probably wants this in the global keymap, rather than in 
the org-mode-map: just like the agenda dispatcher C-c a, this
functionality is useful outside an org file.

--8<---------------cut here---------------start------------->8---
(global-set-key (kbd "C-M-h") (lambda () (interactive) (org-agenda nil "s" "<")))
--8<---------------cut here---------------end--------------->8---

Also C-M-h runs mark-defun by default and it's not nice to usurp global
keys like that. I would suggest C-c s instead.

Using the global keymap also simplifies the initialization. In order to
put the key definition into the org-mode-map, the map has to be defined
already, i.e the define-key has to be done *after* org is loaded; so you
can't put it in an arbitrary place in .emacs. The safest way is to put
it in a hook (a list of no-argument functions that are executed after
the mode is set on a file):

(setq org-mode-hook
      '(
        (function (lambda ()
		   (define-key org-mode-map 
		     (kbd "C-M-h") (lambda ()
				     (interactive)
				     (org-agenda nil "s" "<")))))
        ; maybe followed by more functions in the list
       ) ; this paren end the list
      )  ; this paren closes the setq


Putting it in the global map instead bypasses this problem completely
since the global map is defined before .emacs is loaded. That's not to
say that the global map is always the right place to define a key: on
the contrary, most of the time it isn't. But in this case it is the
right place *and* putting the key definition there is simpler.

-- 
Nick

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

* Re: A simple way to search only headlines
  2013-06-08  5:25             ` Nick Dokos
@ 2013-06-10  7:34               ` Sebastien Vauban
  2013-06-10 13:06                 ` Nick Dokos
  0 siblings, 1 reply; 19+ messages in thread
From: Sebastien Vauban @ 2013-06-10  7:34 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Nick,

Nick Dokos wrote:
> The OP probably wants this in the global keymap, rather than in the
> org-mode-map: just like the agenda dispatcher C-c a, this functionality is
> useful outside an org file.
>
> (global-set-key (kbd "C-M-h") (lambda () (interactive) (org-agenda nil "s" "<")))

Not sure to understand when this functionality would be useful outside of Org.
Can you explain?

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: A simple way to search only headlines
  2013-06-10  7:34               ` Sebastien Vauban
@ 2013-06-10 13:06                 ` Nick Dokos
  2013-06-10 15:04                   ` Sebastien Vauban
  0 siblings, 1 reply; 19+ messages in thread
From: Nick Dokos @ 2013-06-10 13:06 UTC (permalink / raw)
  To: emacs-orgmode

"Sebastien Vauban" <sva-news@mygooglest.com>
writes:

> Hi Nick,
>
> Nick Dokos wrote:
>> The OP probably wants this in the global keymap, rather than in the
>> org-mode-map: just like the agenda dispatcher C-c a, this functionality is
>> useful outside an org file.
>>
>> (global-set-key (kbd "C-M-h") (lambda () (interactive) (org-agenda nil "s" "<")))
>
> Not sure to understand when this functionality would be useful outside of Org.
> Can you explain?
>

I meant "org buffer": you might want to issue the command from an
arbitrary buffer, not just an org mode buffer, so the key should be
defined globally.

-- 
Nick

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

* Re: A simple way to search only headlines
  2013-06-10 13:06                 ` Nick Dokos
@ 2013-06-10 15:04                   ` Sebastien Vauban
  2013-06-11  4:31                     ` Nick Dokos
  0 siblings, 1 reply; 19+ messages in thread
From: Sebastien Vauban @ 2013-06-10 15:04 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Nick,

Nick Dokos wrote:
> "Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org> writes:
>> Nick Dokos wrote:
>>> The OP probably wants this in the global keymap, rather than in the
>>> org-mode-map: just like the agenda dispatcher C-c a, this functionality is
>>> useful outside an org file.
>>>
>>> (global-set-key (kbd "C-M-h") (lambda () (interactive) (org-agenda nil "s" "<")))
>>
>> Not sure to understand when this functionality would be useful outside of Org.
>> Can you explain?
>
> I meant "org buffer": you might want to issue the command from an
> arbitrary buffer, not just an org mode buffer, so the key should be
> defined globally.

I still don't understand.

Here, the command is for searching among (Org) headlines of the current buffer
-- see the restriction "<". I don't see how it would make sense to call that
on something other than an Org mode buffer?

Maybe you missed the "<" restriction?  Or do I miss something else?

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: A simple way to search only headlines
  2013-06-10 15:04                   ` Sebastien Vauban
@ 2013-06-11  4:31                     ` Nick Dokos
  2013-06-11 12:27                       ` Suvayu Ali
  0 siblings, 1 reply; 19+ messages in thread
From: Nick Dokos @ 2013-06-11  4:31 UTC (permalink / raw)
  To: emacs-orgmode

"Sebastien Vauban" <sva-news@mygooglest.com>
writes:

> Hi Nick,
>
> Nick Dokos wrote:
>> "Sebastien Vauban" <sva-news@mygooglest.com> writes:
>>> Nick Dokos wrote:
>>>> The OP probably wants this in the global keymap, rather than in the
>>>> org-mode-map: just like the agenda dispatcher C-c a, this functionality is
>>>> useful outside an org file.
>>>>
>>>> (global-set-key (kbd "C-M-h") (lambda () (interactive) (org-agenda nil "s" "<")))
>>>
>>> Not sure to understand when this functionality would be useful outside of Org.
>>> Can you explain?
>>
>> I meant "org buffer": you might want to issue the command from an
>> arbitrary buffer, not just an org mode buffer, so the key should be
>> defined globally.
>
> I still don't understand.
>

You understand all too well :-)

> Here, the command is for searching among (Org) headlines of the current buffer
> -- see the restriction "<". I don't see how it would make sense to call that
> on something other than an Org mode buffer?
>
> Maybe you missed the "<" restriction?  Or do I miss something else?
>

I did. Sorry about that.

-- 
Nick

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

* Re: A simple way to search only headlines
  2013-06-11  4:31                     ` Nick Dokos
@ 2013-06-11 12:27                       ` Suvayu Ali
  2013-06-11 14:42                         ` Thorsten Jolitz
  0 siblings, 1 reply; 19+ messages in thread
From: Suvayu Ali @ 2013-06-11 12:27 UTC (permalink / raw)
  To: emacs-orgmode

On Tue, Jun 11, 2013 at 12:31:16AM -0400, Nick Dokos wrote:
> "Sebastien Vauban" <sva-news@mygooglest.com>
> writes:
> 
> > Hi Nick,
> >
> > Nick Dokos wrote:
> >> "Sebastien Vauban" <sva-news@mygooglest.com> writes:
> >>> Nick Dokos wrote:
> >>>> The OP probably wants this in the global keymap, rather than in the
> >>>> org-mode-map: just like the agenda dispatcher C-c a, this functionality is
> >>>> useful outside an org file.
> >>>>
> >>>> (global-set-key (kbd "C-M-h") (lambda () (interactive) (org-agenda nil "s" "<")))
> >>>
> >>> Not sure to understand when this functionality would be useful outside of Org.
> >>> Can you explain?
> >>
> >> I meant "org buffer": you might want to issue the command from an
> >> arbitrary buffer, not just an org mode buffer, so the key should be
> >> defined globally.
> >
> > I still don't understand.
> >
> 
> You understand all too well :-)

I wonder if semantic search can be leveraged to achieve the same.  It
might open other possibilities: searching only links, list items, source
blocks, ...  I think you get the point.  :-p

In the past I have had trouble using semantic search even in traditional
source code buffers, e.g. C/C++, Python, lisp, etc, but that was a long
time back.  Did any one else have better luck?

I also have no clue how well the semantic support is for Org buffers.
If I start speedbar, the first few levels of headlines are recognised
automatically; maybe it is not a pipe dream to extend this to other org
syntax elements?

Food for thought,

;)

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: A simple way to search only headlines
  2013-06-11 12:27                       ` Suvayu Ali
@ 2013-06-11 14:42                         ` Thorsten Jolitz
  2013-06-11 22:01                           ` Suvayu Ali
  0 siblings, 1 reply; 19+ messages in thread
From: Thorsten Jolitz @ 2013-06-11 14:42 UTC (permalink / raw)
  To: emacs-orgmode

Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:

> I wonder if semantic search can be leveraged to achieve the same.  It
> might open other possibilities: searching only links, list items, source
> blocks, ...  I think you get the point.  :-p

navi-mode.el works for Org-mode buffers too, e.g. using 

,---------------------------------
| worg/org-contrib/babel/intro.org
`---------------------------------

as an sufficiently complex example file, the following simple
keybindings yield the following search results in the *Navi* buffer:

command (show headlines up to level 2):
,--
| 2
`--

result:
,--------------------------------------------------------------
| 28 matches for "^\*\*? " in buffer: intro.org
|      14:* Improving this document                  :noexport:
|      15:** DONE Document slice indexing of tables
|      16:** DONE Document synonymous alternatives
|      18:** DONE Describe useful functions
|      22:** DONE Language support
|      27:** DONE Document noweb references
|      29:** TODO Developments
|      55:** DONE Useful variables
|      57:** TODO Language specific header arguments
|     127:** DONE What function is bound to C-c '?
|     129:* Introduction
|     153:* Overview
|     179:* Initial Configuration
|     203:* Code Blocks
|     208:** Code Blocks in Org
|     241:** Code Blocks in Babel
|     268:* Source Code Execution
|     360:** Capturing the Results of Code Evaluation
|     429:** Session-based Evaluation
|     453:** Arguments to Code Blocks
|     539:** In-line Code Blocks
|     546:** Code Block Body Expansion
|     593:** A Meta-programming Language for Org-mode
|     652:* Using Code Blocks in Org Tables
|     842:* The Library of Babel
|     886:* Literate Programming
|    1098:* Reproducible Research
|    1136:* Footnotes
`--------------------------------------------------------------

command (show source-code blocks):
,--
| b
`--

result:

,-------------------------------------------------------------------------------
| 30 matches for [long regexp] in buffer:intro.org
| 
|      93:#+begin_src python :file outfile.txt
|     225:#+begin_src org
|     234:#+begin_src org
|     249:#+begin_src org
|     289:#+begin_src ruby
|     304:#+begin_src sh
|     322:#+begin_src R :colnames yes
|     346:#+begin_src ditaa :file blue.png :cmdline -r
|     385:#+begin_src python :results value
|     414:#+begin_src python :results output
|     469:#+begin_src python
|     512:#+begin_src emacs-lisp
|     579:#+begin_src emacs-lisp :rownames yes :var data=user-data
|     585:#+begin_src emacs-lisp
|     647:#+begin_src R :session R-pie-example :file ../../images/babel/dirs.png
|     696:#+begin_src R 
|     776:#+begin_src emacs-lisp
|     788:#+begin_src sh :results silent
|     800:#+begin_src sh :results silent
|     812:#+begin_src ruby :results silent
|     824:#+begin_src python :results silent
|     837:#+begin_src R :results silent
|     878:  #+begin_src emacs-lisp 
|     950:#+begin_src sh :exports none
|     962:#+begin_src sh :exports none
|     983:#+begin_src sh :tangle hello.sh :exports none :noweb yes
|     994:#+begin_src sh 
|    1051:   #+begin_src sh 
|    1056:   #+begin_src sh
|    1065:   #+begin_src emacs-lisp 
`-------------------------------------------------------------------------------

command (show headlines up to level 2 and source-code blocks):

,------
| C-2 b
`------

result:

,-------------------------------------------------------------------------------
| 58 matches for [long regexp] in buffer:intro.org
| 
|      14:* Improving this document                  :noexport:
|      15:** DONE Document slice indexing of tables
|      16:** DONE Document synonymous alternatives
|      18:** DONE Describe useful functions
|      22:** DONE Language support
|      27:** DONE Document noweb references
|      29:** TODO Developments
|      55:** DONE Useful variables
|      57:** TODO Language specific header arguments
|      93:#+begin_src python :file outfile.txt
|     127:** DONE What function is bound to C-c '?
|     129:* Introduction
|     153:* Overview
|     179:* Initial Configuration
|     203:* Code Blocks
|     208:** Code Blocks in Org
|     225:#+begin_src org
|     234:#+begin_src org
|     241:** Code Blocks in Babel
|     249:#+begin_src org
|     268:* Source Code Execution
|     289:#+begin_src ruby
|     304:#+begin_src sh
|     322:#+begin_src R :colnames yes
|     346:#+begin_src ditaa :file blue.png :cmdline -r
|     360:** Capturing the Results of Code Evaluation
|     385:#+begin_src python :results value
|     414:#+begin_src python :results output
|     429:** Session-based Evaluation
|     453:** Arguments to Code Blocks
|     469:#+begin_src python
|     512:#+begin_src emacs-lisp
|     539:** In-line Code Blocks
|     546:** Code Block Body Expansion
|     579:#+begin_src emacs-lisp :rownames yes :var data=user-data
|     585:#+begin_src emacs-lisp
|     593:** A Meta-programming Language for Org-mode
|     647:#+begin_src R :session R-pie-example :file ../../images/babel/dirs.png
|     652:* Using Code Blocks in Org Tables
|     696:#+begin_src R 
|     776:#+begin_src emacs-lisp
|     788:#+begin_src sh :results silent
|     800:#+begin_src sh :results silent
|     812:#+begin_src ruby :results silent
|     824:#+begin_src python :results silent
|     837:#+begin_src R :results silent
|     842:* The Library of Babel
|     878:  #+begin_src emacs-lisp 
|     886:* Literate Programming
|     950:#+begin_src sh :exports none
|     962:#+begin_src sh :exports none
|     983:#+begin_src sh :tangle hello.sh :exports none :noweb yes
|     994:#+begin_src sh 
|    1051:   #+begin_src sh 
|    1056:   #+begin_src sh
|    1065:   #+begin_src emacs-lisp 
|    1098:* Reproducible Research
|    1136:* Footnotes
`-------------------------------------------------------------------------------

These are the keyword searches implemented for Org-mode so far:

,------------------------------------------------
| [KEY] : [SEARCH]
| ================
|                         b : srcblock
|                         x : time
|                         I : inline-srcblock
|                         W : srcname-w-name
|                         M : multilineheader
|                         Y : priority
|                         T : target
|                         R : radiotarget
|                         D : drawer
|                         S : timestamp
|                         N : srcname
|                         U : result
|                         Z : result-w-name
|                         O : options
|                         P : propertydrawer
|                         A : deadline
|                         H : scheduled-time-hour
`------------------------------------------------

they can be combined with the headline searches [1..8], like e.g. 'C-4
D'. 

While the keyword searches for Emacs Lisp in navi-mode are quite
exhaustive and well defined, I did not invest too much work into the
searches for Org-mode, so there is room for improvement. Note that the
keybindings and the regexps are customizable (M-x customize-group RET
navi-mode RET), and that `navi-generic-command' binds all ASCII printing
characters by default.

Thus besides those keys used for navi-mode itself and those already used
in the keyword-searches shown above there are a lot one one-key commands
(keyword-searches) left to be defined by the user via the customizable
variables:

,------------------
| navi-key-mappings
| navi-keywords
`------------------

Any improvements or extensions of the keyword-searches for Org-mode
would be welcome, I'm sure there are more org-elements that people might
want to see listed for the org-buffer at hand. 

A nice thing about the *Navi* is that its plain text, so you can use
standard Emacs search commands to search in the
headlines/keyword-search-results. 

-- 
cheers,
Thorsten

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

* Re: A simple way to search only headlines
  2013-06-11 14:42                         ` Thorsten Jolitz
@ 2013-06-11 22:01                           ` Suvayu Ali
  2013-06-11 23:55                             ` Thorsten Jolitz
  0 siblings, 1 reply; 19+ messages in thread
From: Suvayu Ali @ 2013-06-11 22:01 UTC (permalink / raw)
  To: emacs-orgmode

Hi Thorsten,

On Tue, Jun 11, 2013 at 04:42:28PM +0200, Thorsten Jolitz wrote:
> Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:
> 
> > I wonder if semantic search can be leveraged to achieve the same.  It
> > might open other possibilities: searching only links, list items, source
> > blocks, ...  I think you get the point.  :-p
> 
> navi-mode.el works for Org-mode buffers too, e.g. using 

I think you misunderstood somewhat what I was suggesting.

As far as I understand, navi-mode uses an interface like occur; it
presents a separate buffer with the results which you can then use to
navigate to the results.  Am I correct?

What I was suggesting (and how I understood the OPs question) was, to
restrict regular (i)search to headlines.  Consider the following example
Org buffer:


  * Top heading
  
  ** Sub-heading 1
  + List entry
  + Another entry with an enumerated list
    1. Foo
    2. Bar
  
  ** Another sub-heading


Now with such restriction enabled, `C-s A n o t h e r' will navigate to
the headline (just like regular isearch-forward)

  ** Another sub-heading

not the list item

  + Another entry with an enumerated list

As far as I know, functionality like this exists for traditional source
code buffers using semantic search.  I was wondering if it is possible
to leverage that mechanism to get the behaviour described above.  If it
is indeed possible, it could be hacked to work for other Org syntax
elements like links, lists, source blocks, drawers, etc.

Hopefully I didn't misunderstand your post and I was clearer expressing
myself this time.

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: A simple way to search only headlines
  2013-06-11 22:01                           ` Suvayu Ali
@ 2013-06-11 23:55                             ` Thorsten Jolitz
  0 siblings, 0 replies; 19+ messages in thread
From: Thorsten Jolitz @ 2013-06-11 23:55 UTC (permalink / raw)
  To: emacs-orgmode

Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:

Hi Suvayu,

> On Tue, Jun 11, 2013 at 04:42:28PM +0200, Thorsten Jolitz wrote:
>> Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:
>> 
>> > I wonder if semantic search can be leveraged to achieve the same.  It
>> > might open other possibilities: searching only links, list items, source
>> > blocks, ...  I think you get the point.  :-p
>> 
>> navi-mode.el works for Org-mode buffers too, e.g. using 
>
> I think you misunderstood somewhat what I was suggesting.
>
> As far as I understand, navi-mode uses an interface like occur; it
> presents a separate buffer with the results which you can then use to
> navigate to the results.  Am I correct?

yes, it works on top of occur-mode in a separate buffer, but *Navi*
buffer are permanent, and there can exist many of them at the same time. 

> What I was suggesting (and how I understood the OPs question) was, to
> restrict regular (i)search to headlines.  
[...]
> As far as I know, functionality like this exists for traditional source
> code buffers using semantic search.  I was wondering if it is possible
> to leverage that mechanism to get the behaviour described above.  If it
> is indeed possible, it could be hacked to work for other Org syntax
> elements like links, lists, source blocks, drawers, etc.
>
> Hopefully I didn't misunderstand your post and I was clearer expressing
> myself this time.

I think I more or less understood what the thread was about, but thanks
anyway for the clarification. Of course navi-mode does not offer
"semantic search" within an Org-mode buffer. But for practical purposes
it might be worth mentioning that typing one digit between 1 and 8 and
then C-s or C-r in the *Navi* buffer lets you already search easily only
in the headlines of an Org file. And many other views on a file are
possible, that can then be searched by standard commands. With keyboard
macros and switching between original buffer and *Navi* buffer (and
using org-mark-element e.g.), a lot can be achieved without the need of
writing any elisp code.

-- 
Cheers,
Thorsten

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

end of thread, other threads:[~2013-06-11 23:56 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-01 16:35 A simple way to search only headlines Xebar Saram
2013-06-01 20:10 ` Tassilo Horn
2013-06-03  7:48   ` Sebastien Vauban
2013-06-03 12:16     ` Xebar Saram
2013-06-04  7:18       ` Thorsten Jolitz
2013-06-04  7:50       ` Sebastien Vauban
2013-06-07 20:31         ` Xebar Saram
2013-06-07 21:50           ` Richard Lawrence
2013-06-08  0:05             ` Xebar Saram
2013-06-08  0:34               ` Richard Lawrence
2013-06-08  5:25             ` Nick Dokos
2013-06-10  7:34               ` Sebastien Vauban
2013-06-10 13:06                 ` Nick Dokos
2013-06-10 15:04                   ` Sebastien Vauban
2013-06-11  4:31                     ` Nick Dokos
2013-06-11 12:27                       ` Suvayu Ali
2013-06-11 14:42                         ` Thorsten Jolitz
2013-06-11 22:01                           ` Suvayu Ali
2013-06-11 23:55                             ` Thorsten Jolitz

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