emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Org-mode outside Org-mode


From: Samuel Wales
Subject: Re: [O] Org-mode outside Org-mode
Date: Sat, 13 Apr 2013 13:48:56 -0700

Hi Eric,

Here is old not-working not-finished code that I abandoned.  But it
illustrates the goal.

Samuel

===

Maybe something like:

  - In source file, C-c ' to go to Org entry associated with nearest ID marker
    - C-u C-c ' to create ID marker and create its Org entry in your Org file
      - when it is created, you can refile it wherever
  - C-c ' in Org entry to go to associated source file ID marker

;; this is quick and dirty code
;;
;; it is brittle to store a file path.  it is much better to
;; incorporate ID markers into the Org ID system, then Org will
;; find the file using org-id-goto.  to tell the system where you
;; keep your source files, set a variable.
;;
;; doing so will eliminate the need to store a pathname property.
;;
;; maybe this can be refactored with detangling markers.
;;
;; see also annotation, which requires no marker, but is more
;; brittle and does not indicate that you have an annotation.
;; this should be merged with that.
(defconst alpha-org-id-pair-file-property "ID-pair-file")
(defun alpha-org-bounce-id-pair ()
  "The opposite of Org Babel.  C-c ' in source code to document
it in Org.  Same in documentation to go to source code."
  (interactive)
  (let ((id (org-id-get)))
    (if id
        (org-id-goto id)
      (let ((source (org-entry-get nil alpha-org-id-pair-file-property)))
        (find-file source)
        (re-search-forward id)
        (forward-line 1)))))
(defun* alpha-org-bounce-or-insert-id-pair (&key (comment ";; "))
  "Bounce to the other end of, or create, a (notes, ID
marker) pair.

Suppose you are editing an Emacs Lisp source code file.  You can
bounce between a special entry in your Org agenda file
\(e.g. notes.org\) and your external file \(e.g. file.el\)."
  (interactive)
  (let ((id (org-id-new "id-pair")))
    (save-excursion
      (alpha-org-insert-id-marker id :comment comment))
    (org-capture nil)))
(defun* alpha-org-insert-id-marker (id &key comment)
  "Insert an ID marker."
  (insert
   (concat (when comment comment)
           "$[id "
           id
           ;; (when link (concat " :link " link))
           ;; ;; (org-insert-link)
           ;; (when label (concat " :label \"" label "\""))
           "]"))
  (forward-line -1)
  (funcall indent-line-function))

On 4/6/13, Eric Schulte <address@hidden> wrote:
> That could be handy.  For jumping back and for by function name, the
> following simple implementation might be sufficient.  It relies on file
> local variables to know which src and Org-mode files are related to each
> other.

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

The disease DOES progress.  MANY people have died from it.  ANYBODY
can get it.  There is NO hope without action.  This means YOU.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]