org-wiki icon indicating copy to clipboard operation
org-wiki copied to clipboard

use org-ids for linking wiki files

Open kiuuik opened this issue 8 years ago • 2 comments

At the moment I use org-ids for my links so that later I can freely adjust my headlines and file locations. I have about 1 million words among 250 files and everything works as expected.

I like the features of org-wiki and have tried it out for a while but I haven't found a way to use wiki-links with org-ids. Is that possible? Did I miss something obvious?

Thanks for this useful software.

PS: Do you know these essays about personal wikis in general http://connectedtext.com/manfred.php and http://luhmann.surge.sh/communicating-with-slip-boxes ? I thought they were quite interesting.

kiuuik avatar Feb 06 '17 23:02 kiuuik

Do you mean using search options in file links? You could replicate the behavior of wiki:keyword links by changing org-wiki--open-page to:

(defun org-wiki--open-page (pagename_section)
  "Open or create new a org-wiki page (PAGENAME) by name.
Example:  (org-wiki--open-page \"Linux\")
Will open the the wiki file Linux.org in
`org-wiki-location`"
  (let* ((pagename (car (split-string pagename_section "::")))
	 (section (car (cdr (split-string pagename_section "::"))))
	 (org-wiki-file (org-wiki--page->file pagename))
	)
    (if (not (file-exists-p org-wiki-file))
        ;; Action executed if file doesn't exist.
        (progn (find-file  org-wiki-file)
               ;; Insert header at top of page
               (org-wiki-header)
               ;; Save current page buffer
               (save-buffer)
               ;; Create assets directory
               (org-wiki--assets-make-dir pagename))

      ;; Action executed if file exists.
      (if org-wiki-default-read-only
          ;; open file in read-only mode. 
          (progn  (org-open-file org-wiki-file t nil section)
                  (read-only-mode 1))
          ;; open file in writable mode. 
	  (org-open-file org-wiki-file t nil section))
        ))) 

this would allow links like

wiki:file
wiki:file::#custom_id
[[wiki:file::*section name]]

ayyess avatar Feb 10 '18 09:02 ayyess

thank you very much for your answer. This is still an unsolved problem for me.

I was thinking of External Links using IDs like [[id:B7423F4D-2E8A-471B-8810-C40F074717E9][Link to heading by ID]]. This allows me to rename the file that contains the target heading without breaking the link. The search options you linked to don't allow for changed file names as far as I can see.

I thought that offering to use IDs would require modifications at many different parts of org-wiki (for the index, etc.) so that I didn't even try to change a function to jump to a different wiki heading.

kiuuik avatar Feb 10 '18 12:02 kiuuik