From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Rose Subject: Interactively add refile targets - was: refile ideas Date: Wed, 05 Aug 2009 15:00:16 +0200 Message-ID: <87tz0ms9en.fsf_-_@kassiopeya.MSHEIMNETZ> References: <20524da70907072159v3604e31ekf4209ea2643942e5@mail.gmail.com> <20524da70908031531s417bb607tcf9a4d52857bc070@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MYg2I-00049b-OE for emacs-orgmode@gnu.org; Wed, 05 Aug 2009 08:56:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MYg2C-00047X-OR for emacs-orgmode@gnu.org; Wed, 05 Aug 2009 08:56:05 -0400 Received: from [199.232.76.173] (port=60207 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MYg2C-000476-DN for emacs-orgmode@gnu.org; Wed, 05 Aug 2009 08:56:00 -0400 Received: from mail.gmx.net ([213.165.64.20]:50578) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1MYg2B-0005AU-KG for emacs-orgmode@gnu.org; Wed, 05 Aug 2009 08:56:00 -0400 In-Reply-To: <20524da70908031531s417bb607tcf9a4d52857bc070@mail.gmail.com> (Samuel Wales's message of "Mon, 3 Aug 2009 15:31:55 -0700") 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: Samuel Wales Cc: emacs-orgmode@gnu.org, Carsten Dominik --=-=-= Samuel Wales writes: > Hi Carsten, > > On 2009-08-02, Carsten Dominik wrote: >> If you mark some headlines (for example you remember targets) >> with a tag like "r", you could make yourself a restricted >> refile command like this: >> >> (defun my-org-restricted-refile () >> (interactive) >> (let ((org-refile-targets '((org-agenda-files :tag . "r")))) >> (call-interactively 'org-refile))) >> >> Not what you proposed, but maybe useful. Sorry, for not following the original thread closely. But the above function does something, I missed when refiling, too. A way to add refile targets on the fly. The refile mechanism depends on agenda files and files below `org-directory' or a somewhat static setup, which is insufficient for most of my use cases. I often take notes for just any of my project using a limited set templates (limited, because I don't want to choose out of many templates for better overview and less thinking while storing via remember). But when it comes to refiling, I need to spread all those notes to several directories, scattered all over the place. I therefor have `org-refile-targets' set to: ((org-agenda-files :maxlevel . 3) (sr-org-refile-targets :maxlevel . 2)) In addition, I use the (far from perfect) functions below. They make it possible, to add any directory to my refile targets on-the-fly, which is what I prefer. `sr-add-to-org-refile-targets' adds all *.org files in a directory to my targets, with a prefix arg (`C-u ....') recursively. Since a big number of refile targets slows down refiling a lot (the only area I ever felt a slow down in Org-mode so far), a function to remove refile targets again (recursively, too) is still missing. Also, a function to add or remove single files is missing. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline Content-Transfer-Encoding: quoted-printable (defvar sr-org-refile-targets nil "List of refile targets for Org-remember.= See `org-refile-targets'.") (defvar sr-org-refile-dir-excludes "^[#\\.].*$") (defvar sr-org-refile-file-excludes "^[#\\.].*$") (defun sr-find-org-refile-targets (&optional recurse dirs file-excludes dir= -excludes) "Fill the variable `sr-org-refile-targets'. Optional parameters: RECURSE If `t', scan the directory recusively. DIRS A list of directories to scan for *.org files. FILE-EXCLUDES Regular expression. If a filename matches this regular exp= ression, do not add it to `sr-org-refile-targets'. DIR-EXCLUDES Regular expression. If a directory name matches this regul= ar expression, do not add it to `sr-org-refile-targets'." (let ((targets (or dirs (list org-directory))) (fex (or file-excludes "^[#\\.].*$")) ;; should be defcustom= ed (dex (or dir-excludes "^[#\\.].*$")) ;; should be defcustom= ed path) (dolist (dir targets) (if (file-directory-p dir) (let ((all (directory-files dir nil "^[^#\\.].*$"))) (dolist (f all) (setq path (concat (file-name-as-directory dir) f)) (cond ((file-directory-p path) (if (and recurse (not (string-match dex f))) (sr-find-org-refile-targets t (list path) fex dex))) ((and (string-match "^[^#\\.].*\\.org$" f) (not (string-matc= h fex f))) (setq sr-org-refile-targets (append (list path) sr-org-refi= le-targets)))))) (message "Not a directory: %s" path)) ))) (defun sr-add-to-org-refile-targets ( recurse dirs ) "Add a directory to org-refile targets recursively." (interactive "P\nDdirectory: ") (sr-find-org-refile-targets (if recurse t nil) (list dirs) sr-org-refile-file-excludes sr-org-refile-dir-excludes) (message "org-refile-targets: \n%s" sr-org-refile-targets)) (define-key sr-org-map "H-o r" 'sr-add-to-org-refile-targets)=20 --=-=-= A good better alternative would be, to allow for refiling to arbitrary Org-files. 1. `M-x org-refile-to' 2. Minibuffer prompt: Find file: ~/ 3. Navigate to an *.org file (restrict TAB completion to *.org) 4. RET 5. Org-mode scanns the file and offers the targets as usual. 6. Add the file to the list of refile targets. Which would mean to add just one simple function to Org-mode. I'd prefer this simple interface over the directory aproach. In emacs, the directory aproach is not needed, since we have the history (UP) for quickly find a second file in the same directory. Please choose the interface you like most, say `yes, we want it', and I'll sit down and hack together a proposal. Sebastian --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--