mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 18:36:26 +00:00
DONE ensure that table ranges work
This commit is contained in:
parent
b8ecf9596b
commit
f2c334b30d
|
@ -80,30 +80,33 @@ emacs-lisp representation of the value of the variable."
|
||||||
assignment is a literal value or is a reference to some external
|
assignment is a literal value or is a reference to some external
|
||||||
resource. If REF is literal then return it's value, otherwise
|
resource. If REF is literal then return it's value, otherwise
|
||||||
return nil."
|
return nil."
|
||||||
(let ((out (string-to-number ref)))
|
(let ((out (litorgy-read ref)))
|
||||||
(if (or (not (equal out 0)) (string-match "^[ \f\t\n\r\v]*0\\.?0?[ \f\t\n\r\v]*$" ref))
|
(if (equal out ref)
|
||||||
out ;; number
|
(if (string-match "\"\\(.+\\)\"" ref)
|
||||||
(if (string-match "\"\\(.+\\)\"" ref) (read ref) ;; string
|
(read ref))
|
||||||
nil)))) ;; reference
|
out)))
|
||||||
|
|
||||||
(defun litorgy-ref-resolve-reference (ref)
|
(defun litorgy-ref-resolve-reference (ref)
|
||||||
"Resolve the reference and return it's value"
|
"Resolve the reference and return it's value"
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((case-fold-search t)
|
(let ((case-fold-search t)
|
||||||
type args new-ref result)
|
type args new-refere new-referent result)
|
||||||
;; assign any arguments to pass to source block
|
;; assign any arguments to pass to source block
|
||||||
(when (string-match "\\(.+\\)\(\\(.*\\)\)" ref)
|
(when (string-match "^\\(.+?\\)\(\\(.*\\)\)$" ref)
|
||||||
(save-match-data
|
(setq new-refere (match-string 1 ref))
|
||||||
(if (> (length (match-string 2)) 0)
|
(setq new-referent (match-string 2 ref))
|
||||||
|
;; (message (format "first second %S -- %S" new-refere new-referent)) ;; debugging
|
||||||
|
(when (> (length new-refere) 0)
|
||||||
|
(if (> (length new-referent) 0)
|
||||||
(setq args (mapcar (lambda (ref) (cons :var ref))
|
(setq args (mapcar (lambda (ref) (cons :var ref))
|
||||||
(split-string (match-string 2 ref) ",[ \f\t\n\r\v]*")))))
|
(split-string new-referent ",[ \f\t\n\r\v]*"))))
|
||||||
(setq ref (match-string 1 ref)))
|
(setq ref new-refere)))
|
||||||
(when (string-match "\\(.+\\):\\(.+\\)" ref)
|
(when (string-match "\\(.+\\):\\(.+\\)" ref)
|
||||||
(find-file (match-string 1 ref))
|
(find-file (match-string 1 ref))
|
||||||
(setf ref (match-string 2 ref)))
|
(setf ref (match-string 2 ref)))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(unless (let ((result_regexp (concat "^#\\+\\(TBL\\|RES\\)NAME:[ \t]*"
|
(unless (let ((result_regexp (concat "^#\\+\\(TBL\\|RES\\)NAME:[ \t]*"
|
||||||
(regexp-quote ref) "[ \t]*$"))
|
(regexp-quote ref) "[ \t]*$"))
|
||||||
(regexp (concat "^#\\+SRCNAME:[ \t]*"
|
(regexp (concat "^#\\+SRCNAME:[ \t]*"
|
||||||
(regexp-quote ref) "[ \t]*$")))
|
(regexp-quote ref) "[ \t]*$")))
|
||||||
(or (re-search-forward result_regexp nil t)
|
(or (re-search-forward result_regexp nil t)
|
||||||
|
|
40
rorg.org
40
rorg.org
|
@ -3,7 +3,7 @@
|
||||||
#+SEQ_TODO: TODO PROPOSED | DONE DEFERRED REJECTED
|
#+SEQ_TODO: TODO PROPOSED | DONE DEFERRED REJECTED
|
||||||
#+STARTUP: oddeven
|
#+STARTUP: oddeven
|
||||||
|
|
||||||
* Tasks [19/27]
|
* Tasks [20/28]
|
||||||
|
|
||||||
** TODO resolve references to other buffers
|
** TODO resolve references to other buffers
|
||||||
This would allow source blocks to call upon tables, source-blocks,
|
This would allow source blocks to call upon tables, source-blocks,
|
||||||
|
@ -271,6 +271,44 @@ to the command if BUFF is not given.)
|
||||||
posterity. Same for a shell session either in a *shell* buffer, or
|
posterity. Same for a shell session either in a *shell* buffer, or
|
||||||
pasted from another terminal emulator. And python of course.
|
pasted from another terminal emulator. And python of course.
|
||||||
|
|
||||||
|
** DONE ensure that table ranges work
|
||||||
|
when a table range is passed to litorgy as an argument, it should be
|
||||||
|
interpreted as a vector.
|
||||||
|
|
||||||
|
| 1 | 2 | simple |
|
||||||
|
| 2 | 3 | Fixnum:1 |
|
||||||
|
| 3 | 4 | Array:123456 |
|
||||||
|
| 4 | 5 | |
|
||||||
|
| 5 | 6 | |
|
||||||
|
| 6 | 7 | |
|
||||||
|
#+TBLFM: @1$3='(sbe simple-sbe-example (n 4))::@2$3='(sbe task-table-range (n @1$1..@6$1))::@3$3='(sbe task-table-range (n (@1$1..@6$1)))
|
||||||
|
|
||||||
|
#+srcname: simple-sbe-example
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
"simple"
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+srcname: task-table-range
|
||||||
|
#+begin_src ruby :var n=simple-sbe-example
|
||||||
|
"#{n.class}:#{n}"
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+srcname: simple-results
|
||||||
|
#+begin_src emacs-lisp :var n=task-table-range(n=(1 2 3))
|
||||||
|
n
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+resname: simple-results
|
||||||
|
: Array:123
|
||||||
|
|
||||||
|
#+srcname: task-arr-referent
|
||||||
|
#+begin_src ruby :var ar=(1 2 3)
|
||||||
|
ar.size
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+resname: task-arr-referent
|
||||||
|
: 3
|
||||||
|
|
||||||
** DONE global variable indicating default to vector output
|
** DONE global variable indicating default to vector output
|
||||||
how about an alist... =litorgy-default-header-args= this may already
|
how about an alist... =litorgy-default-header-args= this may already
|
||||||
exist... just execute the following and all source blocks will default
|
exist... just execute the following and all source blocks will default
|
||||||
|
|
Loading…
Reference in a new issue