Hello
I was using a captured column view to display some properties
and wanted the ITEMs to be displayed as nice links to the
proper destinations.
The code has two purposes:
+ to number items according to their heading number in export (dirty)
+ to create links to the headings
Attached is an org-mode file that contains an example on how
it is used and the elisp code.
- Taru Karttunen
#+TITLE: Captured column view item links
#+OPTIONS: toc:nil
#+COLUMNS: %25ITEM(Item) %10Foo{+} %ID
* Captured column view item links
I was using a captured column view to display some properties
and wanted the items to be displayed as nice links.
Here is the result of a quick hacking session for the list archives.
*** ITEMs are numbered with heading numbers (dirty)
*** ITEMs are linked with a heading link or link to the id if it exists
* Elisp
:PROPERTIES:
:Foo: bar
:ID: cd40863f-6980-406c-8501-29fdd3f170cb
:END:
#+BEGIN_SRC emacs-lisp
(defvar taruti-org-hc '())
(defun taruti-org-hlist (string id)
(labels ((taruti-inc-last (l) (let* ((rl (reverse l)))
(setcar rl (+ 1 (car rl)))
(reverse rl)))
(taruti-org-hc-f (m)
(let* ((nl (if org-odd-levels-only (/ (+ 1 (length
m)) 2) (length m)))
(ol (length taruti-org-hc)))
(setq taruti-org-hc
(if (> nl ol)
(append taruti-org-hc '(1))
(taruti-inc-last (subseq taruti-org-hc 0
nl))))
(apply 'concat (mapcar (lambda (e) (format "%d."
e)) taruti-org-hc)))))
(when (string-match "\\(\\*+\\) \\(.+\\)" string)
(let ((m1 (substring string (match-beginning 1) (match-end 1)))
(m2 (substring string (match-beginning 2) (match-end 2))))
(if (zerop (length id))
(concat "[[*" m2 "][" (taruti-org-hc-f m1) " " m2 "]]")
(concat "[[id:" id "][" (taruti-org-hc-f m1) " " m2 "]]"))))))
(defun taruti-org-hlist-reset (x) (setq taruti-org-hc '()) x)
(taruti-org-hlist "** Foobar")
#+END_SRC
* Output
#+BEGIN: columnview :hlines 1 :id global
| Item | Foo | |
|------------------------------------+-----+---|
| [[*Captured column view item links][1. Captured column view item links]] |
| |
|------------------------------------+-----+---|
| [[id:cd40863f-6980-406c-8501-29fdd3f170cb][2. Elisp]]
| bar | |
|------------------------------------+-----+---|
| [[*Output][3. Output]] | | |
#+TBLFM: @1$1='(taruti-org-hlist-reset
$1)::@1$3='(concat)::$1='(taruti-org-hlist $1 $3)::$3='(concat)
#+END:
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-orgmode