emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Girard <girard.nicolas@gmail.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] Allow org-collector to display heading indentation
Date: Fri, 30 Mar 2012 21:43:18 +0200	[thread overview]
Message-ID: <CANMKmee=g5kaSpysLN8hMWmgrqiwW_A2FJds87gPMUsa3zJKHg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1075 bytes --]

Hi all,
attached is a patch which adds a new parameter "indent" to the
propview dynamic bloc, with the following behaviour:

#+BEGIN_SRC org
  ,* Tree
  ,:PROPERTIES:
  ,:COLUMNS: %8ITEM %4prop1 %5prop2
  ,:ID: tree
  ,:END:
  ,** A
  ,:PROPERTIES:
  ,:prop1: 10
  ,:prop2: 20
  ,:END:
  ,*** A1
  ,:PROPERTIES:
  ,:prop1: 15
  ,:prop2: 19
  ,:END:
  ,*** A2
  ,:PROPERTIES:
  ,:prop1: 20
  ,:prop2: 18
  ,:END:
  ,** B
  ,:PROPERTIES:
  ,:prop1: 25
  ,:prop2: 10
  ,:END:
  ,*** B1
  ,:PROPERTIES:
  ,:prop1: 2
  ,:prop2: 4
  ,:END:
  ,*** B2
  ,:PROPERTIES:
  ,:prop1: 3
  ,:prop2: 5
  ,:END:

#+END_SRC

#+BEGIN: propview :id tree :cols (ITEM prop1) :noquote t :indent t
| ITEM   | prop1 |
|--------+-------|
| Tree   |     0 |
| \- A   |    10 |
| \-- A1 |    15 |
| \-- A2 |    20 |
| \- B   |    25 |
| \-- B1 |     2 |
| \-- B2 |     3 |
|--------+-------|
|        |       |
#+END

I wish the indentation to be displayed with nothing but spaces, but
they would be trimmed by org-table guts ; so that's middly satisfying,
but better than nothing :-)

Cheers,

Nicolas

[-- Attachment #2: org-collector.el.diff --]
[-- Type: application/octet-stream, Size: 1816 bytes --]

diff --git a/contrib/lisp/org-collector.el b/contrib/lisp/org-collector.el
index ad198ed..bc9dfae 100644
--- a/contrib/lisp/org-collector.el
+++ b/contrib/lisp/org-collector.el
@@ -121,6 +121,7 @@ preceeding the dblock, then update the contents of the dblock."
 	    (scope (plist-get params :scope))
 	    (noquote (plist-get params :noquote))
 	    (colnames (plist-get params :colnames))
+	    (indent (plist-get params :indent))
 	    (content-lines (org-split-string (plist-get params :content) "\n"))
 	    id table line pos)
 	(save-excursion
@@ -135,7 +136,7 @@ preceeding the dblock, then update the contents of the dblock."
 	  (setq stringformat (if noquote "%s" "%S"))
 	  (setq table (org-propview-to-table
 		       (org-propview-collect cols stringformat conds match scope inherit
-					     (if colnames colnames cols)) stringformat))
+					     (if colnames colnames cols) indent) stringformat))
 	  (widen))
 	(setq pos (point))
 	(when content-lines
@@ -171,13 +172,18 @@ variables and values specified in props"
 		     (when p (cons n p))))
 		 inherit))))
 
-(defun org-propview-collect (cols stringformat &optional conds match scope inherit colnames)
+(defun org-propview-collect (cols stringformat &optional conds match scope inherit colnames indent)
   (interactive)
   ;; collect the properties from every header
   (let* ((header-props
 	  (let ((org-trust-scanner-tags t) alst)
 	    (org-map-entries
-	     (quote (cons (cons "ITEM" (org-get-heading t))
+	     (quote (cons (cons "ITEM" 
+				(let ((item (org-get-heading t))
+				      (level (- (org-current-level) 1)))
+				  (if (and indent (> level 0))
+				      (format "\\%s %s" 
+					      (make-string level ?- ) item) item)))
 			  (org-propview-get-with-inherited inherit)))
 	     match scope)))
 	 ;; read property values

             reply	other threads:[~2012-03-30 19:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <girard.nicolas@gmail.com>
2012-03-30 19:43 ` Nicolas Girard [this message]
2012-03-30 19:52   ` [PATCH] Allow org-collector to display heading indentation Achim Gratz
2012-03-30 19:52   ` Nick Dokos
2012-03-30 20:55     ` Nicolas Girard
2012-03-31  6:57       ` Sebastien Vauban
2012-03-31 23:58         ` Nicolas Girard
2012-03-31 23:59         ` [PATCH 1/2] Simplify org-clocktable-indent-string Nicolas Girard
2012-03-31 23:59           ` [PATCH 2/2] Allow org-collector to display heading indentation by passing ':indent t' to the propview block Nicolas Girard
2012-04-02 16:56             ` Bastien
2012-04-20 11:12             ` Bastien
2012-04-20 11:12           ` [PATCH 1/2] Simplify org-clocktable-indent-string Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANMKmee=g5kaSpysLN8hMWmgrqiwW_A2FJds87gPMUsa3zJKHg@mail.gmail.com' \
    --to=girard.nicolas@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).