emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* add a whole directory as one item to refile targets
@ 2009-10-04 22:30 Eraldo Helal
  2009-10-08  7:02 ` Carsten Dominik
  0 siblings, 1 reply; 11+ messages in thread
From: Eraldo Helal @ 2009-10-04 22:30 UTC (permalink / raw)
  To: Org-Mode

If I do "C-c C-w" (refile), I get the following:

NOW:
 Click <mouse-2> on a completion to select it.
 In this buffer, type RET to select the completion near point.

 Possible completions are:
 done.org/ 	eraldo.org/ inbox.org/

WANTED:
 Possible completions are:
 done.org/ 	eraldo.org/ inbox.org/ Reference/

In other words...
I would like to have a whole directory as one item listed in my refile targets.


Greetings from Austria,
Eraldo & Lea


PS:
Another possibility would be to be able to refile to any other place
apart from the defined ones via prefix or shortcut.

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

* Re: add a whole directory as one item to refile targets
  2009-10-04 22:30 add a whole directory as one item to refile targets Eraldo Helal
@ 2009-10-08  7:02 ` Carsten Dominik
  2009-10-08  8:17   ` Syntax coloring not automatic Helge A. Gudmundsen
  2009-10-10 21:48   ` add a whole directory as one item to refile targets Eraldo Helal
  0 siblings, 2 replies; 11+ messages in thread
From: Carsten Dominik @ 2009-10-08  7:02 UTC (permalink / raw)
  To: Eraldo Helal; +Cc: Org-Mode

Hi Eraldo,

I have now read this email about 4 times, and I have not clue
what you are talking about.  Please try again.

- Carsten

On Oct 5, 2009, at 12:30 AM, Eraldo Helal wrote:

> If I do "C-c C-w" (refile), I get the following:
>
> NOW:
> Click <mouse-2> on a completion to select it.
> In this buffer, type RET to select the completion near point.
>
> Possible completions are:
> done.org/ 	eraldo.org/ inbox.org/
>
> WANTED:
> Possible completions are:
> done.org/ 	eraldo.org/ inbox.org/ Reference/
>
> In other words...
> I would like to have a whole directory as one item listed in my  
> refile targets.
>
>
> Greetings from Austria,
> Eraldo & Lea
>
>
> PS:
> Another possibility would be to be able to refile to any other place
> apart from the defined ones via prefix or shortcut.
>
>
> _______________________________________________
> 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

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

* Syntax coloring not automatic
  2009-10-08  7:02 ` Carsten Dominik
@ 2009-10-08  8:17   ` Helge A. Gudmundsen
  2009-10-10 21:48   ` add a whole directory as one item to refile targets Eraldo Helal
  1 sibling, 0 replies; 11+ messages in thread
From: Helge A. Gudmundsen @ 2009-10-08  8:17 UTC (permalink / raw)
  To: Org-Mode

Hello,

My apologies for a newbie question, but since I upgraded org-mode from
the bundled version (6.21 iirc), syntax highlighting is no longer
automatic, and when I have loaded my org-file, I have to manually run
org-mode-restart for it to kick in.

I am sure this is a configuration issue on my part, but I have not been
able google my way to a solution.

This is running GNU Emacs 23.1.1 (on Windows XP), org-mode version
6.31trans.

The org-specific bits in my setup file are:

----
(setq load-path (cons "c:/elisp/org-mode/lisp" load-path))
(setq load-path (cons "c:/elisp/org-mode/contrib/lisp" load-path))

(require 'org-install)

;; The following lines are always needed. Choose your own keys.

(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)

(org-remember-insinuate)

(setq org-directory "d:/My Dropbox/mylog")
(setq org-default-notes-file (concat org-directory "/notes.org"))
(define-key global-map "\C-cr" 'org-remember)
(setq org-remember-templates
'(("Todo" ?t "* TODO %?\n %i\n %a" "d:/My Dropbox/mylog/TODO.org"
"Tasks")
("Journal" ?j "* %U %?\n\n %i\n %a" "d:/My Dropbox/mylog/JOURNAL.org")))

(global-font-lock-mode 1)
----

Is there something glaringly obvious that is wrong here?

Best regards,
Helge

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

* Re: add a whole directory as one item to refile targets
  2009-10-08  7:02 ` Carsten Dominik
  2009-10-08  8:17   ` Syntax coloring not automatic Helge A. Gudmundsen
@ 2009-10-10 21:48   ` Eraldo Helal
  2009-10-10 22:06     ` Bernt Hansen
  1 sibling, 1 reply; 11+ messages in thread
From: Eraldo Helal @ 2009-10-10 21:48 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org-Mode

| Carsten: "Please try again."
> Sure :)   ;;sorry about that I happen to have problems explaining...


If I am on a headline in an org-mode buffer and do "C-c C-w" (refile) on it...
...and then press TAB twice. I get a completion list buffer that pops
up and looks somthing like this:

     Possible completions are:
     done.org/    eraldo.org/    inbox.org/

>> showing some files as possible refile targets.

What I would like to have is this:

     Possible completions are:
     done.org/    eraldo.org/    inbox.org/    Reference/

>> showing the same refile targets plus a directory of my choice!


In the meantime I have made some experiments and I could get my
directory(name) listed there...
... however that is not of any use since it does not treat it as a
directory nor as a file ;; very strange stuff ^^

What is the way to go in order to move a headline to a location that
is not listed as a refile target?

>> until now what I did is the following:
open a new emacs buffer and open the desired file in there or create a
new one. ;; C-x C-f
go back to the other buffer. ;; C-x o  //  C-c b  //  C-x b  //  Alt+TAB
fold up the headline. ;; TAB  //  TAB TAB
cut the headline ;; C-k
change buffer again. ;;  C-x o  //  C-c b  //  C-x b  //  Alt+TAB
paste the headline ;; C-y

If there is a better / easier way I would be glad to know :)


Thanks for your patience,
Eraldo

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

* Re: add a whole directory as one item to refile targets
  2009-10-10 21:48   ` add a whole directory as one item to refile targets Eraldo Helal
@ 2009-10-10 22:06     ` Bernt Hansen
  2009-10-12 13:48       ` Eraldo Helal
  0 siblings, 1 reply; 11+ messages in thread
From: Bernt Hansen @ 2009-10-10 22:06 UTC (permalink / raw)
  To: Eraldo Helal; +Cc: Org-Mode, Carsten Dominik

Eraldo Helal <eraldo@eraldo.at> writes:

> If I am on a headline in an org-mode buffer and do "C-c C-w" (refile) on it...
> ...and then press TAB twice. I get a completion list buffer that pops
> up and looks somthing like this:
>
>      Possible completions are:
>      done.org/    eraldo.org/    inbox.org/
>
>>> showing some files as possible refile targets.
>
> What I would like to have is this:
>
>      Possible completions are:
>      done.org/    eraldo.org/    inbox.org/    Reference/
>
>>> showing the same refile targets plus a directory of my choice!

What is Reference/ supposed to be in this case -- a directory?  Refiling
only works to headings (or top level headings) in files in org-mode IIRC.

-Bernt

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

* Re: add a whole directory as one item to refile targets
  2009-10-10 22:06     ` Bernt Hansen
@ 2009-10-12 13:48       ` Eraldo Helal
  2009-10-12 14:15         ` Carsten Dominik
  2009-10-12 16:47         ` Sebastian
  0 siblings, 2 replies; 11+ messages in thread
From: Eraldo Helal @ 2009-10-12 13:48 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: Org-Mode, Carsten Dominik

> What is Reference/ supposed to be in this case -- a directory?  Refiling
> only works to headings (or top level headings) in files in org-mode IIRC.
Yes it is supposed to be a directory...

I have org files in many directorys... about like so:
 reference/emacs/emacs.org
 reference/eros/eros.org
 reference/Avalon/Avalon.org
 reference/Gimp/Gimp.org
 reference/office/office.org
 reference/home/home.org
 reference/poems/poems.org
...

What would be a smart way to get a headline from the file inbox.org
named "* Erich Fried poems" to poems.org?
Considering that poems.org is not part of the agenda nor a refile target.

What I am doing until now is:
 folding the headline (tab)
 cutting the headline (C-k)
 making a split screen (C-x 2)
 changing buffer (C-x o)
 opening poems.org (C-x C-f "reference/poems/poems.org")
 pasting headline (C-y)
 changing buffer (C-x o)
 removing split view (C-x 1)

Poems.org is not part of the agenda because it is reference material
and not an active file.
It is also not a refile target because I would have to make every .org
file in all subdirectories a refile target and sometimes the
appropriate file does not yet exist, in which case I need to create
it.

Any ideas?
Do I need to further try to make clear what I mean?

Greetings,
Eraldo

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

* Re: add a whole directory as one item to refile targets
  2009-10-12 13:48       ` Eraldo Helal
@ 2009-10-12 14:15         ` Carsten Dominik
  2009-10-17 13:19           ` Eraldo Helal
  2009-10-12 16:47         ` Sebastian
  1 sibling, 1 reply; 11+ messages in thread
From: Carsten Dominik @ 2009-10-12 14:15 UTC (permalink / raw)
  To: Eraldo Helal; +Cc: Bernt Hansen, Org-Mode


On Oct 12, 2009, at 3:48 PM, Eraldo Helal wrote:

>> What is Reference/ supposed to be in this case -- a directory?   
>> Refiling
>> only works to headings (or top level headings) in files in org-mode  
>> IIRC.
> Yes it is supposed to be a directory...
>
> I have org files in many directorys... about like so:
> reference/emacs/emacs.org
> reference/eros/eros.org
> reference/Avalon/Avalon.org
> reference/Gimp/Gimp.org
> reference/office/office.org
> reference/home/home.org
> reference/poems/poems.org
> ...
>
> What would be a smart way to get a headline from the file inbox.org
> named "* Erich Fried poems" to poems.org?
> Considering that poems.org is not part of the agenda nor a refile  
> target.

Well, you need to make it a refile target, that is the
whole point of defining refiling targets.

If you want, you can make yourself a special refile function that  
temporarily installs a long list of files in org-refile-targets.  You  
can use `let' to bind
org-refile-targets, and directory-files to get the files.

For example (untested)

(defun my-refile-to-reference ()
   (interactive)
   (let ((org-refile-targets (list (directory-files "~/Reference/  
'full "*.org")
                                   '(:maxlevel . 1))))
      (call-interactively 'org-refile)))

Would offer all top-level headlines in any org files in the ~/ 
Reference directory


HTH

- Carsten

>
> What I am doing until now is:
> folding the headline (tab)
> cutting the headline (C-k)
> making a split screen (C-x 2)
> changing buffer (C-x o)
> opening poems.org (C-x C-f "reference/poems/poems.org")
> pasting headline (C-y)
> changing buffer (C-x o)
> removing split view (C-x 1)
>
> Poems.org is not part of the agenda because it is reference material
> and not an active file.
> It is also not a refile target because I would have to make every .org
> file in all subdirectories a refile target and sometimes the
> appropriate file does not yet exist, in which case I need to create
> it.
>
> Any ideas?
> Do I need to further try to make clear what I mean?
>
> Greetings,
> Eraldo

- Carsten

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

* Re: Re: add a whole directory as one item to refile targets
  2009-10-12 13:48       ` Eraldo Helal
  2009-10-12 14:15         ` Carsten Dominik
@ 2009-10-12 16:47         ` Sebastian
  2009-10-17 10:58           ` Eraldo Helal
  1 sibling, 1 reply; 11+ messages in thread
From: Sebastian @ 2009-10-12 16:47 UTC (permalink / raw)
  To: Eraldo Helal; +Cc: Bernt Hansen, Org-Mode, Carsten Dominik

Am Montag, den 12.10.2009, 15:48 +0200 schrieb Eraldo Helal:
> > What is Reference/ supposed to be in this case -- a directory?  Refiling
> > only works to headings (or top level headings) in files in org-mode IIRC.
> Yes it is supposed to be a directory...
> 
> I have org files in many directorys... about like so:
>  reference/emacs/emacs.org
>  reference/eros/eros.org
>  reference/Avalon/Avalon.org
>  reference/Gimp/Gimp.org
>  reference/office/office.org
>  reference/home/home.org
>  reference/poems/poems.org
> ...
> 
> What would be a smart way to get a headline from the file inbox.org
> named "* Erich Fried poems" to poems.org?
> Considering that poems.org is not part of the agenda nor a refile target.
> 
> What I am doing until now is:
>  folding the headline (tab)
>  cutting the headline (C-k)
>  making a split screen (C-x 2)
>  changing buffer (C-x o)
>  opening poems.org (C-x C-f "reference/poems/poems.org")
>  pasting headline (C-y)
>  changing buffer (C-x o)
>  removing split view (C-x 1)
> 
> Poems.org is not part of the agenda because it is reference material
> and not an active file.
> It is also not a refile target because I would have to make every .org
> file in all subdirectories a refile target and sometimes the
> appropriate file does not yet exist, in which case I need to create
> it.
> 
> Any ideas?
> Do I need to further try to make clear what I mean?
> 
> Greetings,
> Eraldo
> 


Since having so many targets for refiling slows down refiling a lot, I
do this here.


I've set `org-refile-targets' like this (custom-set-variables):

 '(org-refile-targets (quote ((org-agenda-files :maxlevel . 3)
      (sr-org-refile-targets :maxlevel . 2))))



In addition, I have this here in my setup:



(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
expression,
                 do not add it to `sr-org-refile-targets'.
  dir-excludes   Regular expression. If a directory name matches this
regular expression,
                 do not add it to `sr-org-refile-targets'."
  (let ((targets (or dirs (list org-directory)))
        (fex (or file-excludes  "^[#\\.].*$"))
        (dex (or dir-excludes  "^[#\\.].*$"))
        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-match fex f)))
                (setq sr-org-refile-targets (append (list path)
sr-org-refile-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))






Now I call the function `sr-add-to-org-refile-targets' whenever I need
to add all Org-files in a directory recursively.




Sebastian

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

* Re: Re: add a whole directory as one item to refile targets
  2009-10-12 16:47         ` Sebastian
@ 2009-10-17 10:58           ` Eraldo Helal
  2009-10-17 12:59             ` Sebastian
  0 siblings, 1 reply; 11+ messages in thread
From: Eraldo Helal @ 2009-10-17 10:58 UTC (permalink / raw)
  To: sebastian_rose; +Cc: Bernt Hansen, Org-Mode, Carsten Dominik

Thank you very much for sharing this!
That seems to be more than what I need.

A waaay easier solution would be to be able to refile/save a headline
to a non-predefined target.
> just like it is the case with "find file"  (C-x C-f)
in other words: being able to "find a file" to use as refile target
(if it does not exist > create)

Wouldn't that be an awesome option?

Greetings,
Eraldo

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

* Re: Re: add a whole directory as one item to refile targets
  2009-10-17 10:58           ` Eraldo Helal
@ 2009-10-17 12:59             ` Sebastian
  0 siblings, 0 replies; 11+ messages in thread
From: Sebastian @ 2009-10-17 12:59 UTC (permalink / raw)
  To: Eraldo Helal; +Cc: Bernt Hansen, Org-Mode, Carsten Dominik

Am Samstag, den 17.10.2009, 12:58 +0200 schrieb Eraldo Helal:
> Thank you very much for sharing this!
> That seems to be more than what I need.
> 
> A waaay easier solution would be to be able to refile/save a headline
> to a non-predefined target.
> > just like it is the case with "find file"  (C-x C-f)
> in other words: being able to "find a file" to use as refile target
> (if it does not exist > create)
> 
> Wouldn't that be an awesome option?

Yes.
This does so. Note: there's no testing for the '*.org'
extension and writability...



(defun sr-add-file-to-org-refile-targets ( file )
  "Add a single file to org-refile targets. Eventually create it."
  (interactive "FNew refile target: ")
  (when (not (file-exists-p file))
    (access-file file))
  (setq sr-org-refile-targets (append (list file)
sr-org-refile-targets))
  (message "org-refile-targets: \n%s" sr-org-refile-targets))



HTH

   Sebastian

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

* Re: add a whole directory as one item to refile targets
  2009-10-12 14:15         ` Carsten Dominik
@ 2009-10-17 13:19           ` Eraldo Helal
  0 siblings, 0 replies; 11+ messages in thread
From: Eraldo Helal @ 2009-10-17 13:19 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Bernt Hansen, Org-Mode

> For example (untested)
>
> (defun my-refile-to-reference ()
>  (interactive)
>  (let ((org-refile-targets (list (directory-files "~/Reference/ 'full
> "*.org")
>                                  '(:maxlevel . 1))))
>     (call-interactively 'org-refile)))
>
> Would offer all top-level headlines in any org files in the ~/Reference
> directory

"directory-files" only outputs directories but no .org files
therefore with the pattern "*.org" as a filter ... nothing is returned!

But I like the idea a lot!
Should "directory-files" list all files inside a directory?

Greetings,
Eraldo

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

end of thread, other threads:[~2009-10-17 13:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-04 22:30 add a whole directory as one item to refile targets Eraldo Helal
2009-10-08  7:02 ` Carsten Dominik
2009-10-08  8:17   ` Syntax coloring not automatic Helge A. Gudmundsen
2009-10-10 21:48   ` add a whole directory as one item to refile targets Eraldo Helal
2009-10-10 22:06     ` Bernt Hansen
2009-10-12 13:48       ` Eraldo Helal
2009-10-12 14:15         ` Carsten Dominik
2009-10-17 13:19           ` Eraldo Helal
2009-10-12 16:47         ` Sebastian
2009-10-17 10:58           ` Eraldo Helal
2009-10-17 12:59             ` Sebastian

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