[O] Bug: Re: ob-scheme.el has two problems: not killing a misbehaving interpreter and sometimes returns nil [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.2/lisp/org/)]

2019-08-18 Thread Vladimir Nikishkin



Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


The super-pedestrian patch I wrote to patch this issue is:

diff --git a/usr/src/emacs/lisp/org/ob-scheme.el 
b/usr/share/emacs/26.2/lisp/org/ob-scheme.el
index 798cf4e..1df4df9 100644
--- a/usr/src/emacs/lisp/org/ob-scheme.el
+++ b/usr/share/emacs/26.2/lisp/org/ob-scheme.el
@@ -175,7 +175,10 @@ is true; otherwise returns the last value."
(geiser-debug-show-debug-p nil))
(let ((ret (geiser-eval-region (point-min) (point-max
  (setq result (if output
-  (geiser-eval--retort-output ret)
+  (let ((g-r-o (geiser-eval--retort-output ret)))
+(if g-r-o
+g-r-o
+  "Geiser-eval--retort-output returned 
nil.\nThe interpreter produced no output\nor there is a bug in geiser 
(likely!)"))
 (geiser-eval--retort-result-str ret "")
  (when (not repl)
(save-current-buffer (set-buffer repl-buffer)


Emacs  : GNU Emacs 26.2 (build 1, x86_64-slackware-linux-gnu, GTK+ Version 
3.24.10)
 of 2019-07-18
Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ 
/usr/share/emacs/26.2/lisp/org/)
-- 
--
Vladimir Nikishkin (MiEr, lockywolf)



[O] Bug: ob-scheme.el has two problems: not killing a misbehaving interpreter and sometimes returns nil [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.2/lisp/org/)]

2019-08-18 Thread Vladimir Nikishkin



Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


Hello, everyone.

I am trying to write a quasi coursework solution for SICP with org and
Chibi-scheme. Unfortunately, chibi is not very well supported in geiser
(although some evaluation features work), so I am having the following
difficulties with the following code:

#+BEGIN_SRC scheme :export both :results output :session
(import (scheme small))
(display "Hello 1\n")
t
#+END_SRC

Note that t is not a registered symbol in scheme (should be #t), but is
shows two errors:

1. The buffer "myfile.org chibi REPL" is not killed after the execution
is finished. Maybe ob-scheme tries to run some internal exit function in
the interpreter, which fails, or whatever, but I am left with a dangling
buffer. (Maybe line 184 in ob-scheme.el, kill-buffer is not doing its job?)

2. In this case, org-babel-scheme-execute-with-geiser returns nil. This
is wrong, because org-babel-reassemble-table does not expect nil as an
input. Moreover, since all of this is not exception-handled, it turns
out into a silent error.

3. In this case, the output of the interpreter is "ERROR: undefined
variable: t", printed to stderr. Geiser processes this by forwarding
back the (error . "<...> error output") cons cell, but org doesn't seem
to be using this. I mean, if I change :results to be "value", I am
getting the exception message into the org buffer, but I suspect that is
should also be displayed when ":results output" since that is what the
interpreter is actually printing.

4. Is there some legitimate way to get all three output channels of a
block of code together? By "all three" I mean, "STDOUT", "STDERR" and
the expression return value?

Cheers, everyone, thanks for your work!

Emacs  : GNU Emacs 26.2 (build 1, x86_64-slackware-linux-gnu, GTK+ Version 
3.24.10)
 of 2019-07-18
Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ 
/usr/share/emacs/26.2/lisp/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-babel-after-execute-hook '((lambda nil
 (if org-inline-image-overlays
  (progn (org-redisplay-inline-images)))
 )
)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-html-format-inlinetask-function 
'org-html-format-inlinetask-default-function
 org-pretty-entities t
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-agenda-files '("~/Personal_Planner/Planner.org")
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-reveal-start-hook '(org-decrypt-entry)
 org-modules '(org-habits org-w3m org-bbdb org-bibtex org-docview org-gnus 
org-info org-irc
   org-mhe org-rmail)
 org-plantuml-jar-path "/usr/local/bin/plantuml.jar"
 org-mode-hook '((lambda nil (imenu-add-to-menubar "Imenu"))
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-show-block-all append 
local] 5]
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-babel-show-result-all 
append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-latex-compiler "lualatex"
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
 org-babel-load-languages '((plantuml . t) (C . t) (scheme . t))
 org-log-done 'time
 org-startup-align-all-tables t
 org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS 
WIDTH)"]
 org-catch-invisible-edits t
 org-occur-hook '(org-first-headline-recenter)
 org-edit-src-auto-save-idle-delay 15
 org-agenda-include-diary t
 org-structure-template-alist '(("p" "#+begin_src plantuml :export both :file ? 
\n#+end_src ")
("s" "#+BEGIN_SRC ?\n\n#+END_SRC")
("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE")
("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE")

Re: [O] Bug: org-sort-entries does not preserve folded drawers [9.1.13 (9.1.13-dist @ /home/yantar92/.emacs.d/straight/build/org/)]

2019-08-18 Thread Ihor Radchenko
Thanks!

Carsten Dominik  writes:

> Hi Ihor,
>
> thank you for the report.
> It would be too much work to *preserve* the visibility state of everything
> in the sorting area, but you are right, the drawers at lease should be
> closed.  I fixed this, the fix is in master.
>
> Carsten
>
> On Sat, Aug 3, 2019 at 8:22 AM Ihor Radchenko  wrote:
>
>>
>> org-sort-entries seems to unfold everything in the subtree even if no
>> modification was done to the buffer during sorting.
>>
>> Steps to reproduce:
>>
>> Consider the following org file:
>> #+begin_src org
>> ,* a
>> :PROPERTIES:
>> :ID:   279e797c-f4a7-47bb-80f6-e72ac6f3ec55
>> :END:
>> :DRAWER:
>> Blah
>> :END:
>>
>> ,** test
>> #+end_src
>>
>> 1. emacs -Q
>> 2. Fold all the drawers and entries in the buffer
>> 3a. Call M-x org-sort-entries p
>> 3b. Call M-: (org-sort-entries nil ?p) RET
>>
>>
>> Expected behaviour for 3a: Subtree is unfolded, all the property drawers
>> are folded, buffer is unchanged
>> Observed behaviour for 3a: Subtree is unfolded, all the property drawers
>> are also unfolded, buffer is marked modified
>>
>> Expected behaviour for 3b: Subtree is folded, all the property drawers
>> are folded, buffer is unchanged
>> Observed behaviour for 3b: Subtree is unfolded, all the property drawers
>> are also unfolded, buffer is marked modified
>>
>> Regards,
>> Ihor
>>
>>
>>
>>
>> Emacs  : GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit)
>>  of 2019-04-29
>> Package: Org mode version 9.1.13 (9.1.13-dist @
>> /home/yantar92/.emacs.d/straight/build/org/)
>> --
>> Ihor Radchenko,
>> PhD,
>> Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
>> State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong
>> University, Xi'an, China
>> Email: yanta...@gmail.com, ihor_radche...@alumni.sutd.edu.sg
>>
>>
>>

-- 
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong 
University, Xi'an, China
Email: yanta...@gmail.com, ihor_radche...@alumni.sutd.edu.sg



[O] org-time-stamp keep the month and the year

2019-08-18 Thread Uwe Brauer


Hi

Sometimes I have to insert various dates of a given month/year in a
table. However if this is not an actual date, every time I use
org-time-stamp I have to go back.

On the other hand if this command is used twice in succession, a time
range is inserted. So in some way the same month/year is kept.

Could I obtain this behavior although I don't use the command twice in
succession but move say the cursor.

Uwe Brauer 





Re: [O] CUSTOM_ID vs ID

2019-08-18 Thread Nicolas Goaziou
Hello,

Jorge P. de Morais Neto  writes:

> But could not we URL-encode the dedicated target text?

My example was about HTML, but the same process is used in every export
back-end. URL-encoded strings may also be invalid in other back-ends.

> In my testing, Org generates an ugly anchor even if the dedicated
> target text is just "Target".

"org-XXX" is not "ugly", but functional :)

> The current behavior does not harm my current use cases, but I looks to
> me it would be simple to improve (for someone familiar with the
> codebase) and help some users.

Note that the current behaviour was implemented as an improvement over
the previous solution, to help some users. You may want to dig into the
mailing list archives about it. IIRC, it started out when a Chinese user
reported an issue with targets.

LaTeX back-end uses `org-latex-prefer-user-labels'. HTML could use
a similar mechanism but no one bothered implementing it yet. In any
case, Org provides a robust default solution. I think it is a reasonable
expectation as a default.

Regards,

-- 
Nicolas Goaziou



[O] [week?] (was: insert date-stamp for one month)

2019-08-18 Thread Uwe Brauer
>>> "TP" == Thomas Plass  writes:
hi 


   > Hello,

I was wondering could that also be done for a week instead of a month

   > (defun Brauer/make-month-timerange (year month)
   >   (interactive
   >(list (string-to-int (read-string "Year: " (int-to-string (nth 5 
(decode-time)
   >  (string-to-int (read-string "Month: " (int-to-string (nth 4 
(decode-time)))
   >   (let* ((last-day (calendar-last-day-of-month month year))
   >  (start (list 0 0 0 1 month year))
   >  (end (list 0 0 0 last-day month year))
   >  (ts (format "<%d-%02d-%02d %s>--<%d-%02d-%02d %s>"
   >  year month 1 (format-time-string "%a" (apply 
#'encode-time start))
   >  year month last-day (format-time-string "%a" (apply 
#'encode-time end)
   > (message (substitute-command-keys (concat "Use \\[yank] to yank " ts)))
   > (kill-new ts)))

The problem seems to be that there is no function
calendar-last-day-of-week. I tried to play a little around but it seems 
difficult.

Anyhow

Uwe Brauer 


smime.p7s
Description: S/MIME cryptographic signature


Re: [O] CUSTOM_ID vs ID

2019-08-18 Thread Jorge P . de Morais Neto
Hello,

Em 2019-08-18T12:40:29+0200, Nicolas Goaziou escreveu:

> That's because the text could contain anything, including invalid HTML
> characters. So we normalize them using only alphanum characters.

But could not we URL-encode the dedicated target text?  In my testing,
Org generates an ugly anchor even if the dedicated target text is just
"Target".

The current behavior does not harm my current use cases, but I looks to
me it would be simple to improve (for someone familiar with the
codebase) and help some users.  Then again, talk is cheap, so please
just take this as just a suggestion.

Regards
-- 
- I am Brazilian.  I hope my English is correct and I welcome feedback
- Please adopt free formats like PDF, ODF, Org, LaTeX, Opus, WebM and 7z
- Free/libre software for Android: https://f-droid.org/
- [[https://www.gnu.org/philosophy/free-sw.html][What is free software?]]



Re: [O] MobileOrg and other tools

2019-08-18 Thread Jean Louis
* Carsten Dominik  [2019-08-18 13:41]:
> does anyone know if the MobileOrg apps for both iOS and Android are still
> supported, and by who?

I prefer that MobileOrg options are removed from Org menu in
Emacs. Just my opinion. It is not necessary.

> I know that Orgzly is actively supported and in excellent shape.  But I
> don't know about MobileOrg or Syncorg for that matter, or any other similar
> tools.

I prefer no such options to be in Org menu, but people can make
packages and support it separately.

> Does anyone have an overview over all these implementations and their
> status?

I just know that for me longer time MobileOrg is not accessible on
F-droid.org and I could not update it, and also was not usable
application. Orgzly is much better, but it is not Org as on Emacs. It
gives some compatibility.

-- 
Thanks,
Jean Louis



[O] MobileOrg and other tools

2019-08-18 Thread Carsten Dominik
Hi,

does anyone know if the MobileOrg apps for both iOS and Android are still
supported, and by who?

I know that Orgzly is actively supported and in excellent shape.  But I
don't know about MobileOrg or Syncorg for that matter, or any other similar
tools.

Does anyone have an overview over all these implementations and their
status?

Thanks.

Carsten


Re: [O] join two or more tables

2019-08-18 Thread Uwe Brauer
>>> "AG" == Achim Gratz  writes:

   > Uwe Brauer writes:
   >> Thanks I knew about it, but it seems very sophisticated and column, not
   >> row based.

   > Well, if simple-minded suits you (i.e. the columns are known to have the
   > same order):

   > Tables in Org are lists with rows as their elements, and a row is either
   > a symbol or a list of column elements.  So just concatenating the two
   > lists does (almost) the right thing.  If you know the row has headers,
   > you need to skip until the first real data row in the second table
   > (i.e. skip the first row, the first header and then resume the concat).

   > Your other option is just grabbing the text of both tables, emit it as a
   > single entity (again you may want to remove the header on the second
   > table) and then call org-align-table on it.


Hm, thanks but could you post an example (the one I finally used is
based on R and goes as follows


 #+tblname: TC
 | a | b | c |
 |---+---+---|
 | 1 | 2 | 3 |
 | 7 | 8 | 9 |
 
 #+tblname: TD
 |  a |  b |  c |
 |++|
 |  4 |  5 |  6 |
 | 10 | 11 | 12 |

 #+begin_src R :colnames t :var t1=TC t2=TD
 rbind(t1, t2)
 #+end_src

 #+RESULTS:
 |  a |  b |  c |
 |++|
 |  1 |  2 |  3 |
 |  7 |  8 |  9 |
 |  4 |  5 |  6 |
 | 10 | 11 | 12 |


smime.p7s
Description: S/MIME cryptographic signature


Re: [O] join two or more tables

2019-08-18 Thread Jude DaShiell
In that situation I made 3 files header; t1, and t2.  The header file
had the two lines at the top of both tables.  The t1 and t2 files had
only record lines in them without the footer.  Then cat header t1 t2
>newtable.  Once done open newtable and be sure it works in emacs and
append that footer line to it and perhaps put it into a #Begin-src
#End-src block.

On Sun, 18 Aug 2019, Uwe Brauer wrote:

> Date: Sun, 18 Aug 2019 04:31:04
> From: Uwe Brauer 
> To: emacs-orgmode@gnu.org
> Subject: Re: [O] join two or more tables
>
> >>> "UB" == Uwe Brauer  writes:
>
>> Hi
>
>> I was googling this a bit, I found more complicated scenarios, but not
>> how to join one or more tables.
>
>> For example
>
>> #+begin_src
>
>> #+tblname: nut
>> | type | Fiber | Sugar | Protein | Carb |
>> |--+---+---+-+--|
>> | eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
>> | tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
>> | onion|   1.3 |   4.4 | 1.3 |  9.0 |
>> | egg  | 0 |  18.3 |31.9 | 18.3 |
>
>
>> #+tblname: nut2
>> | type | Fiber | Sugar | Protein | Carb |
>> |--+---+---+-+--|
>> | rice |   0.2 | 0 | 1.5 | 16.0 |
>> | bread|   0.7 |   0.7 | 3.3 | 16.0 |
>> | orange   |   3.1 |  11.9 | 1.3 | 17.6 |
>> | banana   |   2.1 |   9.9 | 0.9 | 18.5 |
>> | tofu |   0.7 |   0.5 | 6.6 |  1.4 |
>> | nut  |   2.6 |   1.3 | 4.9 |  7.2 |
>> | corn |   4.7 |   1.8 | 2.8 | 21.3 |
>> #+end_src
>
>
>> I want to generate a new table total-nuts, which is just a combination
>> of the two tables, nuts and nuts2
>
>
>> Uwe Brauer
>
> I found a solution posted in
>
> https://lists.gnu.org/archive/html/emacs-orgmode/2009-09/msg00919.html
>
> However
>
> ** Elisp
> #+tblname: tab1
>  | 1 | 2 | 3 |
>  | 7 | 8 | 9 |
>
> #+tblname: tab2
>  |  4 |  5 |  6 |
>  | 10 | 11 | 12 |
>
>  Here's a solution in emacs lisp:
>
>  #+srcname: column-bind-elisp(a=tab1, b=tab2)
>  #+begin_src emacs-lisp
>  (mapcar* 'append a b)
>  #+end_src
>
>
> column-bind-elisp
>
> Does not exist any more.
>
> Any ideas?
>
> Uwe Brauer
>

-- 




Re: [O] join two or more tables

2019-08-18 Thread Achim Gratz
Uwe Brauer writes:
> Thanks I knew about it, but it seems very sophisticated and column, not
> row based.

Well, if simple-minded suits you (i.e. the columns are known to have the
same order):

Tables in Org are lists with rows as their elements, and a row is either
a symbol or a list of column elements.  So just concatenating the two
lists does (almost) the right thing.  If you know the row has headers,
you need to skip until the first real data row in the second table
(i.e. skip the first row, the first header and then resume the concat).

Your other option is just grabbing the text of both tables, emit it as a
single entity (again you may want to remove the header on the second
table) and then call org-align-table on it.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for KORG EX-800 and Poly-800MkII V0.9:
http://Synth.Stromeko.net/Downloads.html#KorgSDada




Re: [O] CUSTOM_ID vs ID

2019-08-18 Thread Nicolas Goaziou
Hello,

Jorge P. de Morais Neto  writes:

> But why does Org not use the dedicated target text as an anchor?

That's because the text could contain anything, including invalid HTML
characters. So we normalize them using only alphanum characters.

Regards,

-- 
Nicolas Goaziou



Re: [O] insert date-stamp for one month

2019-08-18 Thread Uwe Brauer
>>> "KM" == Ken Mankoff  writes:

   > On 2019-08-18 at 03:58 -04, Uwe Brauer  wrote...
   >> I sometimes need to insert a date-stamp which corresponds to one month
   >> in a year, say march 2019. I usually insert <2019-03-01
   Fri> --<2019-03-31 Sun>, but this is cumbersome to do manually.
   >> 
   >> Somebody has a better idea or know how to insert something like <03.2019>

   > What about picking one day in the month, but only displaying the month?

   > e.g. 
https://emacs.stackexchange.com/questions/2243/how-can-i-change-org-mode-time-format-for-one-buffer

   > 
https://stackoverflow.com/questions/50233694/org-mode-edit-timestamp-with-custom-format

   > 
https://emacs.stackexchange.com/questions/32889/can-the-format-of-a-timestamp-in-an-org-mode-document-be-locally-adjusted-for-ex

Thanks, but this is either buffer or export specific, I want it for some
entries but not for all in my buffer. So Thomas solution, was precisely
what I was looking for.


smime.p7s
Description: S/MIME cryptographic signature


Re: [O] insert date-stamp for one month

2019-08-18 Thread Ken Mankoff
On 2019-08-18 at 03:58 -04, Uwe Brauer  wrote...
> I sometimes need to insert a date-stamp which corresponds to one month
> in a year, say march 2019. I usually insert <2019-03-01
> Fri>--<2019-03-31 Sun>, but this is cumbersome to do manually.
>
> Somebody has a better idea or know how to insert something like <03.2019>

What about picking one day in the month, but only displaying the month?

e.g. 
https://emacs.stackexchange.com/questions/2243/how-can-i-change-org-mode-time-format-for-one-buffer

https://stackoverflow.com/questions/50233694/org-mode-edit-timestamp-with-custom-format

https://emacs.stackexchange.com/questions/32889/can-the-format-of-a-timestamp-in-an-org-mode-document-be-locally-adjusted-for-ex

  -k.



Re: [O] join two or more tables

2019-08-18 Thread Uwe Brauer
>>> "KM" == Ken Mankoff  writes:

   > On 2019-08-18 at 04:23 -04, Uwe Brauer  wrote...
   >> I was googling this a bit, I found more complicated scenarios, but not
   >> how to join one or more tables.
   >> 
   >> [...]
   >> 
   >> I want to generate a new table total-nuts, which is just a combination
   >> of the two tables, nuts and nuts2 

   > Does https://github.com/tbanel/orgtbljoin do what you want?


Thanks I knew about it, but it seems very sophisticated and column, not
row based.

Meanwhile I found the following, R-based, solution 

* Using R to combine columns, important the first row must coincide!
 #+tblname: TC
 | a | b | c |
 |---+---+---|
 | 1 | 2 | 3 |
 | 7 | 8 | 9 |
 
 #+tblname: TD
 |  a |  b |  c |
 |++|
 |  4 |  5 |  6 |
 | 10 | 11 | 12 |

 #+begin_src R :colnames t :var t1=TC t2=TD
 rbind(t1, t2)
 #+end_src


smime.p7s
Description: S/MIME cryptographic signature


Re: [O] insert date-stamp for one month

2019-08-18 Thread Uwe Brauer
>>> "TP" == Thomas Plass  writes:

   > Hello,
   > Uwe Brauer wrote at 09:58 on August 18, 2019:
   > : I sometimes need to insert a date-stamp which corresponds to one month
   > : in a year, say march 2019. I usually insert 
   > : <2019-03-01 Fri>--<2019-03-31 Sun>, but this is cumbersome to do
   > : manually.

   > This'll put the computed result on the kill ring.  Beautification and
   > error checking of input values left as an exercise for the reader.

   > (defun Brauer/make-month-timerange (year month)
   >   (interactive
   >(list (string-to-int (read-string "Year: " (int-to-string (nth 5 
(decode-time)
   >  (string-to-int (read-string "Month: " (int-to-string (nth 4 
(decode-time)))
   >   (let* ((last-day (calendar-last-day-of-month month year))
   >  (start (list 0 0 0 1 month year))
   >  (end (list 0 0 0 last-day month year))
   >  (ts (format "<%d-%02d-%02d %s>--<%d-%02d-%02d %s>"
   >  year month 1 (format-time-string "%a" (apply 
#'encode-time start))
   >  year month last-day (format-time-string "%a" (apply 
#'encode-time end)
   > (message (substitute-command-keys (concat "Use \\[yank] to yank " ts)))
   > (kill-new ts)))

Very cool, thanks a lot. But why no

(defun Plass/make-month-timerange (year month)
  (interactive
   (list (string-to-int (read-string "Year: " (int-to-string (nth 5 
(decode-time)
 (string-to-int (read-string "Month: " (int-to-string (nth 4 
(decode-time)))
  (let* ((last-day (calendar-last-day-of-month month year))
 (start (list 0 0 0 1 month year))
 (end (list 0 0 0 last-day month year))
 (ts (format "<%d-%02d-%02d %s>--<%d-%02d-%02d %s>"
 year month 1 (format-time-string "%a" (apply #'encode-time 
start))
 year month last-day (format-time-string "%a" (apply 
#'encode-time end)
(insert ts)))


smime.p7s
Description: S/MIME cryptographic signature


Re: [O] join two or more tables

2019-08-18 Thread Ken Mankoff
On 2019-08-18 at 04:23 -04, Uwe Brauer  wrote...
> I was googling this a bit, I found more complicated scenarios, but not
> how to join one or more tables.
>
> [...]
>
> I want to generate a new table total-nuts, which is just a combination
> of the two tables, nuts and nuts2 

Does https://github.com/tbanel/orgtbljoin do what you want?

  -k.
  




Re: [O] insert date-stamp for one month

2019-08-18 Thread Thomas Plass
Hello,

Uwe Brauer wrote at 09:58 on August 18, 2019:
: I sometimes need to insert a date-stamp which corresponds to one month
: in a year, say march 2019. I usually insert 
: <2019-03-01 Fri>--<2019-03-31 Sun>, but this is cumbersome to do
: manually.

This'll put the computed result on the kill ring.  Beautification and
error checking of input values left as an exercise for the reader.

(defun Brauer/make-month-timerange (year month)
  (interactive
   (list (string-to-int (read-string "Year: " (int-to-string (nth 5 
(decode-time)
 (string-to-int (read-string "Month: " (int-to-string (nth 4 
(decode-time)))
  (let* ((last-day (calendar-last-day-of-month month year))
 (start (list 0 0 0 1 month year))
 (end (list 0 0 0 last-day month year))
 (ts (format "<%d-%02d-%02d %s>--<%d-%02d-%02d %s>"
 year month 1 (format-time-string "%a" (apply #'encode-time 
start))
 year month last-day (format-time-string "%a" (apply 
#'encode-time end)
(message (substitute-command-keys (concat "Use \\[yank] to yank " ts)))
(kill-new ts)))


Regards

Thomas





[O] [rows not columns] (was: [SOLVED])

2019-08-18 Thread Uwe Brauer
>>> "UB" == Uwe Brauer  writes:


   > Best solution found in 

   > https://emacs.stackexchange.com/questions/48508/merge-org-tables

   > ** Solution 1

   > #+NAME: T1
   > | col1 | col2 |

   > |1 | 2|

   > #+NAME: T2
   > | col3 |

   > | 3|

   > #+BEGIN_SRC emacs-lisp :var t1=T1 t2=T2
   > (cl-mapcar #'append t1 t2)
   > #+END_SRC

This only joins columns. I want to join rows, I presume I should replace 
cl-mapcar by something else.

Any suggestions?

Thanks

Uwe Brauer 


smime.p7s
Description: S/MIME cryptographic signature


[O] [SOLVED] (was: join two or more tables)

2019-08-18 Thread Uwe Brauer



>>> "UB" == Uwe Brauer  writes:
   >> Hi

   >> I was googling this a bit, I found more complicated scenarios, but not
   >> how to join one or more tables.

   >> For example 

   >> #+begin_src 

   >> #+tblname: nut
   >> | type | Fiber | Sugar | Protein | Carb |
   >> |--+---+---+-+--|
   >> | eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
   >> | tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
   >> | onion|   1.3 |   4.4 | 1.3 |  9.0 |
   >> | egg  | 0 |  18.3 |31.9 | 18.3 |


   >> #+tblname: nut2
   >> | type | Fiber | Sugar | Protein | Carb |
   >> |--+---+---+-+--|
   >> | rice |   0.2 | 0 | 1.5 | 16.0 |
   >> | bread|   0.7 |   0.7 | 3.3 | 16.0 |
   >> | orange   |   3.1 |  11.9 | 1.3 | 17.6 |
   >> | banana   |   2.1 |   9.9 | 0.9 | 18.5 |
   >> | tofu |   0.7 |   0.5 | 6.6 |  1.4 |
   >> | nut  |   2.6 |   1.3 | 4.9 |  7.2 |
   >> | corn |   4.7 |   1.8 | 2.8 | 21.3 |
   >> #+end_src


   >> I want to generate a new table total-nuts, which is just a combination
   >> of the two tables, nuts and nuts2 


   >> Uwe Brauer 

Best solution found in 

https://emacs.stackexchange.com/questions/48508/merge-org-tables

** Solution 1
#+NAME: T1
| col1 | col2 |
|1 | 2|

#+NAME: T2
| col3 |
| 3|

#+BEGIN_SRC emacs-lisp :var t1=T1 t2=T2
(cl-mapcar #'append t1 t2)
#+END_SRC

#+RESULTS:
| col1 | col2 | col3 |
|1 |2 |3 |

** Solution 2

#+NAME: T3
| col1 | col2 |
|   11 |   12 |
|   21 |   22 |
|   31 |   32 |

#+NAME: T4
| col3 |
|   13 |
|   12 |

#+BEGIN_SRC emacs-lisp :var t1=T3 t2=T4 :colnames no
(cl-mapcar #'append t1 t2)
#+END_SRC

#+RESULTS:
| col1 | col2 | col3 |
|   11 |   12 |   13 |
|   21 |   22 |   12 |



** Solution 3

#+NAME: TA
| col1 | col2 |
|--+--|
|1 |2 |

#+NAME: TB
| col3 |
|--|
|3 |

#+BEGIN_SRC emacs-lisp :var t1=TA t2=TB :colnames no
(insert-at 1 (cl-mapcar #'append t1 t2) 'hline)
#+END_SRC

#+RESULTS:
| col1 | col2 | col3 |
|--+--+--|
|1 |2 |3 |


#+begin_src elisp :noexport

(defun insert-at (n list element)
  "Insert ELEMENT into LIST at position N.
I.e., (eq ELEMENT (nth N (insert-at N LIST ELEMENT)))."
  (if (eq n 0)
  (cons element list)
(let ((link (nthcdr (1- n) list)))
  (setcdr link (cons element (cdr link
list))
#+end_src





Re: [O] join two or more tables

2019-08-18 Thread Uwe Brauer
>>> "UB" == Uwe Brauer  writes:

   > Hi

   > I was googling this a bit, I found more complicated scenarios, but not
   > how to join one or more tables.

   > For example 

   > #+begin_src 

   > #+tblname: nut
   > | type | Fiber | Sugar | Protein | Carb |
   > |--+---+---+-+--|
   > | eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
   > | tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
   > | onion|   1.3 |   4.4 | 1.3 |  9.0 |
   > | egg  | 0 |  18.3 |31.9 | 18.3 |


   > #+tblname: nut2
   > | type | Fiber | Sugar | Protein | Carb |
   > |--+---+---+-+--|
   > | rice |   0.2 | 0 | 1.5 | 16.0 |
   > | bread|   0.7 |   0.7 | 3.3 | 16.0 |
   > | orange   |   3.1 |  11.9 | 1.3 | 17.6 |
   > | banana   |   2.1 |   9.9 | 0.9 | 18.5 |
   > | tofu |   0.7 |   0.5 | 6.6 |  1.4 |
   > | nut  |   2.6 |   1.3 | 4.9 |  7.2 |
   > | corn |   4.7 |   1.8 | 2.8 | 21.3 |
   > #+end_src


   > I want to generate a new table total-nuts, which is just a combination
   > of the two tables, nuts and nuts2 


   > Uwe Brauer 

I found a solution posted in 

https://lists.gnu.org/archive/html/emacs-orgmode/2009-09/msg00919.html

However 

** Elisp
#+tblname: tab1
 | 1 | 2 | 3 |
 | 7 | 8 | 9 |
 
#+tblname: tab2
 |  4 |  5 |  6 |
 | 10 | 11 | 12 |
 
 Here's a solution in emacs lisp:
 
 #+srcname: column-bind-elisp(a=tab1, b=tab2)
 #+begin_src emacs-lisp 
 (mapcar* 'append a b)
 #+end_src


column-bind-elisp

Does not exist any more.

Any ideas?

Uwe Brauer 


smime.p7s
Description: S/MIME cryptographic signature


[O] join two or more tables

2019-08-18 Thread Uwe Brauer

Hi

I was googling this a bit, I found more complicated scenarios, but not
how to join one or more tables.

For example 
#+begin_src 

#+tblname: nut
| type | Fiber | Sugar | Protein | Carb |
|--+---+---+-+--|
| eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
| tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
| onion|   1.3 |   4.4 | 1.3 |  9.0 |
| egg  | 0 |  18.3 |31.9 | 18.3 |


#+tblname: nut2
| type | Fiber | Sugar | Protein | Carb |
|--+---+---+-+--|
| rice |   0.2 | 0 | 1.5 | 16.0 |
| bread|   0.7 |   0.7 | 3.3 | 16.0 |
| orange   |   3.1 |  11.9 | 1.3 | 17.6 |
| banana   |   2.1 |   9.9 | 0.9 | 18.5 |
| tofu |   0.7 |   0.5 | 6.6 |  1.4 |
| nut  |   2.6 |   1.3 | 4.9 |  7.2 |
| corn |   4.7 |   1.8 | 2.8 | 21.3 |
#+end_src


I want to generate a new table total-nuts, which is just a combination
of the two tables, nuts and nuts2 


Uwe Brauer 


smime.p7s
Description: S/MIME cryptographic signature


[O] insert date-stamp for one month

2019-08-18 Thread Uwe Brauer

Hi 

I sometimes need to insert a date-stamp which corresponds to one month
in a year, say march 2019. I usually insert 
<2019-03-01 Fri>--<2019-03-31 Sun>, but this is cumbersome to do
manually.

Somebody has a better idea or know how to insert something like <03.2019>

Uwe Brauer


smime.p7s
Description: S/MIME cryptographic signature