Re: [PATCH] org-table-import: Make it more smarter for interactive use

2021-04-22 Thread Utkarsh Singh
Hi,

On 2021-04-20, 15:40 +0200, Nicolas Goaziou  wrote:

> Again all this needs to extensively tested, as there are a lot of
> dangers lurking around.

I am attaching my patch which also include my previous suggestion of
including yes-or-no prompt to org-table-import to allow file which don't
have csv, tsv or txt as extension.  Here are some concerns
with require your attention:

+ When using org-table-import interactively if we failed to guess
separator then we will be left with a user-error message and an
'unconverted table'.  We can make use of 'temp-buffer' to import our
file after successfully conversion.

+ Conversion part of org-table-convert-region make a distinction between
'(4) (comma separator) and rest of the separator we should either string
version of comma as AND condition or rewrite to simplify it.

I am willing to do these possible changes but currently waiting for your
review for org-table-guess-separator as there can be more serious bugs
lurking around on my code which I am considering base for these changes.

All the best,
Utkarsh

diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el
index 0e93fb271f..84bc981fec 100644
--- a/lisp/org/org-table.el
+++ b/lisp/org/org-table.el
@@ -846,6 +846,42 @@ org-table-create
   (goto-char pos))
 (org-table-align)))
 
+
+(defun org-table-guess-separator (beg0 end0)
+  "Guess separator for `org-table-convert-region' for region BEG0 to END0.
+
+List of preferred separator:
+comma, TAB, semicolon, colon or SPACE.
+
+If region contains a line which doesn't contain the required
+separator then discard the separator and search again using next
+separator."
+  (let* ((beg (save-excursion
+(goto-char (min beg0 end0))
+(skip-chars-forward " \t\n")
+(if (eobp) (point) (line-beginning-position
+	 (end (save-excursion
+(goto-char (max beg end0))
+(skip-chars-backward " \t\n" beg)
+(if (= beg (point)) (point) (line-end-position
+ (sep-regexp '((","  (rx bol (1+ (not (or ?\n ?,))) eol))
+		   ("\t" (rx bol (1+ (not (or ?\n ?\t))) eol))
+		   (";"  (rx bol (1+ (not (or ?\n ?\;))) eol))
+		   (":"  (rx bol (1+ (not (or ?\n ?:))) eol))
+		   (" "  (rx bol (1+ (not (or ?' ?\" ))
+ (not (or ?\s ?\;))
+ (not (or ?' ?\"))) eol
+ sep)
+(unless (= beg end)
+  (save-excursion
+(goto-char beg)
+(catch :found
+  (pcase-dolist (`(,sep ,regexp) sep-regexp)
+(save-excursion
+  (unless (re-search-forward (eval regexp) end t)
+(throw :found sep
+  nil)
+
 ;;;###autoload
 (defun org-table-convert-region (beg0 end0 &optional separator)
   "Convert region to a table.
@@ -859,20 +895,19 @@ org-table-convert-region
 (4) Use the comma as a field separator
 (16)Use a TAB as field separator
 (64)Prompt for a regular expression as field separator
-integer  When a number, use that many spaces, or a TAB, as field separator
-regexp   When a regular expression, use it to match the separator
-nil  When nil, the command tries to be smart and figure out the
- separator in the following way:
- - when each line contains a TAB, assume TAB-separated material
- - when each line contains a comma, assume CSV material
- - else, assume one or more SPACE characters as separator."
+integer When a number, use that many spaces, or a TAB, as field separator
+regexp  When a regular expression, use it to match the separator
+nil When nil, the command tries to be smart and figure out the
+separator using `org-table-guess-seperator'."
   (interactive "r\nP")
   (let* ((beg (min beg0 end0))
 	 (end (max beg0 end0))
 	 re)
+
 (if (> (count-lines beg end) org-table-convert-region-max-lines)
 	(user-error "Region is longer than `org-table-convert-region-max-lines' (%s) lines; not converting"
 		org-table-convert-region-max-lines)
+
   (when (equal separator '(64))
 	(setq separator (read-regexp "Regexp for field separator")))
   (goto-char beg)
@@ -881,17 +916,13 @@ org-table-convert-region
   (goto-char end)
   (if (bolp) (backward-char 1) (end-of-line 1))
   (setq end (point-marker))
-  ;; Get the right field separator
-  (unless separator
-	(goto-char beg)
-	(setq separator
-	  (cond
-	   ((not (re-search-forward "^[^\n\t]+$" end t)) '(16))
-	   ((not (re-search-forward "^[^\n,]+$" end t)) '(4))
-	   (t 1
+  (when (and (not separator)
+ (not (setq separator
+(org-table-guess-separator (beg end)
+(user-error "Failed to guess separator"))
   (goto-char beg)
   (if (equal separator '(4))
-	  (while (< (point) end)
+  (while (< (point) end)
 	;; parse the csv stuff
 	(cond
 	 ((looking-at "^") (insert "

Manual on web site is not the latest version

2021-04-22 Thread William Denton
Mentioning this again for fresh attention to whoever can push an update:  the 
online manual is older than the version in the source tree.


I noticed this from the Working with Source Code / Languages section.  For 
example, the source org-manual.org file says, "Code blocks in dozens of 
languages are supported," with a working link.  The web site says, "Code blocks 
in the following languages are supported," with an outdated link.


Thanks,

Bill


On 29 March 2021, William Denton wrote:

I was looking at this page and noticed that the link to worg should be 
updated:


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

I looked at the source documentation in Git and was surprised to see that 
what's there is different:  some sentences were reworded and the link was 
updated.  So it's already been fixed, but can't be seen!


I didn't check the entire manual, but at least this one page is out of date, 
so I'm reporting it.


Thanks,

Bill
--
William Denton :: Toronto, Canada   ---   Listening to Art: 
https://listeningtoart.org/

https://www.miskatonic.org/ ---   GHG.EARTH: https://ghg.earth/
Caveat lector.  ---   STAPLR: https://staplr.org/



--
William Denton :: Toronto, Canada   ---   Listening to Art: 
https://listeningtoart.org/
https://www.miskatonic.org/ ---   GHG.EARTH: https://ghg.earth/
Caveat lector.  ---   STAPLR: https://staplr.org/



Re: Idea for handling timezones

2021-04-22 Thread Shironeko
Hi all,

I originally thought having the timezone in the header of the file would make
things simpler, since it meant all the timestamp would be in the same timezone,
rather than potentially different ones. But it seems that that might not be
inline with how others use their org files.

org actually already has a keyword for a per entry timezone, 
https://orgmode.org/manual/iCalendar-Export.html
The problem with it is that no other facility of org plugs into that, it only
counts when exporting into other calendar systems, which I think is strange. If
it is indeed better to be able to set timezone per entry, then I think
supporting this properly in org would be best.

Only having CST etc timezone abbreviations is indeed problematic, because it is
ambiguous and kinda difficult to enter, also people don't necessarily
communicate with the correct designation (maybe they mean EDT but used EST, but
the time is unambiguously EDT).

With repeat tasks I don't think it would be a problem for tasks that repeats
daily or longer (since by definition they add to the day/month/year directly,
not counting how many days there are in a month for example). For hourly
repeating tasks it is indeed ambiguous, but I don't have an idea on what would
be better. Maybe people that have those can chime in.

Best,
Shironeko




Re: Bug: JavaScript in HTML export not recognized by LibreJS as free [9.4.5 (9.4.5-16-g94be20-elpaplus @ /home/jorge/.config/emacs/elpa/org-plus-contrib-20210412/)]

2021-04-22 Thread Anthony Carrico

On 4/22/21 4:29 PM, Anthony Carrico wrote:
Practically speaking, the script included by org-mode is in the public 
domain, so it could never conflict with whatever license the author 
chooses. Therefore, we should remove the LibreJS tag from the 

[PATCH] Org-mode publish avoids inserting script license tag into target documents

2021-04-22 Thread Anthony Carrico
>From 8f86d82b6784d26d8af86de01adcf333ee81148b Mon Sep 17 00:00:00 2001
From: Anthony Carrico 
Date: Thu, 22 Apr 2021 17:32:59 -0400
Subject: [PATCH] Org-mode publish avoids inserting script license tag into
 target documents

* ox-html.el: In previous versions, org-export included a script
  license tag which created a conflict for authors exporting documents
  for use with the LibreJS web filter. The script is in the public
  domain, and does not conflict with any LibreJS license notice that
  authors may include at the top of their page, so a separate license
  in the  is unnecessary and was removed.

This entire patch is released to the public domain by its author, Anthony 
Carrico.  TINYCHANGE
---
 lisp/ox-html.el | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index d2f24f5c6..15ab15c34 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -233,7 +233,6 @@ property on the headline itself.")
 
 (defconst org-html-scripts
   "