* a new way to navigate your org files
@ 2011-04-24 16:06 Tom
2011-04-24 18:18 ` Matt Lundin
2011-04-24 20:24 ` Suvayu Ali
0 siblings, 2 replies; 8+ messages in thread
From: Tom @ 2011-04-24 16:06 UTC (permalink / raw)
To: emacs-orgmode
I use org goto to jump quckly to headings, but the other day
I forgot the name of the heading, but I remembered its contents.
I thought it could be useful if I could navigate org files by content
too, so I quickly created this package as a sunday afternoon fun.
It is a wrapper around the multi-occur interface, so you can
simply type your search pattern and the occur results from your org
buffers are updated dynamically as you type.
Here it is:
;;; org-occur-goto.el -- search open org buffers with an occur interface
;;; Usage: M-x oog, then start typing
;;;
;;; select from the occur matches with up/down/pgup/pgdown and press enter
;;;
;;; the search string must be at least 3 characters long (by default)
;;;
(require 'cl)
(defvar oog-idle-delay 0.5)
(defvar oog-minimum-input-length 3)
(defvar oog-map
(let ((map (copy-keymap minibuffer-local-map)))
(define-key map (kbd "<down>") 'oog-next-line)
(define-key map (kbd "<up>") 'oog-previous-line)
(define-key map (kbd "<prior>") 'oog-previous-page)
(define-key map (kbd "<next>") 'oog-next-page)
map))
(defun oog-previous-line ()
(interactive)
(oog-move-selection 'next-line -1))
(defun oog-next-line ()
(interactive)
(oog-move-selection 'next-line 1))
(defun oog-previous-page ()
(interactive)
(oog-move-selection 'scroll-down nil))
(defun oog-next-page ()
(interactive)
(oog-move-selection 'scroll-up nil))
(defun oog-move-selection (movefunc movearg)
(let ((win (get-buffer-window "*Occur*")))
(if win
(with-selected-window win
(condition-case nil
(funcall movefunc movearg)
(beginning-of-buffer (goto-char (point-min)))
(end-of-buffer (goto-char (point-max))))))))
(defun oog-check-input ()
(when (sit-for oog-idle-delay)
(unless (equal (minibuffer-contents) oog-current-input)
(setq oog-current-input (minibuffer-contents))
(if (< (length oog-current-input) oog-minimum-input-length)
(let ((win (get-buffer-window "*Occur*")))
(if win
(with-selected-window win
(setq buffer-read-only nil)
(erase-buffer))))
(save-excursion
(flet ((message (&rest args) nil)) ;; suppress occur messages
(multi-occur
(remove nil (mapcar (lambda (buffer)
(with-current-buffer buffer
(if (eq major-mode 'org-mode)
buffer)))
(buffer-list)))
oog-current-input))
(unless (get-buffer "*Occur*")
(message "No matches.")))))))
(defun oog ()
(interactive)
(let (marker)
(save-window-excursion
(add-hook 'post-command-hook 'oog-check-input)
(setq oog-current-input nil)
(unwind-protect
(let ((minibuffer-local-map oog-map))
(read-string "string: "))
(remove-hook 'post-command-hook 'oog-check-input))
(let ((buf (get-buffer "*Occur*")))
(if buf
(with-current-buffer buf
(unless (= (buffer-size) 0)
(setq marker (occur-mode-find-occurrence)))))))
(switch-to-buffer (marker-buffer marker))
(goto-char marker)
(when (outline-invisible-p)
(save-excursion
(outline-previous-visible-heading 1)
(org-show-subtree)))))
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: a new way to navigate your org files
2011-04-24 16:06 a new way to navigate your org files Tom
@ 2011-04-24 18:18 ` Matt Lundin
2011-04-24 20:24 ` Suvayu Ali
1 sibling, 0 replies; 8+ messages in thread
From: Matt Lundin @ 2011-04-24 18:18 UTC (permalink / raw)
To: Tom; +Cc: emacs-orgmode
Tom <adatgyujto@gmail.com> writes:
> I use org goto to jump quckly to headings, but the other day
> I forgot the name of the heading, but I remembered its contents.
> I thought it could be useful if I could navigate org files by content
> too, so I quickly created this package as a sunday afternoon fun.
>
> It is a wrapper around the multi-occur interface, so you can
> simply type your search pattern and the occur results from your org
> buffers are updated dynamically as you type.
This is great! Thanks for sharing.
Best,
Matt
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: a new way to navigate your org files
2011-04-24 16:06 a new way to navigate your org files Tom
2011-04-24 18:18 ` Matt Lundin
@ 2011-04-24 20:24 ` Suvayu Ali
2011-04-25 19:25 ` Tom
1 sibling, 1 reply; 8+ messages in thread
From: Suvayu Ali @ 2011-04-24 20:24 UTC (permalink / raw)
To: Tom; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 927 bytes --]
Hi Tom,
On Sun, 24 Apr 2011 16:06:05 +0000 (UTC)
Tom <adatgyujto@gmail.com> wrote:
> I use org goto to jump quckly to headings, but the other day
> I forgot the name of the heading, but I remembered its contents.
> I thought it could be useful if I could navigate org files by content
> too, so I quickly created this package as a sunday afternoon fun.
>
> It is a wrapper around the multi-occur interface, so you can
> simply type your search pattern and the occur results from your org
> buffers are updated dynamically as you type.
This is very useful. I made some enhancements in the attached patches.
The first one adds a very basic minibuffer history. You can navigate the
history by the usual `M-p' and `M-n'. The second patch fixes an issue,
now you can go to the first match by just hitting `RET' instead of
`<down> RET'.
Thanks a lot for writing this. :)
--
Suvayu
Open source is the future. It sets us free.
[-- Attachment #2: 0001-Add-minibuffer-history-to-org-occur-goto.patch --]
[-- Type: text/x-patch, Size: 721 bytes --]
From 08c35bcf7cc3b290f8421236c4bc5e3345398ff0 Mon Sep 17 00:00:00 2001
From: Suvayu Ali <fatkasuvayu+linux@gmail.com>
Date: Sun, 24 Apr 2011 12:20:27 -0700
Subject: [PATCH 1/2] Add minibuffer history to org-occur-goto
---
lisp/org-occur-goto.el | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lisp/org-occur-goto.el b/lisp/org-occur-goto.el
index e2af3fb..ccef330 100644
--- a/lisp/org-occur-goto.el
+++ b/lisp/org-occur-goto.el
@@ -90,7 +90,7 @@
(unwind-protect
(let ((minibuffer-local-map oog-map))
- (read-string "string: "))
+ (read-string "string: " nil 'oog-history-list))
(remove-hook 'post-command-hook 'oog-check-input))
--
1.7.3.4
[-- Attachment #3: 0002-oog-can-got-to-first-match-by-hitting-RET.patch --]
[-- Type: text/x-patch, Size: 908 bytes --]
From 1742551e8e19abaa272e444fa8c27afd76a7e6b8 Mon Sep 17 00:00:00 2001
From: Suvayu Ali <fatkasuvayu+linux@gmail.com>
Date: Sun, 24 Apr 2011 13:10:19 -0700
Subject: [PATCH 2/2] oog: can got to first match by hitting RET
---
lisp/org-occur-goto.el | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/lisp/org-occur-goto.el b/lisp/org-occur-goto.el
index ccef330..7398daf 100644
--- a/lisp/org-occur-goto.el
+++ b/lisp/org-occur-goto.el
@@ -98,7 +98,10 @@
(if buf
(with-current-buffer buf
(unless (= (buffer-size) 0)
- (setq marker (occur-mode-find-occurrence)))))))
+ (setq marker (if (eq (line-number-at-pos (point)) 1)
+ (progn (forward-line)
+ (occur-mode-find-occurrence))
+ (occur-mode-find-occurrence))))))))
(switch-to-buffer (marker-buffer marker))
(goto-char marker)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: a new way to navigate your org files
2011-04-24 20:24 ` Suvayu Ali
@ 2011-04-25 19:25 ` Tom
2011-04-26 11:12 ` Suvayu Ali
2011-08-27 13:26 ` Nathan Neff
0 siblings, 2 replies; 8+ messages in thread
From: Tom @ 2011-04-25 19:25 UTC (permalink / raw)
To: emacs-orgmode
Suvayu Ali <fatkasuvayu+linux <at> gmail.com> writes:
>
> This is very useful. I made some enhancements in the attached patches.
> The first one adds a very basic minibuffer history. You can navigate the
> history by the usual `M-p' and `M-n'. The second patch fixes an issue,
> now you can go to the first match by just hitting `RET' instead of
> `<down> RET'.
>
I added your changes to the code (implementing the second one slightly
differently, but it works the same way).
I also turned on full cursor for the Occur buffer, instead of the hollow
one, so it can be seen more easily.
The code is on EmacsWiki for easier downloed:
http://www.emacswiki.org/emacs/org-occur-goto.el
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: a new way to navigate your org files
2011-04-25 19:25 ` Tom
@ 2011-04-26 11:12 ` Suvayu Ali
2011-08-27 13:26 ` Nathan Neff
1 sibling, 0 replies; 8+ messages in thread
From: Suvayu Ali @ 2011-04-26 11:12 UTC (permalink / raw)
To: Tom; +Cc: emacs-orgmode
On Mon, 25 Apr 2011 19:25:17 +0000 (UTC)
Tom <adatgyujto@gmail.com> wrote:
> I added your changes to the code (implementing the second one slightly
> differently, but it works the same way).
>
> I also turned on full cursor for the Occur buffer, instead of the
> hollow one, so it can be seen more easily.
>
> The code is on EmacsWiki for easier downloed:
>
> http://www.emacswiki.org/emacs/org-occur-goto.el
Thanks a lot. :)
--
Suvayu
Open source is the future. It sets us free.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: a new way to navigate your org files
2011-04-25 19:25 ` Tom
2011-04-26 11:12 ` Suvayu Ali
@ 2011-08-27 13:26 ` Nathan Neff
2011-08-28 8:44 ` Stelian Iancu
1 sibling, 1 reply; 8+ messages in thread
From: Nathan Neff @ 2011-08-27 13:26 UTC (permalink / raw)
To: Tom; +Cc: emacs-orgmode
I just found this and it's great -- thanks!
On Mon, Apr 25, 2011 at 2:25 PM, Tom <adatgyujto@gmail.com> wrote:
> Suvayu Ali <fatkasuvayu+linux <at> gmail.com> writes:
>>
>> This is very useful. I made some enhancements in the attached patches.
>> The first one adds a very basic minibuffer history. You can navigate the
>> history by the usual `M-p' and `M-n'. The second patch fixes an issue,
>> now you can go to the first match by just hitting `RET' instead of
>> `<down> RET'.
>>
>
> I added your changes to the code (implementing the second one slightly
> differently, but it works the same way).
>
> I also turned on full cursor for the Occur buffer, instead of the hollow
> one, so it can be seen more easily.
>
> The code is on EmacsWiki for easier downloed:
>
> http://www.emacswiki.org/emacs/org-occur-goto.el
>
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: a new way to navigate your org files
2011-08-27 13:26 ` Nathan Neff
@ 2011-08-28 8:44 ` Stelian Iancu
2011-08-28 8:53 ` suvayu ali
0 siblings, 1 reply; 8+ messages in thread
From: Stelian Iancu @ 2011-08-28 8:44 UTC (permalink / raw)
To: emacs-orgmode
On 08/27/2011 09:26 AM, Nathan Neff wrote:
> I just found this and it's great -- thanks!
>
> On Mon, Apr 25, 2011 at 2:25 PM, Tom<adatgyujto@gmail.com> wrote:
>
>> Suvayu Ali<fatkasuvayu+linux<at> gmail.com> writes:
>>
>>> This is very useful. I made some enhancements in the attached patches.
>>> The first one adds a very basic minibuffer history. You can navigate the
>>> history by the usual `M-p' and `M-n'. The second patch fixes an issue,
>>> now you can go to the first match by just hitting `RET' instead of
>>> `<down> RET'.
>>>
>>>
>> I added your changes to the code (implementing the second one slightly
>> differently, but it works the same way).
>>
>> I also turned on full cursor for the Occur buffer, instead of the hollow
>> one, so it can be seen more easily.
>>
>> The code is on EmacsWiki for easier downloed:
>>
>> http://www.emacswiki.org/emacs/org-occur-goto.el
>>
>>
Sorry for the stupid question, but how do I enable this?
Thanks!
S.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-08-28 8:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-24 16:06 a new way to navigate your org files Tom
2011-04-24 18:18 ` Matt Lundin
2011-04-24 20:24 ` Suvayu Ali
2011-04-25 19:25 ` Tom
2011-04-26 11:12 ` Suvayu Ali
2011-08-27 13:26 ` Nathan Neff
2011-08-28 8:44 ` Stelian Iancu
2011-08-28 8:53 ` 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).