emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-collector: enable specifying a default table-value as a parameter
@ 2013-11-13  3:02 Mark Edgington
  2013-11-13  8:58 ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Edgington @ 2013-11-13  3:02 UTC (permalink / raw)
  To: emacs-orgmode

Currently there isn't an easy way to have default cell values which 
differ from one propview block to another.  This patch enables one to 
specify what a cell's default value for a block should be.  For example, 
with this patch applied, you can do something like:

     #+BEGIN: propview :id " mytable" :defaultval "" :cols (PROP1 PROP2 
PROP3)

in order to make the default value for this block to be "" instead of 0.

* contrib/lisp/org-collector.el (org-dblock-write:propview): if a 
'defaultval'
   property has been set, then use this in place of 
org-propview-default-value.

TINYCHANGE
---
  contrib/lisp/org-collector.el | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/contrib/lisp/org-collector.el b/contrib/lisp/org-collector.el
index 60b9069..d62a462 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))
+           (defaultval (plist-get params :defaultval))
             (content-lines (org-split-string (plist-get params 
:content) "\n"))
             id table line pos)
         (save-excursion
@@ -133,9 +134,10 @@ preceeding the dblock, then update the contents of 
the dblock."
                   (t (error "Cannot find entry with :ID: %s" id))))
           (unless (eq id 'global) (org-narrow-to-subtree))
           (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))
+         (let ((org-propview-default-value (if defaultval defaultval 
org-propview-default-value)))
+           (setq table (org-propview-to-table
+                        (org-propview-collect cols stringformat conds 
match scope inherit
+                                              (if colnames colnames 
cols)) stringformat)))
           (widen))
         (setq pos (point))
         (when content-lines

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] org-collector: enable specifying a default table-value as a parameter
  2013-11-13  3:02 Mark Edgington
@ 2013-11-13  8:58 ` Bastien
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien @ 2013-11-13  8:58 UTC (permalink / raw)
  To: Mark Edgington; +Cc: emacs-orgmode

Hi Mark,

the patch is unreadable -- can you resend it as an attachment?

Thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] org-collector: enable specifying a default table-value as a parameter
@ 2013-11-13 12:32 Mark Edgington
  2013-11-13 12:51 ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Edgington @ 2013-11-13 12:32 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi Bastien,

Sorry about the formatting -- that's annoying.  I've attached the patch. 
  Here's its description:

Currently there isn't an easy way to have default cell values which 
differ from one propview block to another.  This patch enables one to 
specify what a cell's default value for a block should be.  For example, 
with this patch applied, you can do something like:

     #+BEGIN: propview :id " mytable" :defaultval "" :cols (PROP1 PROP2)

in order to make the default value for this block to be "" instead of 0 
in the case that PROP1 or PROP2 isn't contained as a property of a headline.

Regards,

Mark

[-- Attachment #2: org-collector-enable-default-table-value.patch --]
[-- Type: text/x-patch, Size: 1556 bytes --]

* contrib/lisp/org-collector.el (org-dblock-write:propview): if a 'defaultval'
  property has been set, then use this in place of org-propview-default-value.

TINYCHANGE
---
 contrib/lisp/org-collector.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/contrib/lisp/org-collector.el b/contrib/lisp/org-collector.el
index 60b9069..d62a462 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))
+	    (defaultval (plist-get params :defaultval))
 	    (content-lines (org-split-string (plist-get params :content) "\n"))
 	    id table line pos)
 	(save-excursion
@@ -133,9 +134,10 @@ preceeding the dblock, then update the contents of the dblock."
 		  (t (error "Cannot find entry with :ID: %s" id))))
 	  (unless (eq id 'global) (org-narrow-to-subtree))
 	  (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))
+	  (let ((org-propview-default-value (if defaultval defaultval org-propview-default-value)))
+	    (setq table (org-propview-to-table
+			 (org-propview-collect cols stringformat conds match scope inherit
+					       (if colnames colnames cols)) stringformat)))
 	  (widen))
 	(setq pos (point))
 	(when content-lines

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] org-collector: enable specifying a default table-value as a parameter
  2013-11-13 12:32 [PATCH] org-collector: enable specifying a default table-value as a parameter Mark Edgington
@ 2013-11-13 12:51 ` Bastien
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien @ 2013-11-13 12:51 UTC (permalink / raw)
  To: Mark Edgington; +Cc: emacs-orgmode

Hi Mark,

Mark Edgington <edgimar@gmail.com> writes:

> Currently there isn't an easy way to have default cell values which 
> differ from one propview block to another.  This patch enables one to 
> specify what a cell's default value for a block should be.  For example, 
> with this patch applied, you can do something like:
>
>      #+BEGIN: propview :id " mytable" :defaultval "" :cols (PROP1 PROP2)
>
> in order to make the default value for this block to be "" instead of 0 
> in the case that PROP1 or PROP2 isn't contained as a property of a headline.

Applied in master, thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-13 13:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 12:32 [PATCH] org-collector: enable specifying a default table-value as a parameter Mark Edgington
2013-11-13 12:51 ` Bastien
  -- strict thread matches above, loose matches on Subject: below --
2013-11-13  3:02 Mark Edgington
2013-11-13  8:58 ` Bastien

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).