From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: automatic isearch-mode in org-goto and org-remember Date: Fri, 23 Jun 2006 21:10:50 +0200 Message-ID: <08010922c4fde2a6894467bad9fd365a@science.uva.nl> References: <3c12eb8d0606230740m21779d82ra064e71977124304@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v624) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ftr3S-0000xQ-OG for emacs-orgmode@gnu.org; Fri, 23 Jun 2006 15:10:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ftr3P-0000x5-Ry for emacs-orgmode@gnu.org; Fri, 23 Jun 2006 15:10:57 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ftr3P-0000ww-KJ for emacs-orgmode@gnu.org; Fri, 23 Jun 2006 15:10:55 -0400 Received: from [64.233.182.186] (helo=nf-out-0910.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FtrEf-00035I-N6 for emacs-orgmode@gnu.org; Fri, 23 Jun 2006 15:22:33 -0400 Received: by nf-out-0910.google.com with SMTP id a27so501385nfc for ; Fri, 23 Jun 2006 12:10:54 -0700 (PDT) In-Reply-To: <3c12eb8d0606230740m21779d82ra064e71977124304@mail.gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Piotr Zielinski Cc: emacs-orgmode@gnu.org 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