From mboxrd@z Thu Jan 1 00:00:00 1970 From: Taru Karttunen Subject: Creating links to ITEMs in captured column views (code attached) Date: Tue, 3 Feb 2009 00:43:40 +0200 Message-ID: <20090202224340.GA6739@taruti.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_courier-21250-1233614621-0001-2" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LU7WR-0006u6-Ih for emacs-orgmode@gnu.org; Mon, 02 Feb 2009 17:44:07 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LU7WR-0006to-0C for emacs-orgmode@gnu.org; Mon, 02 Feb 2009 17:44:07 -0500 Received: from [199.232.76.173] (port=37396 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LU7WQ-0006tk-PJ for emacs-orgmode@gnu.org; Mon, 02 Feb 2009 17:44:06 -0500 Received: from courier.cs.helsinki.fi ([128.214.9.1]:40139 helo=mail.cs.helsinki.fi) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LU7WQ-0007bO-8A for emacs-orgmode@gnu.org; Mon, 02 Feb 2009 17:44:06 -0500 Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org-mode ml This is a MIME-formatted message. If you see this text it means that your E-mail software does not support MIME-formatted messages. --=_courier-21250-1233614621-0001-2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 --=_courier-21250-1233614621-0001-2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ex.org" #+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: --=_courier-21250-1233614621-0001-2 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --=_courier-21250-1233614621-0001-2--