* [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert. @ 2008-05-05 1:54 Jason Riedy 2008-05-05 1:54 ` [PATCH 1/4] Provide an *orgtbl-default-fmt* for entries not in a fmt plist Jason Riedy 2008-05-05 5:15 ` [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert Carsten Dominik 0 siblings, 2 replies; 7+ messages in thread From: Jason Riedy @ 2008-05-05 1:54 UTC (permalink / raw) To: emacs-orgmode; +Cc: Jason Riedy I needed an orgtbl-to-orgtbl transformation when writing up transformation examples. It seems pretty core, so I've added it to org-table.el. The function needs a way to suppress :tstart and :tend strings, so I added support for explicit nils. Cleaning up the orgtbl-to-sqlinsert function lead to some cute little problems. One was that formatting columns with plist would pass values through directly rather than quoting them. So I a general *orgtbl-default-fmt* variable to handle all columns that aren't in the plist. A similar one for the header might be useful, but I haven't needed it. All these can be pulled from git://repo.or.cz/org-mode/ejr.git master BTW, Bruno Haible's git ChangeLog merger has been working wonderfully for me. It also is in gnulib; see the message for how to generate it with gnulib-tool: http://article.gmane.org/gmane.comp.lib.gnulib.bugs/12653 Jason Riedy (4): Provide an *orgtbl-default-fmt* for entries not in a fmt plist. Allow an explicitly nil :tstart and :tend to suppress the strings. Add an orgtbl-to-orgtbl transformation. Clean up orgtbl-sqlinsert. ChangeLog | 10 ++++++++++ contrib/ChangeLog | 7 +++++++ contrib/lisp/orgtbl-sqlinsert.el | 13 +++++++------ lisp/org-table.el | 33 ++++++++++++++++++++++++++++----- 4 files changed, 52 insertions(+), 11 deletions(-) ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/4] Provide an *orgtbl-default-fmt* for entries not in a fmt plist. 2008-05-05 1:54 [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert Jason Riedy @ 2008-05-05 1:54 ` Jason Riedy 2008-05-05 1:54 ` [PATCH 2/4] Allow an explicitly nil :tstart and :tend to suppress the strings Jason Riedy 2008-05-05 5:15 ` [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert Carsten Dominik 1 sibling, 1 reply; 7+ messages in thread From: Jason Riedy @ 2008-05-05 1:54 UTC (permalink / raw) To: emacs-orgmode; +Cc: Jason Riedy The *orgtbl-default-fmt* is a hook for orgtbl transformations to ensure a destination-sensible default for columns not present in a fmt plist. The leaving the value at nil changes no existing behavior. Signed-off-by: Jason Riedy <jason@acm.org> --- ChangeLog | 6 ++++++ lisp/org-table.el | 5 ++++- 2 files changed, 10 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index 15c9602..69710ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-04 Jason Riedy <jason@acm.org> + + * lisp/org-table.el (*orgtbl-default-fmt*): New variable. + (orgtbl-format-line): Use the value of *orgtbl-default-fmt* + when there is no other fmt available. + 2008-05-02 Carsten Dominik <dominik@science.uva.nl> * lisp/org.el (org-read-date-analyze): "." as an alias for "+0" in diff --git a/lisp/org-table.el b/lisp/org-table.el index ef1d932..17441cd 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -3631,6 +3631,7 @@ First element has index 0, or I0 if given." ;; Formatting parameters for the current table section. (defvar *orgtbl-hline* nil "Text used for horizontal lines") (defvar *orgtbl-sep* nil "Text used as a column separator") +(defvar *orgtbl-default-fmt* nil "Default format for each entry") (defvar *orgtbl-fmt* nil "Format for each entry") (defvar *orgtbl-efmt* nil "Format for numbers") (defvar *orgtbl-lfmt* nil "Format for an entire line, overrides fmt") @@ -3672,7 +3673,9 @@ First element has index 0, or I0 if given." (orgtbl-apply-fmt efmt (match-string 1 f) (match-string 2 f)) f))) - (orgtbl-apply-fmt (orgtbl-get-fmt *orgtbl-fmt* i) f))) + (orgtbl-apply-fmt (or (orgtbl-get-fmt *orgtbl-fmt* i) + *orgtbl-default-fmt*) + f))) line))) (push (if *orgtbl-lfmt* (orgtbl-apply-fmt *orgtbl-lfmt* line) -- 1.5.5.rc1.121.g1594 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] Allow an explicitly nil :tstart and :tend to suppress the strings. 2008-05-05 1:54 ` [PATCH 1/4] Provide an *orgtbl-default-fmt* for entries not in a fmt plist Jason Riedy @ 2008-05-05 1:54 ` Jason Riedy 2008-05-05 1:54 ` [PATCH 3/4] Add an orgtbl-to-orgtbl transformation Jason Riedy 0 siblings, 1 reply; 7+ messages in thread From: Jason Riedy @ 2008-05-05 1:54 UTC (permalink / raw) To: emacs-orgmode; +Cc: Jason Riedy Passing explicit nils to leave out start and end strings feels natural. Also, transforming org-mode tables into other org-mode tables can use :tstart and :tend to specify directives, so I don't want to change the default splice setting for those. Signed-off-by: Jason Riedy <jason@acm.org> --- ChangeLog | 2 ++ lisp/org-table.el | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 69710ec..d70bc98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ * lisp/org-table.el (*orgtbl-default-fmt*): New variable. (orgtbl-format-line): Use the value of *orgtbl-default-fmt* when there is no other fmt available. + (orgtbl-to-generic): Allow an explicitly nil :tstart or + :tend to suppress the appropriate string. 2008-05-02 Carsten Dominik <dominik@science.uva.nl> diff --git a/lisp/org-table.el b/lisp/org-table.el index 17441cd..19dd74a 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -3773,8 +3773,10 @@ directly by `orgtbl-send-table'. See manual." ;; Put header (unless splicep - (push (or (orgtbl-eval-str (plist-get params :tstart)) - "ERROR: no :tstart") *orgtbl-rtn*)) + (if (not (plist-member params :tstart)) + (push "ERROR: no :tstart" *orgtbl-rtn*) + (let ((tstart (orgtbl-eval-str (plist-get params :tstart)))) + (if tstart (push tstart *orgtbl-rtn*))))) ;; Do we have a heading section? If so, format it and handle the ;; trailing hline. @@ -3801,8 +3803,10 @@ directly by `orgtbl-send-table'. See manual." (orgtbl-format-section nil) (unless splicep - (push (or (orgtbl-eval-str (plist-get params :tend)) - "ERROR: no :tend") *orgtbl-rtn*)) + (if (not (plist-member params :tend)) + (push "ERROR: no :tend" *orgtbl-rtn*) + (let ((tend (orgtbl-eval-str (plist-get params :tend)))) + (if tend (push tend *orgtbl-rtn*))))) (mapconcat 'identity (nreverse (if remove-nil-linesp (remq nil *orgtbl-rtn*) -- 1.5.5.rc1.121.g1594 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] Add an orgtbl-to-orgtbl transformation. 2008-05-05 1:54 ` [PATCH 2/4] Allow an explicitly nil :tstart and :tend to suppress the strings Jason Riedy @ 2008-05-05 1:54 ` Jason Riedy 2008-05-05 1:54 ` [PATCH 4/4] Clean up orgtbl-sqlinsert Jason Riedy 0 siblings, 1 reply; 7+ messages in thread From: Jason Riedy @ 2008-05-05 1:54 UTC (permalink / raw) To: emacs-orgmode; +Cc: Jason Riedy Useful for documenting orgtbl transformation and formatting functions. Signed-off-by: Jason Riedy <jason@acm.org> --- ChangeLog | 2 ++ lisp/org-table.el | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index d70bc98..d8f1a3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ when there is no other fmt available. (orgtbl-to-generic): Allow an explicitly nil :tstart or :tend to suppress the appropriate string. + (orgtbl-to-orgtbl): New function for translating to another orgtbl + table. 2008-05-02 Carsten Dominik <dominik@science.uva.nl> diff --git a/lisp/org-table.el b/lisp/org-table.el index 19dd74a..af12a4c 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -3917,6 +3917,22 @@ this function is called." :hlstart "@headitem "))) (orgtbl-to-generic table (org-combine-plists params2 params)))) +(defun orgtbl-to-orgtbl (table params) + "Convert the orgtbl-mode TABLE into another orgtbl-mode table. +Useful when slicing one table into many. The :hline, :sep, +:lstart, and :lend provide orgtbl framing. The default nil :tstart +and :tend suppress strings without splicing; they can be set to +provide ORGTBL directives for the generated table." + (let* ((params2 + (list + :tstart nil :tend nil + :hline "|---" + :sep " | " + :lstart "| " + :lend " |")) + (params (org-combine-plists params2 params))) + (orgtbl-to-generic table params))) + (provide 'org-table) ;; arch-tag: 4d21cfdd-0268-440a-84b0-09237a0fe0ef -- 1.5.5.rc1.121.g1594 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] Clean up orgtbl-sqlinsert. 2008-05-05 1:54 ` [PATCH 3/4] Add an orgtbl-to-orgtbl transformation Jason Riedy @ 2008-05-05 1:54 ` Jason Riedy 0 siblings, 0 replies; 7+ messages in thread From: Jason Riedy @ 2008-05-05 1:54 UTC (permalink / raw) To: emacs-orgmode; +Cc: Jason Riedy Use the default fmt function, collect only the first header line for field names, and don't call plist-get for the table name on every line. Signed-off-by: Jason Riedy <jason@acm.org> --- contrib/ChangeLog | 7 +++++++ contrib/lisp/orgtbl-sqlinsert.el | 13 +++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/contrib/ChangeLog b/contrib/ChangeLog index 5db4bb3..85a7a27 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,10 @@ +2008-05-04 Jason Riedy <jason@acm.org> + + * lisp/orgtbl-sqlinsert.el (orgtbl-to-sqlinsert): Use the + default fmt function, collect only the first header line for + field names, and don't call plist-get for the table name on + every line. + 2008-04-15 Jason Riedy <jason@acm.org> * lisp/orgtbl-sqlinsert.el: New file. diff --git a/contrib/lisp/orgtbl-sqlinsert.el b/contrib/lisp/orgtbl-sqlinsert.el index 869f74f..648e44c 100644 --- a/contrib/lisp/orgtbl-sqlinsert.el +++ b/contrib/lisp/orgtbl-sqlinsert.el @@ -64,6 +64,8 @@ this function is called." org-table-last-alignment "")) (nowebname (plist-get params :nowebname)) (breakvals (plist-get params :breakvals)) + (firstheader t) + (*orgtbl-default-fmt* 'orgtbl-sql-strip-and-quote) (params2 (list :sqlname name @@ -72,12 +74,10 @@ this function is called." "") "BEGIN TRANSACTION;")) :tend (lambda () (concat "COMMIT;" (if nowebname "\n@ " ""))) - :fmt (lambda (str) (orgtbl-sql-strip-and-quote str)) -; :hfmt (lambda (f) (push (concat "[" f "]") hdrlist) "") - :hfmt (lambda (f) (push f hdrlist) "") - :hlfmt (lambda (lst) nil) + :hfmt (lambda (f) (progn (if firstheader (push f hdrlist)) "")) + :hlfmt (lambda (lst) (setq firstheader nil)) :lstart (lambda () (concat "INSERT INTO " - (plist-get params :sqlname) "( " + sqlname "( " (mapconcat 'identity (reverse hdrlist) ", ") " )" (if breakvals "\n" " ") @@ -86,7 +86,8 @@ this function is called." :sep " , " :hline nil :remove-nil-lines t)) - (params (org-combine-plists params2 params))) + (params (org-combine-plists params2 params)) + (sqlname (plist-get params :sqlname))) (orgtbl-to-generic table params))) (defun orgtbl-sql-quote (str) -- 1.5.5.rc1.121.g1594 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert. 2008-05-05 1:54 [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert Jason Riedy 2008-05-05 1:54 ` [PATCH 1/4] Provide an *orgtbl-default-fmt* for entries not in a fmt plist Jason Riedy @ 2008-05-05 5:15 ` Carsten Dominik 2008-05-05 6:34 ` Jason Riedy 1 sibling, 1 reply; 7+ messages in thread From: Carsten Dominik @ 2008-05-05 5:15 UTC (permalink / raw) To: Jason Riedy; +Cc: emacs-orgmode Hi Jason, On May 5, 2008, at 3:54 AM, Jason Riedy wrote: > I needed an orgtbl-to-orgtbl transformation when writing up > transformation examples. It seems pretty core, so I've > added it to org-table.el. The function needs a way to > suppress :tstart and :tend strings, so I added support > for explicit nils. > > Cleaning up the orgtbl-to-sqlinsert function lead to some cute > little problems. One was that formatting columns with plist > would pass values through directly rather than quoting them. > So I a general *orgtbl-default-fmt* variable to handle all > columns that aren't in the plist. A similar one for the header > might be useful, but I haven't needed it. > > All these can be pulled from > git://repo.or.cz/org-mode/ejr.git master Can you explain to step by step what I would have to do to pull these changes from your repository into a local branch in my own repository? Thanks. - Carsten > > > BTW, Bruno Haible's git ChangeLog merger has been working > wonderfully for me. It also is in gnulib; see the message > for how to generate it with gnulib-tool: > http://article.gmane.org/gmane.comp.lib.gnulib.bugs/12653 > > Jason Riedy (4): > Provide an *orgtbl-default-fmt* for entries not in a fmt plist. > Allow an explicitly nil :tstart and :tend to suppress the strings. > Add an orgtbl-to-orgtbl transformation. > Clean up orgtbl-sqlinsert. > > ChangeLog | 10 ++++++++++ > contrib/ChangeLog | 7 +++++++ > contrib/lisp/orgtbl-sqlinsert.el | 13 +++++++------ > lisp/org-table.el | 33 +++++++++++++++++++++++++++ > +----- > 4 files changed, 52 insertions(+), 11 deletions(-) > > > > _______________________________________________ > 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert. 2008-05-05 5:15 ` [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert Carsten Dominik @ 2008-05-05 6:34 ` Jason Riedy 0 siblings, 0 replies; 7+ messages in thread From: Jason Riedy @ 2008-05-05 6:34 UTC (permalink / raw) To: Carsten Dominik; +Cc: emacs-orgmode And Carsten Dominik writes: >> git://repo.or.cz/org-mode/ejr.git master > > Can you explain to step by step what I would have to do to > pull these changes from your repository into a local branch in my own > repository? Thanks. One long-term version is to add that repo as a named remote: git remote add ejr git://repo.or.cz/org-mode/ejr.git Then you can update all your remotes in one go: git remote update Or just grab one: git fetch ejr If you want to remove that remote repo later, use git remote rm ejr After fetching, git branch -r should list the remote branches, including ejr/master, or git branch -a lists all of the branches. A short-term version is just git fetch git://repo.or.cz/org-mode/ejr.git master:refs/heads/ejr-tmp to slurp it into a local ejr-tmp branch. The typical git branch -D ejr-tmp would delete that branch. Note that for deleting branches added via git remote, you need to pass -r to git branch as well. The command git log -p --stat --color ..ejr/master should give a pretty, colorized listing of the changes in ejr/master and not in your current index. Just git diff --color ..ejr/master should give a colorized diff between your index and ejr/master. You can base those off HEAD, i.e. HEAD..ejr/master, to see the differences between your currently committed work and the named branch (ejr/master). The difference between HEAD and your current (unnamed) index only matters if you've added changes to your index explicitly (through git add) or implicitly (through a partial merge). The "OUTPUT FORMAT" section of git-diff's man page (conveniently also available as git diff --help) gives a list of which sub-commands provide which diffs, in case you feel like poking around to get a feel for how each level works. Many of these work in various forms through Emacs and eshell, but I admit I rarely use them directly from Emacs. And git has many more, newer gadgets that may be nicer. The few simple tools fit how I think well enough that I kinda stopped following the improvements. As an alternate method not using remotes, you could just save the patches to an mbox (say ejr-silly-patches.mbox), create a branch, then use git am ejr-silly-patches.mbox to import the patches. Some people prefer that method, and it can make replying with corrections and requests a bit easier if your mail reader can poke around individual mbox files. And to save some digging in man pages and annoyance in the future, applying a patch that adds files is easiest with git apply --index foo.patch That option will add the changes, including new files, to the index directly. Then to see the differences before committing, you need git diff HEAD. Just using git apply does not update the index and hence won't include the new files automatically, so you'd need to find them and add them. Jason ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-05-05 6:34 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-05-05 1:54 [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert Jason Riedy 2008-05-05 1:54 ` [PATCH 1/4] Provide an *orgtbl-default-fmt* for entries not in a fmt plist Jason Riedy 2008-05-05 1:54 ` [PATCH 2/4] Allow an explicitly nil :tstart and :tend to suppress the strings Jason Riedy 2008-05-05 1:54 ` [PATCH 3/4] Add an orgtbl-to-orgtbl transformation Jason Riedy 2008-05-05 1:54 ` [PATCH 4/4] Clean up orgtbl-sqlinsert Jason Riedy 2008-05-05 5:15 ` [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert Carsten Dominik 2008-05-05 6:34 ` Jason Riedy
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.