Skip to content

Commit

Permalink
org-sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
jueqingsizhe66 committed May 29, 2018
1 parent 5e7f7e2 commit b942514
Show file tree
Hide file tree
Showing 19 changed files with 1,436 additions and 27 deletions.
29 changes: 16 additions & 13 deletions GTD/orgBoss/dfeich-lisp-babel.org
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,22 @@
#+END_SRC

#+RESULTS:
| col1 | col2 | col3 |
|------+------+------|
| 5 | 25 | 50 |
| 6 | 30 | 60 |
| 7 | 35 | 70 |
| 8 | 40 | 80 |
| 9 | 45 | 90 |
| 10 | 50 | 100 |
| 11 | 55 | 110 |
| 12 | 60 | 120 |
| 13 | 65 | 130 |
| 14 | 70 | 140 |
| 15 | 75 | 150 |
| col1 | col2 | col3 |
|-------+------+------|
| 5 | 25 | 50 |
| 6 | 30 | 60 |
| 7 | 35 | 70 |
| 8 | 40 | 80 |
| 9 | 45 | 90 |
| 10 | 50 | 100 |
| 11 | 55 | 110 |
| 12 | 60 | 120 |
| 13 | 65 | 130 |
| 14 | 70 | 140 |
| 15 | 75 | 150 |
|-------+------+------|
| Total | 550 | 100 |
#+TBLFM: @>$3=vmean(@I..@II);::@>$2=vsum(@I..@II);

** passing a sub-range
It is possible to specify a sub-range for the table that is handed over through =:var=. But currently
Expand Down
107 changes: 107 additions & 0 deletions GTD/orgBoss/dfreich-lob.org
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,110 @@

:END:



#+NAME: srcPostAlignTablesLIB
#+header: :var text="|5|22222|\n|0||\n|12|45|\n|---\n|||\n#+TBLFM:@>$1=vsum(@1..@-1)\n\n|1|22222|\n|0||\n|12|45|\n"
#+BEGIN_SRC emacs-lisp :results value :exports both
(with-temp-buffer
(erase-buffer)
(cl-assert text nil "PostAlignTables received nil instead of text ")
(insert text)
(beginning-of-buffer)
(org-mode)
(while
(search-forward-regexp org-table-any-line-regexp nil t)
(org-table-align)
(org-table-recalculate 'iterate)
(goto-char (org-table-end)))
(buffer-string))
#+END_SRC

#+RESULTS: srcPostAlignTablesLIB
#+begin_example
| 5 | 22222 |
| 0 | |
| 12 | 45 |
|----+-------|
| 17 | |
,#+TBLFM:@>$1=vsum(@1..@-1)

| 1 | 22222 |
| 0 | |
| 12 | 45 |
#+end_example




#+BEGIN_SRC python
import datetime
today=datetime.datetime.today()
name="J. Random User"
print (f'{name:14s} signed up for Bozoid Services on {today}')
#+END_SRC

#+RESULTS:




#+BEGIN_SRC emacs-lisp
(defmacro f-string (fmt)
"Like `s-format' but with format fields in it.
FMT is a string to be expanded against the current lexical
environment. It is like what is used in `s-lex-format', but has
an expanded syntax to allow format-strings. For example:
${user-full-name 20s} will be expanded to the current value of
the variable `user-full-name' in a field 20 characters wide.
(let ((f (sqrt 5))) (f-string \"${f 1.2f}\"))
will render as: 2.24
This function is inspired by the f-strings in Python 3.6, which I
enjoy using a lot.
"
(let* ((matches (s-match-strings-all"${\\(?3:\\(?1:[^} ]+\\) *\\(?2:[^}]*\\)\\)}" fmt))
(agetter (cl-loop for (m0 m1 m2 m3) in matches
collect `(cons ,m3 (format (format "%%%s" (if (string= ,m2 "")
(if s-lex-value-as-lisp "S" "s")
,m2))
(symbol-value (intern ,m1)))))))

`(s-format ,fmt 'aget (list ,@agetter))))

(let ((username "John Kitchin")
(somevar (sqrt 5)))
(f-string "${username -60s}${somevar 1.2f}"))

#+END_SRC

#+RESULTS:
: John Kitchin 2.24



#+NAME: get-named-text
#+BEGIN_SRC elisp :var name="docstring"
(let* ((named-element (org-element-map (org-element-parse-buffer) org-element-all-elements
(lambda (element)
(when (string= (org-element-property :name element) name)
element))
nil t))
(result (buffer-substring (org-element-property :contents-begin named-element)
(org-element-property :contents-end named-element))))
(format "\"%s\"" (replace-regexp-in-string "\\\"" "\\\\\"" result))) ;; escape quote
#+END_SRC



#+NAME: doc-for-add
This is a sample docstring for the function "add".

#+BEGIN_SRC elisp :noweb yes :tangle yes
(defun add (x y)
<<get-named-text("doc-for-add")>>
(+ x y))

#+END_SRC

#+RESULTS:
: add
6 changes: 3 additions & 3 deletions GTD/orgBoss/elisp-cal.org
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,10 @@ End:
| | Name | number | cost per item | sum | incl VAT |
| ! | name | num | peritem | sum | |
|---+---------+--------+---------------+----------+----------|
| | name1 | 3 | 1500.00 | 4500. | 4860.00 |
| * | name1 | 3 | 1500.00 | 4500. | 4860.00 |
| ^ | varname | | | | |
| | name2 | 9 | 4000.00 | 36000. | 38880.00 |
| | name3 | 4 | 2800.00 | 11200. | 12096.00 |
| * | name2 | 9 | 4000.00 | 36000. | 38880.00 |
| * | name3 | 4 | 2800.00 | 11200. | 12096.00 |
|---+---------+--------+---------------+----------+----------|
| | Total | | | 51700.00 | 55836.00 |
#+TBLFM: @>$5..@>$>=vsum(@I..@II);%.2f::$5=$num * $peritem::$6=$sum*1.08;%.2f
14 changes: 14 additions & 0 deletions GTD/orgBoss/listcrunchertest.org
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,18 @@



#+NAME: lsttest
- 花销
- item: 叶昭良(10)
-
-
- item:
- category (recurrence: 5)
- item: a category item C (kCHF: 30)

#+NAME: src-example1
#+BEGIN_SRC elisp :results value :var lname="lsttest" :exports both
(org-listcruncher-to-table lname)
#+END_SRC


8 changes: 4 additions & 4 deletions GTD/orgBoss/newgtd.org
Original file line number Diff line number Diff line change
Expand Up @@ -831,11 +831,12 @@ SCHEDULED: <2017-12-05 周二>
:LOGBOOK:
CLOCK: [2017-12-05 周二 14:13]--[2017-12-05 周二 14:13] => 0:00
:END:
** TODO [#A] 流场可视化专利申请 <2017-12-06 周三 14:53> :@work:
SCHEDULED: <2017-12-06 周三>
** DONE [#A] 流场可视化专利申请 <2017-12-06 周三 14:53> :@work:
CLOSED: [2018-05-29 周二 16:05] SCHEDULED: <2017-12-06 周三>
:PROPERTIES:
:Effort: 2:00
:END:
- State "DONE" from "TODO" [2018-05-29 周二 16:05]
:LOGBOOK:
CLOCK: [2017-12-06 周三 14:53]--[2017-12-06 周三 14:54] => 0:01
:END:
Expand All @@ -851,7 +852,7 @@ DEADLINE: <2018-08-10 周五>
CLOCK: [2017-12-09 周六 22:03]--[2017-12-09 周六 22:08] => 0:05
CLOCK: [2017-12-07 周四 01:11]--[2017-12-08 周五 08:46] => 31:35
:END:

[[https://www.baidu.com][hello]]


Expand Down Expand Up @@ -1180,4 +1181,3 @@ http://www.hnceri.com/n4/n12/index.html
| 水 | | | | bag | | | | |
| 工作 | | teamview | | | | | | |
| 星期一 | | teamview | | bag | | | subway | bought |

28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5288,6 +5288,29 @@ fsolve(x*2+x=4,x)
更进一步参考[dfeich calc.org][284]


#### 如何把自定义的babel系列函数放入org-babel加载库中?

With the help of [The Library of Babel][288], we don't have to include [the code block][287] get-named-text into every Org file.
I put the block into an Org file under my .emacs.d directory, $HOME/.emacs.d/custimazations/org-babel-lib.org.
Then put this line into my .orgConf.el:


``` org
(org-babel-lob-ingest (expand-file-name "~/.emacs.d/custimizations/org-babel-lib.org"))
```

This makes the code block get-named-text a predefined and callable code block that can be seen and called in any Org file.

### 118. org-sidebar

类似于[org-listcrunch][278], [org-sidebar][289]也处于刚刚起步阶段,所以可能还有bug,但效果还不错,于是把它添加进来。

`M-x package-install dash-functional`也得安装。

对我没用,所以从init.el剔除掉!




<hr align="center" width="40%"/>
<hr align="center" width="40%"/>
Expand Down Expand Up @@ -5579,5 +5602,8 @@ fsolve(x*2+x=4,x)
[282]:https://github.com/jueqingsizhe66/ranEmacs.d#102-orgmode-%E8%A1%A8%E6%A0%BC%E8%AF%B4%E6%98%8E
[283]:https://github.com/dfeich/org-babel-examples/blob/master/library-of-babel/dfeich-lob.org
[284]:https://github.com/dfeich/org-babel-examples/blob/master/calc/calc.org
[285]: https://raw.githubusercontent.com/dfeich/org-babel-examples/master/tables/tables.org
[285]:https://raw.githubusercontent.com/dfeich/org-babel-examples/master/tables/tables.org
[286]:https://github.com/jueqingsizhe66/ranEmacs.d/blob/develop/customizations/img/tablestar.png
[287]:http://kdr2.com/tech/emacs/1805-approach-org-ref-code-to-text.html
[288]:https://orgmode.org/worg/org-contrib/babel/library-of-babel.html
[289]: https://github.com/alphapapa/org-sidebar
8 changes: 4 additions & 4 deletions bookmarks
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
(rear-context-string . "5-03 Sun 21:38]\n")
(position . 499))
("org-capture-last-stored"
(filename . "~/.emacs.d/GTD/orgBoss/code-snippets.org")
(front-context-string . "* dfeich-lob的函数对")
(rear-context-string . "1) \n#+END_SRC\n")
(position . 942))
(filename . "~/.emacs.d/GTD/orgBoss/newgtd.org")
(front-context-string . "** TODO [#B] 市政交")
(rear-context-string . "way | bought |\n")
(position . 45181))
#1=(#("org-remember-last-stored" 0 24
(bmkp-full-record #1#))
(annotation)
Expand Down
Loading

0 comments on commit b942514

Please sign in to comment.