Re: Plotting a table of date+time pairs

2024-11-29 Thread Fraga, Eric
Response below/inline for email Michael Heerdegen wrote:
> (original email sent 29 Nov 2024 at 00:17)
> 
> I'm not a sophisticated org user.  May I ask for a simple example,
> and how I would have to invoke gnuplot instead?

Sure, see attached.  This example has a table of data to plot (simple
example with two columns) and the gnuplot src block to create a PDF
plot.  You invoke gnuplot by typing C-c C-c in the src block.  You can
then view the result with C-c C-o.

Check the info manual for org, specifically
(org) Working with Source Code

HTH,
eric
-- 
: Eric S Fraga, with org 9.7.15-a1df10 in Emacs 31.0.50


test.org
Description: test.org


Re: [PATCH] Add yank-media handler for LibreOffice Calc tables

2024-11-29 Thread Visuwesh
Sorry for the late reply.  I was busy with uni.

[திங்கள் அக்டோபர் 21, 2024] Visuwesh wrote:

> [திங்கள் அக்டோபர் 21, 2024] Rens Oliemans wrote:
>
>> Visuwesh  writes:
>>
>>> If possible, could you please try LibreOffice 7.6.4? The version Ihor
>>> has installed in his system.  There is an AppImage available for you to
>>> try.
>>
>> Yep, on 7.6.4 the problem occurs.
>>
>> $ ./LibreOffice-7.6.4.1.basic-x86_64.AppImage --version
>> LibreOffice 7.6.4.1 e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
>>
>> Debugger entered--entering a function:
>> * org--libreoffice-table-handler(application/x-libreoffice-tsvc 
>> #("f\0o\0o\0\11\0b\0a\0r\0\11\0\n\0001\0\11\0002\0\11\0003\0\n\0" 0 30 
>> (foreign-selection STRING)))
>>   yank-media()
>>
>> , resulting in
>>
>> | f\0o\0o\0 | \0b\0a\0r\0 | \0|
>> | \01\0 | \02\0   | \03\0 |
>> | \0| |   |
>>
>> To narrow it down a bit more: the problem exists in 7.6.5.2, and does not 
>> exist in the
>> following release, 7.6.6.3.
>
> Thank you!  So it is most likely not locale related---a major headache
> saved.  I will look into this soon (cannot promise anything this week
> unfortunately).

For reasons that escape me completely, I did not see null bytes in the
selection in

% ./LibreOffice-7.6.4.1.standard.help-x86_64.AppImage --version
LibreOffice 7.6.4.1 e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1

But considering that the chances of having null bytes in documents are
very low, I decided to bruteforce strip them.

[சனி அக்டோபர் 19, 2024] Visuwesh wrote:

> [சனி அக்டோபர் 19, 2024] Ihor Radchenko wrote:
>
>> Visuwesh  writes:
>>
 Also, do note that any text exceeding
 `org-table-convert-region-max-lines' will lead to
 `org-table-convert-region' throwing an error.
>>>
>>> Catching that and messaging the user should be sufficient?
>>
>> Maybe. Or we may catch and ask user to lift the restriction temporarily.
>> Something like:
>>
>> Inserting large table with more than `org-table-convert-region-max-lines' 
>> . Continue? (yes/no)
>
> Ah, something like what Calc does.  Yes, I will go with this approach.
> Thanks for the suggestion.

I have now done this in the attached patch.  I use a temporary buffer to
convert the table, and also decode it as per buffer-file-coding-system
of the Org buffer as I could not tell whether LibreOffice always uses
UTF-8 or not.  I believe buffer-file-coding-system should be utf-8 on
most systems so it should be a safe choice.

>From f392dc1f3eb550c3d833683113c2d958f7f9b722 Mon Sep 17 00:00:00 2001
From: Visuwesh 
Date: Mon, 14 Oct 2024 22:04:23 +0530
Subject: [PATCH] Add `yank-media' handler for LibreOffice Calc tables

* lisp/org.el (org--libreoffice-table-handler): Add new `yank-media'
handler for tables copied from LibreOffice Calc documents.
(org-setup-yank-dnd-handlers): Register it.
* doc/org-manual.org: (Drag and Drop & ~yank-media~): Update the
manual to mention the new feature.
* etc/ORG-NEWS: Announce the new feature.
---
 doc/org-manual.org |  6 +-
 etc/ORG-NEWS   |  5 +
 lisp/org.el| 27 ++-
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 95846b475..e23e388a0 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -21684,7 +21684,8 @@ value as ~org-attach-method~ (~cp~ by default).]
 
 #+cindex: pasting files, images from clipboard
 Starting from Emacs 29, Org mode supports ~yank-media~ command to yank
-images from the clipboard and files from a file manager.
+images from the clipboard, files from a file manager and tables copied
+from LibreOffice Calc documents.
 
 #+vindex: org-yank-image-save-method
 When yanking images from clipboard, Org saves the image on disk and
@@ -21702,6 +21703,9 @@ of ~org-yank-dnd-method~.  Image files pasted this way also respect
 the value of ~org-yank-image-save-method~ when the action to perform
 is =attach=.
 
+Yanking tables copied from LibreOffice Calc documents are inserted as
+Org tables.
+
 ** Repeating commands
 :PROPERTIES:
 :DESCRIPTION: Repeating navigation commands
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 08857962b..9ad2da5d4 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -136,6 +136,11 @@ The keybindings in the repeat-maps can be changed by customizing
 
 See the new [[info:org#Repeating commands]["Repeating commands"]] section in Org mode manual.
 
+*** Tables copied from LibreOffice Calc documents can be pasted as Org tables
+
+Tables copied into the clipboard from LibreOffice Calc documents can
+now be pasted as an Org table using ~yank-media~.
+
 ** New and changed options
 
 # Chanes deadling with changing default values of customizations,
diff --git a/lisp/org.el b/lisp/org.el
index def094a9a..f9c275ca7 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20354,7 +20354,9 @@ (defun org-setup-yank-dnd-handlers ()
 ;; Looks like different DEs go for different handler names,
 ;; https://larsee.c

Re: Plotting a table of date+time pairs

2024-11-29 Thread Max Nikulin

On 29/11/2024 06:17, Michael Heerdegen wrote:

I'm not a sophisticated org user.  May I ask for a simple example,
and how I would have to invoke gnuplot instead?




Link to its source is incorrect, it should be





[PATCH worg] link-fix: fix broken link in ob-doc-gnuplot.org

2024-11-29 Thread Suhail Singh
* org-contrib/babel/languages/ob-doc-gnuplot.org (Introduction): Fix
link to source.
---
 org-contrib/babel/languages/ob-doc-gnuplot.org | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/org-contrib/babel/languages/ob-doc-gnuplot.org 
b/org-contrib/babel/languages/ob-doc-gnuplot.org
index 4bcca41d..d51102d2 100644
--- a/org-contrib/babel/languages/ob-doc-gnuplot.org
+++ b/org-contrib/babel/languages/ob-doc-gnuplot.org
@@ -34,7 +34,7 @@ * Introduction
 usage. Since babel is simply allowing native code to run inside of
 Org-mode, all gnuplot documentation is applicable and valid. [fn:1]
 
-This file may be downloaded here: 
[[https://orgmode.org/worg/sources/org-contrib/babel/examples/org-babel-gnuplot.org][org-babel-gnuplot.org]].
 The image
+This file may be downloaded here: 
[[https://orgmode.org/worg/org-contrib/babel/examples/org-babel-gnuplot.org][org-babel-gnuplot.org]].
 The image
 links are to the images online on Worg, but running the code blocks
 will produce matching images in the same directory as the .org file.
 

base-commit: db73ab050bd884bdc7a062aeb9042f5e659854ff



[PATCH worg] todo.org: Update tasks based on discussion with Ihor.

2024-11-29 Thread Suhail Singh
---
 todo.org | 46 --
 1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/todo.org b/todo.org
index d8ce26d7..e2bd286d 100644
--- a/todo.org
+++ b/todo.org
@@ -25,29 +25,37 @@
 
 * General tasks
 
-** DONE Simplify/merge worg-about.org, worg-maintenance.org, worg-git.org
-** TODO Add a note in files which need an update
-** DONE Update links for 'org-fireforg' in org-devel.org
-** TODO Update doc.org from latest stable
 ** TODO Make a comprehensive list of Org exporters (see 
[[https://list.orgmode.org/87r1r5jvak@gnu.org/][this message]])
+** TODO Complete Babel checklist for languages
+** TODO Write Babel doc to show what value/output returns for each language
+
+See https://list.orgmode.org/87imjyoi99@gnu.org/ for context.
 ** TODO Update org-contrib/babel/languages/ob-doc-ditaa.org
 
 Ditaa is not included in Org anymore.  See
 https://github.com/stathissideris/ditaa.
 
-** TODO Write Babel doc to show what value/output returns for each language
+** TODO improve accessability of the TOC
 
-See https://list.orgmode.org/87imjyoi99@gnu.org/ for context.
+** 
 
+** TODO Add a note in files which need an update
+** TODO Update doc.org from latest stable
 ** TODO BUG: The "how to use git for Worg" link on the index page doesn't link 
correctly to the subheading.
 
 * Work on tutorials
-  
-** TODO Enhance the main tutorial
 ** TODO Add a dedicated file for mobile workflows with org
+- How to browse/view org on web/mobile?
+- How to edit org files on mobile?
+- How to synchronize with mobile?
+- Calendar synchronization
+- Contact synchronization (org-contacts third party)
+** TODO Tutorial about links (export and abbrev)
+- Custom link types
+** TODO Update the tutorial about the LaTeX exporter
+file:./org-tutorials/org-latex-export.org
+** Enhance the main tutorial
 ** Gather examples of custom agenda views from the mailing list
-** Tutorial about links (export and abbrev)
-** Tutorial about the LaTeX exporter
 * Archived tasks
 
 ** DONE Rename this file to todo.org and update references
@@ -85,3 +93,21 @@ ** DONE Remove references to org-install.el
 :ARCHIVE_CATEGORY: worg
 :ARCHIVE_TODO: DONE
 :END:
+
+** DONE Simplify/merge worg-about.org, worg-maintenance.org, worg-git.org
+:PROPERTIES:
+:ARCHIVE_TIME: 2024-10-01 Tue 13:08
+:ARCHIVE_FILE: ~/Documents/projects/worg/todo.org
+:ARCHIVE_OLPATH: General tasks
+:ARCHIVE_CATEGORY: worg
+:ARCHIVE_TODO: DONE
+:END:
+
+** DONE Update links for 'org-fireforg' in org-devel.org
+:PROPERTIES:
+:ARCHIVE_TIME: 2024-10-01 Tue 13:08
+:ARCHIVE_FILE: ~/Documents/projects/worg/todo.org
+:ARCHIVE_OLPATH: General tasks
+:ARCHIVE_CATEGORY: worg
+:ARCHIVE_TODO: DONE
+:END:

base-commit: db73ab050bd884bdc7a062aeb9042f5e659854ff



[PATCH worg v2] ob-doc-gnuplot.org: Fix broken link to source.

2024-11-29 Thread Suhail Singh
* org-contrib/babel/languages/ob-doc-gnuplot.org (Introduction): Fix
link to source.
---
 org-contrib/babel/languages/ob-doc-gnuplot.org | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/org-contrib/babel/languages/ob-doc-gnuplot.org 
b/org-contrib/babel/languages/ob-doc-gnuplot.org
index 4bcca41d..d51102d2 100644
--- a/org-contrib/babel/languages/ob-doc-gnuplot.org
+++ b/org-contrib/babel/languages/ob-doc-gnuplot.org
@@ -34,7 +34,7 @@ * Introduction
 usage. Since babel is simply allowing native code to run inside of
 Org-mode, all gnuplot documentation is applicable and valid. [fn:1]
 
-This file may be downloaded here: 
[[https://orgmode.org/worg/sources/org-contrib/babel/examples/org-babel-gnuplot.org][org-babel-gnuplot.org]].
 The image
+This file may be downloaded here: 
[[https://orgmode.org/worg/org-contrib/babel/examples/org-babel-gnuplot.org][org-babel-gnuplot.org]].
 The image
 links are to the images online on Worg, but running the code blocks
 will produce matching images in the same directory as the .org file.
 

base-commit: db73ab050bd884bdc7a062aeb9042f5e659854ff



[PATCH] org-element.el; significant optimizations for org-element--interpret-affiliated-keywords

2024-11-29 Thread Dwarshuis, Nathan J
Hi all,

I noticed that calling `org-element-interpret-data' on objects is generally 
5-10x faster than when calling on elements. The reason seems to be that 
`org-element--interpret-affiliated-keywords' (which is only called on elements) 
does alot of unnecessary work. Namely, it runs on all elements (including those 
that should never have an affiliated keyword) and also loops over 
:standard-properties which should not be relevant here.

The attached patch addresses this.

I also attached some benchmarks pre and post-patch and accompanying code, which 
shows many elements (specifically those without children) approaching the 
execution time of objects. For the graphs, just pay attention to the 
'org-element' bars (red); the others were from me trying to optimize the 
`org-ml` package.

Thank you,
Nate


>From 1b4fb607bd6e233a15a569960517a9388a80974b Mon Sep 17 00:00:00 2001
From: ndwarshuis 
Date: Mon, 25 Nov 2024 22:04:09 -0500
Subject: [PATCH] org-element.el: Make affiliated keyword interpreter faster

* lisp/org-element.el (org-element--interpret-affiliated-keywords):
Optimize performance by bypassing unnecessary types and reducing
loop complexity. Added new constant
`org-element-elements-no-affiliated` which stores the types to
be bypassed.

This function was doing redundant work on several levels which
dramatically reduced performance of interpreting element nodes
relative to object nodes.

First, all types were interpreted regardless of if they could
possibly contain affiliated keywords. Skipping these types
dramatically speeds up typical use cases since many of these
skipped types are common (headline, item, etc).

Second, the loop was much more complex than needed. The loop included
:standard-properties which should not be necessary here. It also
duplicated some work between calls to `org-element--properties-mapc`
and `mapconcat` (the code was moved entirely under the former). The
result should be faster and more readable.

TINYCHANGE
---
 lisp/org-element.el | 82 +++--
 1 file changed, 42 insertions(+), 40 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 9f8f52745..3b90dce2a 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -335,6 +335,11 @@ specially in `org-element--object-lex'.")
   (append org-element-recursive-objects '(paragraph table-row verse-block))
   "List of object or element types that can directly contain objects.")
 
+(defconst org-element-elements-no-affiliated
+  '(org-data comment clock headline inlinetask item
+ node-property planning property-drawer
+ section table-row))
+
 (defconst org-element-affiliated-keywords
   '("CAPTION" "DATA" "HEADER" "HEADERS" "LABEL" "NAME" "PLOT" "RESNAME" "RESULT"
 "RESULTS" "SOURCE" "SRCNAME" "TBLNAME")
@@ -5517,49 +5522,46 @@ to interpret.  Return Org syntax as a string."
 			  (make-string blank ?\n)
 (funcall fun data nil)))
 
+(defun org-element--keyword-to-org (key value)
+  (let (dual)
+(when (member key org-element-dual-keywords)
+  (setq dual (cdr value) value (car value)))
+(concat "#+" (downcase key)
+(and dual
+ (format "[%s]" (org-element-interpret-data dual)))
+": "
+(if (member key org-element-parsed-keywords)
+(org-element-interpret-data value)
+  value)
+"\n")))
+
 (defun org-element--interpret-affiliated-keywords (element)
   "Return ELEMENT's affiliated keywords as Org syntax.
 If there is no affiliated keyword, return the empty string."
-  (let ((keyword-to-org
-	 (lambda (key value)
-	   (let (dual)
-	 (when (member key org-element-dual-keywords)
-	   (setq dual (cdr value) value (car value)))
-	 (concat "#+" (downcase key)
-		 (and dual
-			  (format "[%s]" (org-element-interpret-data dual)))
-		 ": "
-		 (if (member key org-element-parsed-keywords)
-			 (org-element-interpret-data value)
-		   value)
-		 "\n")
-(mapconcat
- (lambda (prop)
-   (let ((value (org-element-property prop element))
-	 (keyword (upcase (substring (symbol-name prop) 1
-	 (when value
-	   (if (or (member keyword org-element-multiple-keywords)
-		   ;; All attribute keywords can have multiple lines.
-		   (string-match-p "^ATTR_" keyword))
-	   (mapconcat (lambda (line) (funcall keyword-to-org keyword line))
-			  value "")
-	 (funcall keyword-to-org keyword value)
- ;; List all ELEMENT's properties matching an attribute line or an
- ;; affiliated keyword, but ignore translated keywords since they
- ;; cannot belong to the property list.
- (let (acc)
-   (org-element-properties-mapc
-(lambda (prop _ __)
-  (let  ((keyword (upcase (substring (symbol-name prop) 1
-(when (or (string-match-p "^ATTR_" keyword)
-		  (and
-		   (member keyword org-element-affiliated-keywords)
-		   (not (assoc keyword
-	

Re: Plotting a table of date+time pairs

2024-11-29 Thread Michael Heerdegen
Michael Heerdegen  writes:

> I now have one remaining problem: my time values in the second column
> contain the name of the time zone - the purpose is to flag the time as
> summer or winter time.  Currently I need to remove these indicators from
> the table, else plotting fail, gnuplot doesn't understand the data.

I could adjust `org-table-number-regexp' - this makes plotting succeed.
Unfortunately does "ob-gnuplot" not respect a buffer local binding of
that variable (in the org buffer containing the table).  I need to
change the global binding of that variable.


Michael.



Re: Plotting a table of date+time pairs

2024-11-29 Thread Michael Heerdegen
"Fraga, Eric"  writes:

> Sure, see attached.  This example has a table of data to plot (simple
> example with two columns) and the gnuplot src block to create a PDF
> plot.  You invoke gnuplot by typing C-c C-c in the src block.  You can
> then view the result with C-c C-o.
> [...]

Ok... I had to (require 'ob-gnuplot), but then the example worked fine.
It took a while but I got my own table work as well, more or less (see
below).

Thank you very much!


"Max Nikulin"  writes:

> 

Very nice overview and reference, thank you very much as well.

I now have one remaining problem: my time values in the second column
contain the name of the time zone - the purpose is to flag the time as
summer or winter time.  Currently I need to remove these indicators from
the table, else plotting fail, gnuplot doesn't understand the data.

Can I tell "ob-gnuplot" to export the table in a different way - how?

The time zone makes a difference when exporting since the generated
data file has a different format: the time fields including the timezone
get wrapped in quotation marks, without time zone they are exported
literally.


Thanks again,

Michael.