John, this is superb!

thx so much it answers all my needs, what a great find :)

kind regards

Z

On Sat, Aug 1, 2015 at 7:33 PM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
(helm-org-agenda-files-headings) seems to do this already for all
headlines in your agenda files. the third action is to insert a link to
the selected headline.

You can use let to temporarily define the org-agenda-files list to what
you want, and just use the (helm-org-agenda-files-headings) command for
non-agenda files.

e.g.

#+BEGIN_SRC emacs-lisp
(defun insert-heading-link (dir)
  "select a headline from org-files in dir and insert a link to it."
  (interactive  (list (read-directory-name "Directory: ")))
  (let ((org-agenda-files (f-entries
                           dir
                           (lambda (f)
                             (string=
                              "org"
                              (file-name-extension f)))
                           t)))
    (helm-org-agenda-files-headings)))
#+END_SRC

gives me a helm buffer to select headlines from org-files in the
directory I select and when I press f3 (for the third
action), it inserts a link to the selected headline. It does the file
finding recursively, so you might not want to run this on /  ;)

You could bind it to a key for easy use.

Xebar Saram writes:

> Thx so much Bernhard
>
> this looks really promising. i never had luck with either company or
> auto-complete t o get it to work reliably (it often stops working even
> though its still in the mod bar).
> anyway i tried it and added this to my config (after cloning from git):
>
> (add-to-list 'load-path "/home/zeltak/.emacs.g/company-org-headings")
> (add-hook 'org-mode-hook
>  (lambda () (set (make-local-variable 'company-backends)
>     '((company-org-headings)))))
>
> i dont see it completes on org heading, is there any keys i need to press
> or anything else in need to config? does this work only when you try to
> insert a link?
>
> best and thx so much, this look awesome
>
> P.S have you considered Helm for this as well?
>
> best
>
> Z
>
>
>
> On Sat, Aug 1, 2015 at 12:07 PM, Bernhard Pröll <bmutbuerger@gmail.com>
> wrote:
>
>> Hi Saram,
>>
>> I've been in the same boat and decided to write a company-backend for
>> this purpose. So if you're already using company-mode, this may be worth
>> looking into:
>>
>> https://github.com/mutbuerger/company-org-headings
>>
>> Keep in mind that I'm in the process of learning Elisp and
>> there has been little to no testing done on the package. Furthermore it
>> uses org-store-link instead of org-id-store-link.
>>
>> Regards,
>> Bernhard Pröll
>>
>>
>> On Fri, 31. Jul 09:43, Xebar Saram wrote:
>>
>>> i also have a similar workflow and would love to hear Dominic if you
>>> found a
>>> solution for this or if anyone on the list has other suggestions?
>>>
>>> best
>>>
>>> Z
>>>
>>> On Tue, May 12, 2015 at 10:57 PM, Dominic Surano <sk8ingdom@gmail.com>
>>> wrote:
>>>
>>>    Hello,
>>>
>>>    I use org-mode a lot like a wiki so links to other org-mode headings
>>> are
>>>    very common. Currently, I navigate to the heading or pull it up in an
>>>    agenda view, store the link with C-l, going back to where I want to
>>>    insert the link, then insert the link with C-c C-l RET. This is a bit
>>>    time consuming.
>>>
>>>    Instead, I would prefer to map a key that allows me to insert a link at
>>>    the current point using tab completion similar to org-refile (C-c C-w).
>>>    Looking through org-id.el, it seems like org-id-get-with-outline-path
>>>    completion was designed for this purpose. I tried:
>>>
>>>    (global-set-key "\C-ci" (lambda () (interactive) (org-id-get-with
>>>    outline-path-completion)))
>>>
>>>    but it didn't work as intended. Anyone have any ideas?
>>>
>>>    Thanks!
>>>    -D
>>>
>>>    For reference, I have the following set in my configuration:
>>>
>>>    ;; Use global IDs
>>>    (require 'org-id)
>>>    (setq org-id-link-to-org-use-id t)
>>>
>>>    ;; Update ID file .org-id-locations on startup
>>>    (org-id-update-id-locations)
>>>
>>>    ;; Targets include this file and any file contributing to the agenda -
>>>    up to 9 levels deep
>>>    (setq org-refile-targets (quote ((nil :maxlevel . 9)
>>>                                     (org-agenda-files :maxlevel . 9))))
>>>    (setq org-refile-use-outline-path 'file)
>>>    (setq org-outline-path-complete-in-steps t)
>>>    (setq org-refile-allow-creating-parent-nodes t)
>>>
>>>
>>>
>>>
>>>

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu