emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* automatic isearch-mode in org-goto and org-remember
@ 2006-06-23 14:40 Piotr Zielinski
  2006-06-23 19:10 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Piotr Zielinski @ 2006-06-23 14:40 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

The following lisp code turns automatic isearch mode on (as in
Firefox) whenever you navigate an org-file using org-goto or
org-remember.  It is useful especially for finding headlines when the
org-file is long and has a deeply nested structure. The isearch-mode
is modified so that it searches only headlines (even invisible ones)
but ignores normal text.

The function local-move-tree uses (the enhanced) org-goto to move the
current tree to the selected location.  It is useful for organizing
your org-file; when many items accumulated on your general todo list
(eg. after using org-remember a lot) and you want to dispatch them to
the projects they belong to.

Finally, the newest version of  org-mouse (0.17) allows you to toggle
checkboxes [X] with a single mouse click.

http://www.cl.cam.ac.uk/~pz215/files/org-mouse.el

Piotr


(defvar local-auto-isearch-map (make-sparse-keymap))
(set-keymap-parent local-auto-isearch-map isearch-mode-map)
(define-key local-auto-isearch-map "\C-i" 'isearch-other-control-char)

(defun local-search-forward-headings (string bound noerror)
  (catch 'return
    (while (search-forward string bound noerror)
      (when (save-match-data (outline-on-heading-p t))
	(throw 'return t)))))

(defun local-auto-isearch ()
  (interactive)
  (let ((keys (this-command-keys)))
    (when (eq (lookup-key isearch-mode-map keys) 'isearch-printing-char)
      (isearch-mode t)
      (isearch-process-search-char (string-to-char keys)))))

(defun local-move-tree (&optional tobuffer)
  (interactive)
  (setq tobuffer (or tobuffer (current-buffer)))
  (let ((toplace (save-excursion
		    (set-buffer tobuffer)
		    (beginning-of-buffer)
		    (org-goto)
		    (copy-marker (point)))))
    (org-cut-subtree)
      (save-excursion
	(set-buffer tobuffer)
	(goto-char toplace)
	(org-back-to-heading t)
	(org-paste-subtree (outline-level)))))


(add-hook 'org-mode-hook
	  '(lambda ()
	     (defadvice org-get-location (around auto-isearch-advice activate)
	       (let ((isearch-mode-map local-auto-isearch-map)
		     (isearch-hide-immediately nil)
		     (isearch-search-fun-function
		      (lambda () 'local-search-forward-headings)))
		 ad-do-it))
  	     (define-key org-goto-map [(return)] 'org-goto-ret)
	     (define-key-after org-goto-map [t] 'local-auto-isearch)
	     (require 'cl)
	     (dolist (key '(?n ?p ?f ?b ?u ?q))
	       (setq org-goto-map (assq-delete-all key org-goto-map)))))

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

* Re: automatic isearch-mode in org-goto and org-remember
  2006-06-23 14:40 automatic isearch-mode in org-goto and org-remember Piotr Zielinski
@ 2006-06-23 19:10 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2006-06-23 19:10 UTC (permalink / raw)
  To: Piotr Zielinski; +Cc: emacs-orgmode

Now, here is something for me to learn.  Thanks Piotr,
this looks really great.

- Carsten

On Jun 23, 2006, at 16:40, Piotr Zielinski wrote:

> Hi,
>
> The following lisp code turns automatic isearch mode on (as in
> Firefox) whenever you navigate an org-file using org-goto or
> org-remember.  It is useful especially for finding headlines when the
> org-file is long and has a deeply nested structure. The isearch-mode
> is modified so that it searches only headlines (even invisible ones)
> but ignores normal text.
>
> The function local-move-tree uses (the enhanced) org-goto to move the
> current tree to the selected location.  It is useful for organizing
> your org-file; when many items accumulated on your general todo list
> (eg. after using org-remember a lot) and you want to dispatch them to
> the projects they belong to.
>
> Finally, the newest version of  org-mouse (0.17) allows you to toggle
> checkboxes [X] with a single mouse click.
>
> http://www.cl.cam.ac.uk/~pz215/files/org-mouse.el
>
> Piotr
>
>
> (defvar local-auto-isearch-map (make-sparse-keymap))
> (set-keymap-parent local-auto-isearch-map isearch-mode-map)
> (define-key local-auto-isearch-map "\C-i" 'isearch-other-control-char)
>
> (defun local-search-forward-headings (string bound noerror)
>  (catch 'return
>    (while (search-forward string bound noerror)
>      (when (save-match-data (outline-on-heading-p t))
> 	(throw 'return t)))))
>
> (defun local-auto-isearch ()
>  (interactive)
>  (let ((keys (this-command-keys)))
>    (when (eq (lookup-key isearch-mode-map keys) 'isearch-printing-char)
>      (isearch-mode t)
>      (isearch-process-search-char (string-to-char keys)))))
>
> (defun local-move-tree (&optional tobuffer)
>  (interactive)
>  (setq tobuffer (or tobuffer (current-buffer)))
>  (let ((toplace (save-excursion
> 		    (set-buffer tobuffer)
> 		    (beginning-of-buffer)
> 		    (org-goto)
> 		    (copy-marker (point)))))
>    (org-cut-subtree)
>      (save-excursion
> 	(set-buffer tobuffer)
> 	(goto-char toplace)
> 	(org-back-to-heading t)
> 	(org-paste-subtree (outline-level)))))
>
>
> (add-hook 'org-mode-hook
> 	  '(lambda ()
> 	     (defadvice org-get-location (around auto-isearch-advice activate)
> 	       (let ((isearch-mode-map local-auto-isearch-map)
> 		     (isearch-hide-immediately nil)
> 		     (isearch-search-fun-function
> 		      (lambda () 'local-search-forward-headings)))
> 		 ad-do-it))
>  	     (define-key org-goto-map [(return)] 'org-goto-ret)
> 	     (define-key-after org-goto-map [t] 'local-auto-isearch)
> 	     (require 'cl)
> 	     (dolist (key '(?n ?p ?f ?b ?u ?q))
> 	       (setq org-goto-map (assq-delete-all key org-goto-map)))))
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>

--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477

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

end of thread, other threads:[~2006-06-23 19:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-23 14:40 automatic isearch-mode in org-goto and org-remember Piotr Zielinski
2006-06-23 19:10 ` Carsten Dominik

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