[PATCH] Auto-complete PRINT_BIBLIOGRAPHY with a trailing colon

2024-05-02 Thread Rudolf Adamkovič
* lisp/org.el (org-options-keywords): Add a trailing colon to the
'PRINT_BIBLIOGRAPHY' keyword to avoid unnecessary user confusion.
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index a3d0c4547..ccf552aeb 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9048,7 +9048,7 @@ keywords relative to each registered export backend."
   '("ARCHIVE:" "AUTHOR:" "BIBLIOGRAPHY:" "BIND:" "CATEGORY:" "CITE_EXPORT:"
 "COLUMNS:" "CREATOR:" "DATE:" "DESCRIPTION:" "DRAWERS:" "EMAIL:"
 "EXCLUDE_TAGS:" "FILETAGS:" "INCLUDE:" "INDEX:" "KEYWORDS:" "LANGUAGE:"
-"MACRO:" "OPTIONS:" "PROPERTY:" "PRINT_BIBLIOGRAPHY" "PRIORITIES:"
+"MACRO:" "OPTIONS:" "PROPERTY:" "PRINT_BIBLIOGRAPHY:" "PRIORITIES:"
 "SELECT_TAGS:" "SEQ_TODO:" "SETUPFILE:" "STARTUP:" "TAGS:" "TITLE:" "TODO:"
 "TYP_TODO:" "SELECT_TAGS:" "EXCLUDE_TAGS:" "EXPORT_FILE_NAME:"))
 
-- 
2.44.0




Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-05-02 Thread Rudolf Adamkovič
Rudolf Adamkovič  writes:

> I am attaching a V2 of the patch that:

Oops, I forgot to attach the patch.  Here it is. :)

Rudy
>From b4d61bf511df74094fbcdf13c8c0c2b57b1e4a22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Mon, 29 Apr 2024 21:42:04 +0200
Subject: [PATCH] ob-lua: Quote list-like strings, sort tables, and parse bare
 returns

* lisp/ob-lua.el (org-babel-lua-wrapper-method): 3 changes: (1) Quote
strings with list-like content to prevent Org Babel from incorrectly
guessing their type, (2) sort pretty-printed non-sequential tables to
make them reproducible, and (3) handle implicit nils produced by
'return' used with no arguments.
* testing/lisp/test-ob-lua.el (test-ob-lua/result/nil):
(test-ob-lua/result/nil/explicit):
(test-ob-lua/result/boolean):
(test-ob-lua/results/number/integer):
(test-ob-lua/results/number/integer/negative):
(test-ob-lua/results/number/integer/multiple):
(test-ob-lua/results/number/real):
(test-ob-lua/results/number/real/multiple):
(test-ob-lua/results/number/infinity):
(test-ob-lua/results/string/single-quotes):
(test-ob-lua/results/string/double-quotes):
(test-ob-lua/results/string/multiple):
(test-ob-lua/results/string/list-like):
(test-ob-lua/results/string/list-like/brackets):
(test-ob-lua/results/string/list-like/curlies):
(test-ob-lua/results/string/list-like/standard-output):
(test-ob-lua/result/table):
(test-ob-lua/result/table/pretty-print):
(test-ob-lua/result/table/pretty-print/sorted):
(test-ob-lua/results/value-separator): New tests.
---
 lisp/ob-lua.el  |  49 +--
 testing/lisp/test-ob-lua.el | 278 
 2 files changed, 284 insertions(+), 43 deletions(-)

diff --git a/lisp/ob-lua.el b/lisp/ob-lua.el
index 041abfabc..19950f2cb 100644
--- a/lisp/ob-lua.el
+++ b/lisp/ob-lua.el
@@ -254,33 +254,40 @@ then create.  Return the initialized session."
 (defvar org-babel-lua-wrapper-method
   "
 function main()
-%s
+   %s
 end
 
 function dump(it, indent)
if indent == nil then
   indent = ''
end
+
if type(it) == 'table' and %s then
-  local count = 0
-  for _ in pairs(it) do
- count = count + 1
-  end
   local result = ''
+
   if #indent ~= 0 then
  result = result .. '\\n'
   end
-  for key, value in pairs(it) do
+
+  local keys = {}
+  for key in pairs(it) do
+ table.insert(keys, key)
+  end
+
+  table.sort(keys)
+
+  for index, key in pairs(keys) do
+ local value = it[key]
  result = result
 .. indent
 .. dump(key)
 .. ' = '
 .. dump(value, indent .. '  ')
- count = count - 1
- if count ~= 0 then
+ if index ~= #keys then
 result = result .. '\\n'
  end
   end
+
   return result
else
   return tostring(it)
@@ -288,11 +295,27 @@ function dump(it, indent)
 end
 
 function combine(...)
-  local result = {}
-  for index = 1, select('#', ...) do
-result[index] = dump(select(index, ...))
-  end
-  return table.concat(result, '%s')
+   local quotes = '\"'
+   local result = {}
+
+   for index = 1, select('#', ...) do
+  result[index] = dump(select(index, ...))
+   end
+
+   if #result == 0 then
+  return dump(nil)
+   end
+
+   if #result == 1 then
+  local value = result[1]
+  if string.find(value, '[%%(%%[{]') == 1 then
+ return quotes .. value .. quotes
+  else
+ return value
+  end
+   end
+
+   return quotes .. table.concat(result, '%s') .. quotes
 end
 
 output = io.open('%s', 'w')
diff --git a/testing/lisp/test-ob-lua.el b/testing/lisp/test-ob-lua.el
index 0a60c68ca..a0a3b178c 100644
--- a/testing/lisp/test-ob-lua.el
+++ b/testing/lisp/test-ob-lua.el
@@ -136,45 +136,263 @@ return x
 	(org-babel-next-src-block)
 	(org-babel-execute-src-block)
 
-(ert-deftest test-ob-lua/types ()
-  "Test returning different types."
+(ert-deftest test-ob-lua/result/nil ()
+  "Test returning nothing."
   (should
-   (equal "nil"
-  (org-test-with-temp-text "src_lua{return nil}"
-(org-babel-execute-src-block
+   (equal
+"src_lua{return} {{{results(=nil=)}}}"
+(org-test-with-temp-text "src_lua{return}"
+  (org-babel-execute-src-block)
+  (buffer-substring-no-properties (point-min)
+  (point-max))
+
+(ert-deftest test-ob-lua/result/nil/explicit ()
+  "Test returning nothing explicitly."
+  (should
+   (equal
+"src_lua{return nil} {{{results(=nil=)}}}"
+(org-test-with-temp-text "src_lua{return nil}"
+  (org-babel-execute-src-block)
+  (buffer-substring-no-properties (point-min)
+  (point-max))
+
+(ert-deftest test-ob-lua/result/boolean ()
+  "Test returning the boolean values true and false."
+

Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-05-02 Thread Rudolf Adamkovič
Max Nikulin  writes:

> On 30/04/2024 03:26, Rudolf Adamkovič wrote:
>> +local value = result[1]
>> +if string.find(value, '[%%(%%[{]') == 1 then
>> +  return quotes .. value .. quotes
>
> Am I wrong that quotes in value may cause issues? I expect some way of
> escaping " characters.

What would the reproduction steps look like?

Rudy
-- 
"It is far better to have a question that can't be answered than an answer that
can't be questioned."
--- Carl Sagan

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-05-02 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> May you please elaborate why this breaking change is going to lead to
> significant improvement? How is using "," worse than using "|"? Either
> way, strings containing the separator will become problematic and need
> to be escaped. Moreover, using "|" may lead to interpreting the output
> as Org tables, which may be surprising to users.

Thank you for the review!

The change of the separator was a lazy move on my part.  I appologize.
I changed the separator because I could not figure out how to make Org
behave sanely.  The problem is not specific to Lua:

  src_elisp{"3, 2, 1, and go!"} {{{results(=3\, 2\, 1\, and go!=)}}}

Why Org is escaping commas here?  In other words, should my tests expect
\-escapes in front of commas, or is that a bug?

I am attaching a V2 of the patch that:

- does not modify the separator anymore (resulting in 3 failing tests)
- adds one more test (which is just a sanity check, you can ignore it)
- fixes Lua code indentation (as indented by the Lua major mode)

Thank you for your guidance.

Rudy
-- 
"Be especially critical of any statement following the word
'obviously.'"
--- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-05-02 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> May you please elaborate why this breaking change is going to lead to
> significant improvement? How is using "," worse than using "|"? Either
> way, strings containing the separator will become problematic and need
> to be escaped. Moreover, using "|" may lead to interpreting the output
> as Org tables, which may be surprising to users.

Thank you for the review!

The change of the separator was a lazy move on my part.  I appologize.
I changed the separator because I could not figure out how to make Org
behave sanely.  The problem is not specific to Lua:

  src_elisp{"3, 2, 1, and go!"} {{{results(=3\, 2\, 1\, and go!=)}}}

Why Org is escaping commas here?  In other words, should my tests expect
\-escapes in front of commas, or is that a bug?

I am attaching a V2 of the patch that:

- does not modify the separator anymore (resulting in 3 failing tests)
- adds one more test (which is just a sanity check, you can ignore it)
- fixes Lua code indentation (as indented by the Lua major mode)

Thank you for your guidance.

Rudy
-- 
"Be especially critical of any statement following the word
'obviously.'"
--- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-04-29 Thread Rudolf Adamkovič
Rudolf Adamkovič  writes:

> Definitely!  I am on it.

All right, how about the attached patch?

Rudy

>From 40270bc62f951cfd20916c17e2dfc52863d6b8e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Mon, 29 Apr 2024 21:42:04 +0200
Subject: [PATCH] ob-lua: Quote list-like strings, sort tables, and parse bare
 returns

* lisp/ob-lua.el (org-babel-lua-multiple-values-separator): Change the
default value from ", " to "|" to avoid '\\,' appearing in strings.
(org-babel-lua-wrapper-method): Improve 3 aspects: (1) Quote strings
with list-like content to prevent Org Babel from incorrectly guessing
their type, (2) sort pretty-printed non-sequential tables to make them
reproducible, and (3) handle implicit nils produced by 'return' used
with no arguments.
* testing/lisp/test-ob-lua.el (test-ob-lua/result/nil):
(test-ob-lua/result/nil/explicit):
(test-ob-lua/result/boolean):
(test-ob-lua/results/number/integer):
(test-ob-lua/results/number/integer/negative):
(test-ob-lua/results/number/integer/multiple):
(test-ob-lua/results/number/real):
(test-ob-lua/results/number/real/multiple):
(test-ob-lua/results/number/infinity):
(test-ob-lua/results/string/single-quotes):
(test-ob-lua/results/string/double-quotes):
(test-ob-lua/results/string/multiple):
(test-ob-lua/results/string/list-like):
(test-ob-lua/results/string/list-like/brackets):
(test-ob-lua/results/string/list-like/curlies):
(test-ob-lua/result/table):
(test-ob-lua/result/table/pretty-print):
(test-ob-lua/result/table/pretty-print/sorted):
(test-ob-lua/results/value-separator): New tests.
---
 lisp/ob-lua.el  |  41 --
 testing/lisp/test-ob-lua.el | 264 
 2 files changed, 266 insertions(+), 39 deletions(-)

diff --git a/lisp/ob-lua.el b/lisp/ob-lua.el
index 041abfabc..5a0fdb18b 100644
--- a/lisp/ob-lua.el
+++ b/lisp/ob-lua.el
@@ -81,7 +81,7 @@ This will typically be `lua-mode'."
   :package-version '(Org . "8.3")
   :type 'symbol)
 
-(defcustom org-babel-lua-multiple-values-separator ", "
+(defcustom org-babel-lua-multiple-values-separator "|"
   "Separate multiple values with this string."
   :group 'org-babel
   :package-version '(Org . "9.7")
@@ -261,26 +261,33 @@ function dump(it, indent)
if indent == nil then
   indent = ''
end
+
if type(it) == 'table' and %s then
-  local count = 0
-  for _ in pairs(it) do
- count = count + 1
-  end
   local result = ''
+
   if #indent ~= 0 then
  result = result .. '\\n'
   end
-  for key, value in pairs(it) do
+
+  local keys = {}
+  for key in pairs(it) do
+table.insert(keys, key)
+  end
+
+  table.sort(keys)
+
+  for index, key in pairs(keys) do
+ local value = it[key]
  result = result
 .. indent
 .. dump(key)
 .. ' = '
 .. dump(value, indent .. '  ')
- count = count - 1
- if count ~= 0 then
+ if index ~= #keys then
 result = result .. '\\n'
  end
   end
+
   return result
else
   return tostring(it)
@@ -288,11 +295,27 @@ function dump(it, indent)
 end
 
 function combine(...)
+  local quotes = '\"'
   local result = {}
+
   for index = 1, select('#', ...) do
 result[index] = dump(select(index, ...))
   end
-  return table.concat(result, '%s')
+
+  if #result == 0 then
+return dump(nil)
+  end
+
+  if #result == 1 then
+local value = result[1]
+if string.find(value, '[%%(%%[{]') == 1 then
+  return quotes .. value .. quotes
+else
+  return value
+end
+  end
+
+  return quotes .. table.concat(result, '%s') .. quotes
 end
 
 output = io.open('%s', 'w')
diff --git a/testing/lisp/test-ob-lua.el b/testing/lisp/test-ob-lua.el
index 0a60c68ca..775a5cf14 100644
--- a/testing/lisp/test-ob-lua.el
+++ b/testing/lisp/test-ob-lua.el
@@ -136,45 +136,249 @@ return x
 	(org-babel-next-src-block)
 	(org-babel-execute-src-block)
 
-(ert-deftest test-ob-lua/types ()
-  "Test returning different types."
+(ert-deftest test-ob-lua/result/nil ()
+  "Test returning nothing."
   (should
-   (equal "nil"
-  (org-test-with-temp-text "src_lua{return nil}"
-(org-babel-execute-src-block
+   (equal
+"src_lua{return} {{{results(=nil=)}}}"
+(org-test-with-temp-text "src_lua{return}"
+  (org-babel-execute-src-block)
+  (buffer-substring-no-properties (point-min)
+  (point-max))
+
+(ert-deftest test-ob-lua/result/nil/explicit ()
+  "Test returning nothing explicitly."
+  (should
+   (equal
+"src_lua{return nil} {{{results(=nil=)}}}"
+(org-test-with-temp-text "src_lua{return nil}"
+  (org-babel-execute-src-block)
+  (buffer-substring-no-properties (po

Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-04-29 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

>> We need *better tests*, otherwise all this is kind of useless.
>>
>> I will hack on this some more...
>
> Will you be willing to provide some?

Definitely!  I am on it.

Rudy
-- 
"Genius is 1% inspiration and 99% perspiration."
--- Thomas Alva Edison, 1932

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: Cant expand a heading with tab : Subtree (no children)

2024-04-27 Thread Rudolf Adamkovič
Jonathan Gregory  writes:

> I see this too.

+1 here.

Rudy
-- 
"Thinking is a momentary dismissal of irrelevancies."
--- Richard Buckminster Fuller, 1969

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-04-27 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Maybe something like the attached.

Nice:

  src_elisp{"foo"} {{{results(=foo=)}}}
  src_python{return "foo"} {{{results(=foo=)}}}
  src_lua{return "foo"} {{{results(=foo=)}}}

That said, I have just noticed:

  # expected: a, b, c
  src_lua{return "a", "b", "c"} {{{results(="a"  "b"  "c"=)}}}

  # expected: 1, 2
  src_lua{return 1, 2} {{{results(=1\, 2=)}}}

Oops!

We need *better tests*, otherwise all this is kind of useless.

I will hack on this some more...

Rudy
-- 
"Thinking is a momentary dismissal of irrelevancies."
--- Richard Buckminster Fuller, 1969

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-04-24 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> May you create a test for this with expected failure?

Sure!  Here is one:

  (should
   (equal "{B}"
  (org-test-with-temp-text
  "src_lua{return string.match('A {B} C', '%b{}')}"
(org-babel-execute-src-block

The return value from 'string.match' is the substring "{B}", which Babel
misjudges to be a list and signals the error:

  (user-error "Inline error: list result cannot be used")

> Applied, onto main, after [...]

Thank you, Ihor!

Rudy
-- 
"I do not fear death.  I had been dead for billions and billions of
years before I was born, and had not suffered the slightest
inconvenience from it."  --- Mark Twain, paraphrased

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-04-23 Thread Rudolf Adamkovič
Rudolf Adamkovič  writes:

> +Lua code blocks can now return values of any type and can also return
> +multiple values.  Previously, values of certain types were incorrectly
> +converted to the empty string =""=, which broke HTML export for inline
> +code blocks, and multiple values were incorrectly concatenated, where
> +~return 1, 2, 3~ was evaluated as =123=.

Also,

  #+BEGIN_SRC lua
  return {1, 2, 3}
  #+END_SRC

previously crashed, as did

  #+BEGIN_SRC lua
  function divide()
 error("oops")
 return divident / divisor
  end
  return pcall(oops)
  #+END_SRC

All that works now, with no more crashes.

P.S. #1

We still have an old bug where

  src_lua{return string.match("A {B} C", "%b{}")}

is misjudged to be a table:

  org-babel-insert-result: Inline error: list result cannot be used

P.S. #2

I did not update any session-related code.

Currently,

  #+BEGIN_SRC lua :session x
  print 1
  #+END_SRC

gives

  ... Sessions currently not supported, work in progress

This is also documented in the header

  ;; Requirements:
  ;; for session support, lua-mode is needed.
  ;; [...]
  ;; However, sessions are not yet working.

This half-finished session support should be removed, IMHO.

If someone needs it and are willing to finish it, they can still dig it
up it in the history.  That is what VC is for, after all.

As of now, all that session-related dead code only pollutes the file,
making it harder to change, as it drifts out of sync...

Rudy
-- 
"All you have to do is write one true sentence.  Write the truest
sentence that you know."  --- Ernest Miller Hemingway (1899-1961)

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



[PATCH] ob-lua: Support all types and multiple values in results

2024-04-23 Thread Rudolf Adamkovič
* etc/ORG-NEWS
(New and changed options): Describe the new option
'org-babel-lua-multiple-values-separator'.
(New features): Describe the main change, as per the title of this
commit message.
* lisp/ob-lua.el
(org-babel-lua-multiple-values-separator): Enable the user to
customize the string that separates the individual values in
multi-valued returns.
(org-babel-lua-wrapper-method): Support all Lua types and multi-valued
returns.  Further, do not pretty-print tables with one or more
extraneous newline characters.
(org-babel-lua-pp-wrapper-method): Remove in favor of the new, more
general 'org-babel-lua-wrapper-method'.
(org-babel-lua-evaluate-external-process): Adapt for the new
'org-babel-lua-wrapper-method'.
* testing/lisp/test-ob-lua.el
(test-ob-lua/colnames-yes-header-argument-pp):
(test-ob-lua/colnames-nil-header-argument):
(test-ob-lua/colnames-no-header-argument): Stop expecting extraneous
newlines, now that the pretty printer does not output them.
(test-ob-lua/types): Test nil, boolean, number, string, and table
results.
(test-ob-lua/multiple-values): Test multi-valued results.
---
 etc/ORG-NEWS| 17 +
 lisp/ob-lua.el  | 73 ++---
 testing/lisp/test-ob-lua.el | 48 ++--
 3 files changed, 105 insertions(+), 33 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index fc2ff9e00..696f46e53 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -637,6 +637,11 @@ link when storing any type of external link type in an Org 
file, not
 just =id:= links.
 
 ** New and changed options
+*** ~org-babel-lua-multiple-values-separator~
+
+The string that separates the values of multi-valued results returned
+from Lua code blocks.
+
 *** =.avif= images are now recognized in ~org-html-inline-image-rules~
 
 In =ox-html=, =.avif= image links are now inlined by default.
@@ -1012,6 +1017,18 @@ The option can be customized either by
 2. by setting the file local keyword =LATEX_FOOTNOTE_COMMAND=
 
 ** New features
+*** =ob-lua=: Support all types and multiple values in results
+
+Lua code blocks can now return values of any type and can also return
+multiple values.  Previously, values of certain types were incorrectly
+converted to the empty string =""=, which broke HTML export for inline
+code blocks, and multiple values were incorrectly concatenated, where
+~return 1, 2, 3~ was evaluated as =123=.
+
+Multiple values are comma-separated by default, so that they work well
+with inline code blocks.  To change the string used as the separator,
+customize ~org-babel-lua-multiple-values-separator~.
+
 *** ~org-paste-subtree~ now handles =C-u= and =C-u C-u= prefix arguments 
specially
 
 With =C-u= prefix argument, force inserting a sibling heading below.
diff --git a/lisp/ob-lua.el b/lisp/ob-lua.el
index b241fccdc..92a1b3344 100644
--- a/lisp/ob-lua.el
+++ b/lisp/ob-lua.el
@@ -81,6 +81,13 @@ This will typically be `lua-mode'."
   :package-version '(Org . "8.3")
   :type 'symbol)
 
+(defcustom org-babel-lua-multiple-values-separator ", "
+  "Separate multiple values with this string."
+  :group 'org-babel
+  :version "30.0"
+  :package-version '(Org . "9.7")
+  :type 'string)
+
 (defun org-babel-execute:lua (body params)
   "Execute Lua BODY according to PARAMS.
 This function is called by `org-babel-execute-src-block'."
@@ -251,41 +258,47 @@ function main()
 %s
 end
 
-fd=io.open(\"%s\", \"w\")
-fd:write( main() )
-fd:close()")
-(defvar org-babel-lua-pp-wrapper-method
-  "
--- table to string
-function t2s(t, indent)
+function dump(it, indent)
if indent == nil then
-  indent = \"\"
+  indent = ''
end
-   if type(t) == \"table\" then
-  ts = \"\"
-  for k,v in pairs(t) do
- if type(v) == \"table\" then
-ts = ts .. indent .. t2s(k,indent .. \"  \") .. \" = \\n\" ..
-   t2s(v, indent .. \"  \")
- else
-ts = ts .. indent .. t2s(k,indent .. \"  \") .. \" = \" ..
-   t2s(v, indent .. \"  \") .. \"\\n\"
+   if type(it) == 'table' and %s then
+  local count = 0
+  for _ in pairs(it) do
+ count = count + 1
+  end
+  local result = ''
+  if #indent ~= 0 then
+ result = result .. '\\n'
+  end
+  for key, value in pairs(it) do
+ result = result
+.. indent
+.. dump(key)
+.. ' = '
+.. dump(value, indent .. '  ')
+ count = count - 1
+ if count ~= 0 then
+result = result .. '\\n'
  end
   end
-  return ts
+  return result
else
-  return tostring(t)
+  return tostring(it)
end
 end
 
-
-function main()
-%s
+function combine(...)
+  local result = {}
+  for index = 1, select('#', ...) do
+result[index] = dump(select(index, ...))
+  end
+  return table.concat(result, '%s')
 end
 
-fd=io.open(\"%s\", \"w\")
-fd:write(t2s(main()))
-fd:close()")
+output = io.open('%s', 'w')
+output:write(combine(main()))

Re: Radio links work only in small numbers

2024-04-04 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Thanks for testing!
> Applied, onto main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=341a01a07
> Fixed.

Thanks everyone for chiming in and fixing the problem.  I have been
unexpectedly busy lately, hence the radio silence [pun intended].

Great work!

Rudy
-- 
"The whole science is nothing more than a refinement of everyday
thinking."  --- Albert Einstein, 1879-1955

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: [PATCH] org-faq.org: rename org-export-htmlize-* options to org-html-htmlize-*

2024-04-04 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

While you are on it, ...

> +Normally, when you export an agenda view from within emacs, htmlize
> +will convert your face definitions to direct color css styles inlined

emacs -> Emacs (per English, and to match Org in the same sentence)
css -> CSS (per English, and to match HTML in the same sentence)

> +supply custom css styles to make these classes look any way you like.
> +To generate face definitions for a CSS file based on any faces you are
> +currently using in Emacs, you can use the following command:

css -> CSS (per English, and to match CSS in the next sentence)

Rudy
-- 
"It is far better to have a question that can't be answered than an
answer that can't be questioned."  --- Carl Sagan

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: Pending contents in org documents (Re: Asynchronous blocks for everything (was Re: ...))

2024-03-30 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

>> I've found a better name: I'm now calling it a "lock".  So I renamed
>> "PENREG" into "REGLOCK" as "region lock".  The structure is now
>> `org-pending-reglock'.
>
> I slightly dislike short names and would prefer region-lock, but not a
> big deal - it is just my personal style preference.

+1 for the full name.

Searching 'M-x' for 'region' gives 229 results on my Emacs, so there is
a precedent.  In fact, when I first read the name 'reglock', I took
'reg' for *not* a region, but register or registry, precisely because
Emacs consistently spells the word out in full.

Rudy
-- 
"I love deadlines.  I love the whooshing noise they make as they go by."
--- Douglas Adams, The Salmon of Doubt, 2002

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: #6 [[bbb:OrgMeetup]] on Wed, Feb 14, 19:00 UTC+3

2024-02-18 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> The email you are replying to has been submitted on January 30, two
> weeks before Feb 14.

Oopsie!  My apologies for the noise, Ihor.

Rudy
-- 
"The whole science is nothing more than a refinement of everyday
thinking."
--- Albert Einstein, 1879-1955

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: #6 [[bbb:OrgMeetup]] on Wed, Feb 14, 19:00 UTC+3

2024-02-17 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Another OrgMeetup will be scheduled on the second Wednesday of
> February, in two weeks.

Wait, ... the date of your message is "the second Wednesday of February"
(Feb 14).  Did you mean "the *fourth* Wednesday of February" (Feb 28),
which is "in two weeks" from Feb 14, or perhaps you meant "the second
Wednesday of *March*" (Mar 13), which is "in four weeks and one day"
from Feb 14?

Rudy
-- 
"'Obvious' is all too often a synonym for 'wrong'."
--- Jeff Erickson, Algorithms, 2019

Rudolf Adamkovič  [he/him]
Studenohorská 25, 84103 Bratislava, Slovakia, European Union



Re: Why not enable extra keys by default?

2024-01-12 Thread Rudolf Adamkovič
Dear Ihor,

Thank you for taking the time to explain the matter to me.

All is clear now!

Rudy
-- 
"Simplicity is complexity resolved."
--- Constantin Brâncuși, 1876-1957

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Moving to the next heading does not always work

2024-01-12 Thread Rudolf Adamkovič
REPRODUCTION STEPS:

1. Launch 'emacs -Q'.
2. Create a new Org file:

* 1
:PROPERTIES:
:CUSTOM_ID: foo
:END:
* [[#foo][foo]] 2
* 3

3. Open the newly created Org file.
3. Type M-x org-toggle-link-display RET.
4. Move the cursor to the first heading.
5. Type C-c C-n.

EXPECTED:

  The cursor moves to the second heading.

ACTUAL:

  The cursor moves to the end of file.

Rudy
-- 
“I do not fear death.  I had been dead for billions and billions of years
before I was born, and had not suffered the slightest inconvenience from it.”
--- Mark Twain, paraphrased

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Why not enable extra keys by default?

2024-01-10 Thread Rudolf Adamkovič
Hi folks,

I have the 'org-use-extra-keys' customization enabled to avoid reaching
for the arrow keys, but the variable needs to be set before loading Org,
which makes literate configuration a bit more complex.

Other Emacs commands have alternative keys bound by default, which makes
me wonder, why does Org need the 'org-use-extra-keys' customization?  If
the user rebinds any of the extra keys, their personal key bindings take
precedence, so all should work well for everyone, right?

If so, then why not (1) enable the extra keys by default and (2)
deprecate the 'org-use-extra-keys' customization?

Thank you for your time.

Rudy
-- 
"Mathematics takes us still further from what is human into the region
of absolute necessity, to which not only the actual world, but every
possible world, must conform."
--- Bertrand Russell, 1902

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] org-babel-tangle: Do not allow tangling into self

2024-01-10 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> The attached patch makes Org throw an error in such scenario.

This is a great feature (and it deserves a test, given it protects from
data loss).  For what is worth, I remember making this error at least
twice in the past year.  (Git saved me in both cases, fortunately.)

Rudy
-- 
"I do not fear death.  I had been dead for billions and billions of
years before I was born, and had not suffered the slightest
inconvenience from it."  --- Mark Twain, paraphrased

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: custom function for org-babel src block export

2023-12-26 Thread Rudolf Adamkovič
How about:

(defvar stacker-base
  "\href{https://www.example.com/stacker/?program=%s}{execute on stacker}")

(defun org-babel-execute:stacker (body params)
  (format stacker-base 
  (org-link-encode body '(?? ?  ?( ?) ?\n

It works with noweb too:

#+NAME: last
#+BEGIN_SRC stacker :eval no
(f)
#+END_SRC

#+BEGIN_SRC stacker :noweb yes
(defvar x 1)
(deffun (f)
  (defvar y 2)
  (deffun (h)
(+ x y))
  (h))
<>
#+END_SRC

#+RESULTS:
: 
href{https://www.example.com/stacker/?program=%28defvar%20x%201%29%0A%28deffun%20%28f%29%0A%20%20%28defvar%20y%202%29%0A%20%20%28deffun%20%28h%29%0A%20%20%20%20%28+%20x%20y%29%29%0A%20%20%28h%29%29%0A%28f%29}{execute
 on stacker}

Rudy
-- 
"Genius is 1% inspiration and 99% perspiration."
--- Thomas Alva Edison, 1932

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] Re: [feature request] startup variable for link display

2023-12-22 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> #+startup: showlinks
> and
> #+startup: compresslinks

Why not continue with established terminology?

#+STARTUP: descriptivelinks
#+STARTUP: literallinks

Rudy
-- 
"It is no paradox to say that in our most theoretical moods we may be
nearest to our most practical applications."
--- Alfred North Whitehead, 1861-1947

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: #4 [[bbb:OrgMeetup]] on Wed, Dec 13, 19:00 UTC+3

2023-12-17 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Time & Date: <2023-12-13 Wed 19:00-21:00 @+03,Europe/Istanbul>

When I click on the timestamp above, Org says:

  This should not happen

Is that normal?

Rudy
-- 
"Simplicity is complexity resolved."
--- Constantin Brâncuși, 1876-1957

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Consider removing newlines from org-insert-link help message

2023-12-17 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Thanks! [...] Applied, onto main, with minor amendments.

Thank you, Ihor.

> I have removed redundant `cons' call in the `apply' and added proper
> function quoting: #'format.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=664ffde14

Eagle eyes; one always learns something new!

Rudy
-- 
“I do not fear death.  I had been dead for billions and billions of years
before I was born, and had not suffered the slightest inconvenience from it.”
--- Mark Twain, paraphrased

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Consider removing newlines from org-insert-link help message

2023-12-10 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> You can just use `org-format-prompt'.

TIL!  Updated.

Thank you!

P.S. I have also updated the commit message.

Rudy
>From aa947b42186fca813d3fcc702f7f5daa554980f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Sun, 10 Dec 2023 00:51:31 +0100
Subject: [PATCH] org-link: Improve UX of 'org-insert-link'

* lisp/ol.el (org-insert-link): Shorten the text in the *Org Links*
buffer to avoid unnecessary line breaks, reword it to better align
with the rest of Emacs, and propertize its key bindings to improve
readability.  Further, move the default link to the minibuffer, as
seen elsewhere in Emacs, and make the *Org Links* buffer read-only.
---
 lisp/ol.el | 40 +---
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index c38a30378..bd89415e8 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1868,16 +1868,34 @@ non-interactively, don't allow to edit the default description."
   (org-link--fontify-links-to-this-file)
   (org-switch-to-buffer-other-window "*Org Links*")
   (with-current-buffer "*Org Links*"
-	(erase-buffer)
-	(insert "Insert a link.
-Use TAB to complete link prefixes, then RET for type-specific completion support\n")
-	(when org-stored-links
-	  (insert "\nStored links are available with / or M-p/n \
-\(most recent with RET):\n\n")
-	  (insert (mapconcat #'org-link--prettify
-			 (reverse org-stored-links)
-			 "\n")))
-	(goto-char (point-min)))
+(read-only-mode 1)
+(let ((inhibit-read-only t)
+  ;; FIXME Duplicate: Also in 'ox.el'.
+  (propertize-help-key
+   (lambda (key)
+ ;; Add `face' *and* `font-lock-face' to "work
+ ;; reliably in any buffer", per a comment in
+ ;; `help--key-description-fontified'.
+ (propertize key
+ 'font-lock-face 'help-key-binding
+ 'face 'help-key-binding
+  (erase-buffer)
+  (insert
+   (apply 'format
+  (cons "Type %s to complete link type, then %s to complete destination.\n"
+(mapcar propertize-help-key
+(list "TAB" "RET")
+	  (when org-stored-links
+(insert (apply 'format
+   (cons "\nStored links accessible with %s/%s or %s/%s are:\n\n"
+ (mapcar propertize-help-key
+ (list "" ""
+   "M-p" "M-n"
+   "RET")
+	(insert (mapconcat #'org-link--prettify
+			   (reverse org-stored-links)
+			   "\n"
+(goto-char (point-min)))
   (when (get-buffer-window "*Org Links*" 'visible)
 (let ((cw (selected-window)))
 	  (select-window (get-buffer-window "*Org Links*" 'visible))
@@ -1892,7 +1910,7 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
 			 org-link--insert-history)))
 	(setq link
 		  (org-completing-read
-		   "Link: "
+   (org-format-prompt "Insert link" (caar org-stored-links))
 		   (append
 		(mapcar (lambda (x) (concat x ":")) all-prefixes)
 		(mapcar #'car org-stored-links)
-- 
2.39.3 (Apple Git-145)

-- 
"Mathematics takes us still further from what is human into the region
of absolute necessity, to which not only the actual world, but every
possible world, must conform."  --- Bertrand Russell, 1902

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


Re: Consider removing newlines from org-insert-link help message

2023-12-09 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Patches welcome.

Please, see the attached patch.

> I see no obvious downsides. May as well.

Done.

> Currently, the minibuffer message is simply "Link: ". "Insert link:"
> is also ok.

Done.

> Maybe "Press" rather than "Type".

I went with "Type" to match other Emacs commands.

> We may, but the default link might sometimes be long. Not sure how it
> will look like.

All right, you be the judge.

Personally, I find this UI less disorienting, as opposed to the unclear
comment about RET in the *Org Links* buffer.  And it makes sense, given
I see the "VERB NOUN [default CANDIDATE]: " constantly, all throughout
in Emacs.

> AFAIK, this is already done. We already use `completing-read'. The UI
> is there historically and in addition to the normal Emacs completion.

Gotcha!

(It is quite confusing when using e.g. Vertico, but if we are optimizing
for the default Emacs completion system, then it makes sense.)

Rudy

>From 7bc8e913af0972f0d6119e45d4ecaf80835f2277 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Sun, 10 Dec 2023 00:51:31 +0100
Subject: [PATCH] org-link: Prettify 'org-insert-link'

* lisp/ol.el (org-insert-link): Update the UI with text that is (1)
shorter, to avoid line breaks, (2) more standard, to match other Emacs
commands, and (3) more readable, with propertized key bindings.  Also,
show the default link in the minibuffer, as seen elsewhere in Emacs.
---
 lisp/ol.el | 44 +---
 1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index e684b9504..49499e932 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1866,16 +1866,34 @@ non-interactively, don't allow to edit the default description."
   (org-link--fontify-links-to-this-file)
   (org-switch-to-buffer-other-window "*Org Links*")
   (with-current-buffer "*Org Links*"
-	(erase-buffer)
-	(insert "Insert a link.
-Use TAB to complete link prefixes, then RET for type-specific completion support\n")
-	(when org-stored-links
-	  (insert "\nStored links are available with / or M-p/n \
-\(most recent with RET):\n\n")
-	  (insert (mapconcat #'org-link--prettify
-			 (reverse org-stored-links)
-			 "\n")))
-	(goto-char (point-min)))
+(read-only-mode 1)
+(let ((inhibit-read-only t)
+  ;; FIXME Duplicate: Also in 'ox.el'.
+  (propertize-help-key
+   (lambda (key)
+ ;; Add `face' *and* `font-lock-face' to "work
+ ;; reliably in any buffer", per a comment in
+ ;; `help--key-description-fontified'.
+ (propertize key
+ 'font-lock-face 'help-key-binding
+ 'face 'help-key-binding
+  (erase-buffer)
+  (insert
+   (apply 'format
+  (cons "Type %s to complete link type, then %s to complete destination.\n"
+(mapcar propertize-help-key
+(list "TAB" "RET")
+	  (when org-stored-links
+(insert (apply 'format
+   (cons "\nStored links accessible with %s/%s or %s/%s are:\n\n"
+ (mapcar propertize-help-key
+ (list "" ""
+   "M-p" "M-n"
+   "RET")
+	(insert (mapconcat #'org-link--prettify
+			   (reverse org-stored-links)
+			   "\n"
+(goto-char (point-min)))
   (when (get-buffer-window "*Org Links*" 'visible)
 (let ((cw (selected-window)))
 	  (select-window (get-buffer-window "*Org Links*" 'visible))
@@ -1890,7 +1908,11 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
 			 org-link--insert-history)))
 	(setq link
 		  (org-completing-read
-		   "Link: "
+   (concat "Insert link"
+   (if-let ((default (caar org-stored-links)))
+   (format " [default %s]" default)
+ "")
+   ": ")
 		   (append
 		(mapcar (lambda (x) (concat x ":")) all-prefixes)
 		(mapcar #'car org-stored-links)
-- 
2.39.3 (Apple Git-145)

-- 
"Music is the mathematics of the sense, mathematics is the music of the
reason."  -- James Joseph Sylvester, 1814-1897

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


Org contributors: Typo in a heading

2023-12-04 Thread Rudolf Adamkovič
A quick heads-up about a typo at

  https://orgmode.org/worg/contributors.html

Actual heading:

  Current contributors with FSF assignement

Expected heading:

  Current contributors with FSF assignment

Rudy
-- 
"'Obvious' is all too often a synonym for 'wrong'."
-- Jeff Erickson, Algorithms, 2019

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: No-description <> links

2023-10-22 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> I think that we may need to introduce a customization for default link
> description. Some backends hard-code the default description to
> something non-trivial and some just use arbitrary fallback like ???
> (ox-ascii), "No description" (ox-html), or "" (ox-latex).

I wonder, why not export [[link]] to <> as "link" by default, if
no description is given, as is the case with URLs, Elisp, and the like?
And if that is not desirable, would the new customization allow for
doing that?

I am asking the second question because I am still hoping to solve my
problem with the impracticality of [[Literal link][literal link]]s in
densely linked text, as explained in my other thread.  If Org could
export [[link]] to <> as "link", and offered a STARTUP for literal
links, then that would fix my problem for good.

Thank you!

Rudy
-- 
"Simplicity is complexity resolved."
-- Constantin Brâncuși, 1876-1957

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Case insensitivity of simple [[links]]

2023-10-21 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> [...] loading happens before Emacs loads file-local variables. This is
> by major mode design and we cannot do much about this. See
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57003

I see.  So, that is by design of Emacs, and Org has no built-in
mechanism, akin to the existing #+OPTIONS, where I could say "show
literal links", right?

Rudy
-- 
"I love deadlines.  I love the whooshing noise they make as they go by."
-- Douglas Adams, The Salmon of Doubt, 2002

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



No-description <> links

2023-10-21 Thread Rudolf Adamkovič
Hello there!

Consider the sentence

  "This is a [[link]]."

in a document with a "<>" target.

Org exports the sentence to HTML as

  "This is a No description for this link."

and to PDF as

  "This is a ."

How about we export it as

  "This is a link."

where the word "link" is the actual link?

WDYT?

Rudy
-- 
"Simplicity is complexity resolved."
-- Constantin Brâncuși, 1876-1957

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Consider removing newlines from org-insert-link help message

2023-10-20 Thread Rudolf Adamkovič
Salih Muhammed  writes:

> What about replacing it with shorter description?

+1 for making the message shorter,

... and while on it, perhaps also a bit clearer.

Also,

- the key bindings are not propertized, and
- the entire buffer is writable.

> Insert a link.

How about we say "Insert link:" in the minibuffer and drop this sentence
altogether?  Grammatically, the minibuffer prompt would be similar to
'C-x b', which says "Switch to buffer".

> Use TAB to complete link prefixes, then RET for type-specific
> completion support.

How about:

  Type TAB to complete link types, then RET to complete destinations.

> Stored links are available with / or M-p/n (most recent with
> RET):

Could we show the default value in the minibuffer, as

  Insert link (default [...]):

and then drop the "(most recent with RET)" comment?

As for the rest of the message, ... actually let me stop here and zoom
out a bit.  The optimal solution here would be to remove this entire UI
and leverage standard Emacs completions.  Org could simply ask

  Insert link (default [...]):

in the minibuffer and then provide intelligent completions based on the
current input.  If that can be done, then Emacs can handle the rest.  It
can show completion candidates, handle past/future history, and more.

Rudy
-- 
"We shall not cease from exploration
 And the end of all our exploring
 Will be to arrive where we started
 And know the place for the first time"
--- T. S. Eliot, Little Gidding, Four Quarters, 1943

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Case insensitivity of simple [[links]]

2023-10-19 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

>>> Note that there is generally no guarantee that [[name]] link will be
>>> exported as "name" by any particular backend. Your workaround with
>>> num:nil is just a workaround that may or may not work in future.
>>
>> I did not know this is considered a workaround!  I have always thought
>> this is how Org is specified to work (as in tests).

Actually, dang!  I spoke too soon.  While links now work consistently
before and after exports, their description matches the destination
heading, not the source link.  But if we case-fold now, it would make a
lot more sense to match the case of the source link, as it enables one
to link [[capitalized heading]]s.  Otherwise, we case-fold with no
significant benefits, as far as I can see.

Without also fixing this part, my problem with Org remains. :(

>> [...] call to 'org-toggle-link-display' does nothing.

> It does nothing because it is one of the options that must be set before
> Org mode is loaded. Resolving buffer-local variables happens after the
> major mode is loaded.

I have noticed that 'org-use-extra-keys', for example, is documented as
"must set it before loading Org", but there is nothing similar in the
'org-link-descriptive' docstring.  So perhaps this is a bug, not a
feature?

Upon a quick look, 'org-toggle-link-display' does exactly two things:

  1. (setq org-link-descriptive (not org-link-descriptive)) and
  2. (org-link-descriptive-ensure),

where 'org-link-descriptive-ensure' wraps exactly one expression:

  (org-fold-core-set-folding-spec-property
 (car org-link--link-folding-spec)
 :visible (not org-link-descriptive))

Could Org execute this expression after loading a document, given the
buffer-local value of 'org-link-descriptive' necessitates it?

Rudy
-- 
"It is far better to have a question that can't be answered than an answer that
can't be questioned."
--- Carl Sagan

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Case insensitivity of simple [[links]]

2023-10-16 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Note that there is generally no guarantee that [[name]] link will be
> exported as "name" by any particular backend. Your workaround with
> num:nil is just a workaround that may or may not work in future.

I did not know this is considered a workaround!  I have always thought
this is how Org is specified to work (as in tests).

> I can see how this can be helpful in certain scenarios.
> I made headline and radio target link matching case-insensitive on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ed42dc34a
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ec2399330

Wait, did you just solve my *biggest* problem with Org?  OMG!

One more question before I declare a full victory: I want my notebook to
show literal links by default, but the following does not seem to work:

# -*- fill-column: 79; org-link-descriptive: nil -*-

The line seems to confuse Org in that not only it shows descriptive
links but the first call to 'org-toggle-link-display' does nothing.

Rudy
-- 
"'Obvious' is all too often a synonym for 'wrong'."
-- Jeff Erickson, Algorithms, 2019

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Exporting elisp: and shell: links

2023-10-11 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> I am not sure if I like it.

Me neither.  The problem is in the parentheses, IMHO.  The Lisp
expression is enclosed in parentheses and so is the description:

  (message "Hello") (Message Hello)

That indeed looks confusing!  How about we swap the sides and remove one
pair of parentheses?  That would give:

  Message Hello (message "Hello")

Rudy
-- 
"Genius is 1% inspiration and 99% perspiration."
-- Thomas Alva Edison, 1932

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Case insensitivity of simple [[links]]

2023-10-06 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

>> For context, I use '#+OPTIONS: num:nil', which means that '[[link]]'
>> exports as 'link' and not a section number.
>
> I am confused. num:nil just means that section titles will not be
> numbered. It has nothing to do with links, AFAIK.

My sentence says it all, but if that is not clear, consider:

EXAMPLE 1:

  This is a [[test]] link.
  
  * test

EXPORT OF EXAMPLE 1:

  This is a 1 link.

EXAMPLE 2:

  #+OPTIONS: num:nil
  
  This is a [[test]] link.
  
  * test

EXPORT OF EXAMPLE 2:

  This is a test link.

> What about [[Link][link]]?

That makes Org documents hard to read in *plain text*, that is without
the "descriptive links" fontification.  Here is my note again, compare:

EXAMPLE 1: Hard-to-read, unhelpful markup:

  The set of [[Cellular membrane][cellular membrane]]-bound
  [[Organelle][organelle]]s inside of the [[Eukaryotic cell][eukaryotic
  cell]] that work together on the synthesis and distribution of
  [[Protein][protein]]s and [[Lipid][lipid]]s.

EXAMPLE 2: Lightweight, helpful markup:

  The set of [[cellular membrane]]-bound [[organelle]]s inside of the
  [[eukaryotic cell]] that work together on the synthesis and
  distribution of [[protein]]s and [[lipid]]s.

> Judging from your example, I am not sure if it is an actual problem
> with Org mode. I am still to see a use case when case-insensitivity
> would be useful. Now, I am inclined to fix the docstring (and possibly
> the manual), clarifying about case-sensitivity of the internal links.

For me, this is not only "an actual problem with Org" but the biggest
problem, and the only big problem, I have with Org.

As a markup language, Org is "99% there" in having some of the *most
practical* plain text [[link]]s available, but then falls short on case
sensitivity, ending up with the exact opposite.

Now, I could use descriptive links, which hide the [[Wart][wart]] behind
fontification tricks, but that would not solve my problem.  Why?  I need
to use other plain text tools, such as Git, with my densely linked Org
documents.

Rudy
-- 
"Simplicity is complexity resolved."
-- Constantin Brâncuși, 1876-1957

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: org-ctags-find-tag should not prompt inside org-open-at-point

2023-09-28 Thread Rudolf Adamkovič
Joseph Turner  writes:

> (setopt org-ctags-open-link-functions nil)

Oh, thank you!  This regularly drives me crazy.

I added the following to my Emacs/Org configuration:

#+BEGIN_SRC emacs-lisp :results none
(eval-after-load 'org-ctags
  (setq org-ctags-open-link-functions nil))
#+END_SRC

Rudy
-- 
"I love deadlines.  I love the whooshing noise they make as they go by."
-- Douglas Adams, The Salmon of Doubt, 2002

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Exporting elisp: and shell: links

2023-09-28 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Still, it would be nice to have _a_ variant compared to the current
> state of affairs.

Agreed.  If the link has no description, we can do a great job on
exporting it.  Half of the victory, right there!

Also, how about the following /simple/ idea for the description:

  [[elisp:(server-start)][Launch Server]]
  [[elisp:(server-start)][=M-x server-start RET=]]
  
  src_elisp[:exports code]{(server-start)} (Launch Server)
  src_elisp[:exports code]{(server-start)} (=M-x server-start RET=)

TL;DR We export the description, if any, in parentheses after the code.

Rudy
-- 
"One can begin to reason only when a clear picture has been formed in
the imagination."
-- Walter Warwick Sawyer, Mathematician's Delight, 1943

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Case insensitivity of simple [[links]]

2023-09-27 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> You might as well use [[Link]].

For context, I use '#+OPTIONS: num:nil', which means that '[[link]]'
exports as 'link' and not a section number.  I thought about using
'[[Link]]' as you suggest, but it would make almost all sentences I
write ungrammatical.  For comparison, consider:

Properly capitalized:

  The set of cellular membrane-bound organelles inside of the eukaryotic
  cell that work together on the synthesis and distribution of proteins
  and lipids.

Sentence-capitalized to make Org find the respective headings:

  The set of Cellular membrane-bound Organelles inside of the Eukaryotic
  cell that work together on the synthesis and distribution of Proteins
  and Lipids.

> As for case sensitivity, it is something we might discuss. I just
> outlined the current state of the Org code.

Thank you for outlining the current state.  I asked about it because I
have been struggling with this problem for a long time, and I was not
sure whether Org can or cannot do it, particularly given the fact that
my use of literal links is as simple as it gets.

If someone could fix this problem, say by adding link case-insensitivity
to '#+OPTIONS', I am willing to sponsor it financially, as the current
behavior is my biggest problem with the Org mode.

Rudy
-- 
"'Obvious' is all too often a synonym for 'wrong'."
-- Jeff Erickson, Algorithms, 2019

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Case insensitivity of simple [[links]]

2023-09-24 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> [...]

So, if I understand correctly, there is no way to make "[[link]]" find
"* Link" while editing, after exporting, and on any Emacs, that is
'emacs -Q'.  In other words, writing "* link" in lowercase, which is my
workaround, is "the solution".  Do I have that right?

Rudy
-- 
"It is no paradox to say that in our most theoretical moods we may be
nearest to our most practical applications."
-- Alfred North Whitehead, 1861-1947

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Case insensitivity of simple [[links]]

2023-09-22 Thread Rudolf Adamkovič
Howdy!

A while ago, I asked about case insensitivity of the syntactically
simplest "[[links]]" in Org.  I am interested in using these links
because they are the most practical with the "literal" view.

In 'emacs -Q' Org 9.6.9, "[[links]]" are case _sensitive_ when looking
for headings.  This was originally not the case, and case _insensitive_
linking was broken in Org 7 and then fixed in Org 8, as per [1] and [2].
Is it broken again?  I ask because 'org-link-search' documentation says
that search is "case-insensitive and ignores white spaces".

On top of the above, yesterday I noticed that

  (setq org-link-search-must-match-exact-headline nil)

makes "[[link]]" find "* Link" when clicked.  My joy was short-lived,
however, as I soon found that I cannot export anything due to

  org-export-data: Unable to resolve link: "link".

As a user, I am a bit lost here.  I cannot figure out what is a bug and
what is a feature in all of the above.  In a nutshell, all I want is to
make "[[link]]" find "* Link" while editing, after exporting, and on any
Emacs, that is 'emacs -Q'.  I have been struggling with this problem for
a while now, down-casing my headings as a workaround.  Any ideas?

Thank you!

Rudy

[1]
https://stackoverflow.com/questions/35542208/how-to-make-internal-link-in-org-mode-case-insensitive

[2] 
https://emacs.stackexchange.com/questions/20441/how-to-make-internal-links-in-org-mode-case-insensitive

-- 
"All you have to do is write one true sentence.  Write the truest sentence that
you know."
--- Ernest Miller Hemingway (1899-1961)

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Exporting elisp: and shell: links

2023-09-22 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Another idea: use code as description displayed in the tooltip (in html).
> Copy-on-clip also makes sense.
>
> Yet another idea: export code inside a footnote. This will work across
> all the backends.

Yet another, another idea: export the description as a Lisp comment,
after converting it to plain text.  To use Max's example:

src_elisp[:exports code]{(server-start) ; Launch server}
src_elisp[:exports code]{(server-start) ; `M-x server-start RET'}

Rudy
-- 
"Logic is a science of the necessary laws of thought, without which no
employment of the understanding and the reason takes place."
-- Immanuel Kant, 1785

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Exporting elisp: and shell: links

2023-09-18 Thread Rudolf Adamkovič
Max Nikulin  writes:

> Do you think a label specifying language should be added to code 
> snippets, e.g. (identity "a") or it is 
> useless and may cause undesired noise for screen reader users? What 
> about LaTeX?

As a user, I would expect

  [[elisp:(identity "a")]]

to be export-equivalent to

  src_elisp[:exports code]{(identity "a")}

across all backends.

[If Org works as it should, then that solves
screen readers, LaTeX, etc.]

> What is your expectation for links having description?
>
>[[elisp:(identity "a")][Run it]]

Good point!  Perhaps we just need to find a
good symbol that would work well between the
Elisp code and the description?

For example

  /Run it/ \to src_elisp[:exports code]{(identity "a")}

exports to ASCII as

  /Run it/ -> `(identity "a")'

Of course, \to could be something else...

WDYT?

Rudy
-- 
"Thinking is a momentary dismissal of irrelevancies."
-- Richard Buckminster Fuller, 1969

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [BUG] tikz latex figures don't render properly in the html output. [9.6.6 (release_9.6.6 @ /usr/share/emacs/29.1/lisp/org/)]

2023-09-18 Thread Rudolf Adamkovič
tusharhero--- via "General discussions about Org-mode."
 writes:

> \begin{tikzpicture}
> \draw (0,0) circle [radius=2cm];
> \end{tikzpicture}

By default Org uses MathJax in HTML exports,
and MathJax does not implement TikZ.  But!
Org can be told to instead use LaTeX to
generate SVG or PNG for HTML exports [1].
But, but!  That does not work well without a
small pile of hacks.  But, but, but!  There
is a new LaTeX preview system in works [2],
and it fixes a lot of problems out of the
box, including yours!

Rudy

[1] https://orgmode.org/manual/Math-formatting-in-HTML-export.html
[2] https://youtu.be/n-AfvuV-bYo?si=k-5QY9MdrJXazmPv
-- 
"Programming reliably -- must be an activity of an undeniably
mathematical nature […] You see, mathematics is about thinking, and
doing mathematics is always trying to think as well as possible."
-- Edsger W. Dijkstra, 1981

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Addendum

2023-09-17 Thread Rudolf Adamkovič
Summer Emacs  writes:

> I’m not certain. I just wanted to mention that before anyone piles on
> me for not recognising that fact.

To reach a conclusion, I would recommend you to:

1. Start a minimal Emacs with 'emacs -Q'.
2. Open the problematic file and see if the bug still shows.
3. If it does, cut the file down to the problematic part.
4. Finally, share the cut-down file here.

Rudy
-- 
"It is far better to have a question that can't be answered than an answer that
can't be questioned."
--- Carl Sagan

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [BUG] URI handling is overly complicated and nonstandard [9.6.7 (N/A @ /gnu/store/mg7223g8mw90lccp6mm5g6f3mpjk70si-emacs-org-9.6.7/share/emacs/site-lisp/org-9.6.7/)]

2023-09-17 Thread Rudolf Adamkovič
Max Nikulin  writes:

> From my point of view, e.g.  should be exported 
> as plain text (identity "a") rather than an (invalid due to 
> not escaped quotes inside href) link (identity 
> "a").

This would be a very welcome fix!  I avoid
'elisp' links, even in my Emacs notes, as
they do not export correctly.

Rudy
-- 
"Chop your own wood and it will warm you twice."
-- Henry Ford; Francis Kinloch, 1819; Henry David Thoreau, 1854

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



[PATCH] org-manual: Fix a preposition and capitalization

2023-09-15 Thread Rudolf Adamkovič
* doc/org-manual.org (Capturing column view): Replace "in the
... line" with "on the ... line" and capitalize the containing
sentence as well.
---
 doc/org-manual.org | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 6cd2bf378..3e9d42f55 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -5971,7 +5971,7 @@ The following commands insert or update the dynamic block:
   #+kindex: C-c C-c
   #+kindex: C-c C-x C-u
   #+findex: org-dblock-update
-  Update dynamic block at point.  point needs to be in the =#+BEGIN=
+  Update dynamic block at point.  Point needs to be on the =#+BEGIN=
   line of the dynamic block.
 
 - {{{kbd(C-u C-c C-x C-u)}}} (~org-update-all-dblocks~) ::
-- 
2.42.0




Re: [PATCH] Fix a possibly problematic string comparison

2023-08-29 Thread Rudolf Adamkovič
Thank you for the explanation!

Given the complexity of the caller, that is
the `org-table-eval-formula' function, as
well as, the fact that I have yet to learn
about the spreadsheet functionality, I am
backing away from this bugfix.

Sorry for the noise.

Rudy
-- 
"Programming reliably -- must be an activity
of an undeniably mathematical nature […] You
see, mathematics is about thinking, and doing
mathematics is always trying to think as well
as possible."  -- Edsger W. Dijkstra, 1981

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] Fix a possibly problematic string comparison

2023-08-28 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> This is not as trivial. Applying this patch will break tests.
> One needs to carefully examine the org-table logic to fix this
> particular warning.

Wow!  You are right.  How is that even possible?  In other words, what
value (of 'elements') can possibly be object-equal to a literal "" but
not string-equal to the same literal "" or vice versa?

Rudy
-- 
"Logic is a science of the necessary laws of thought, without which no
employment of the understanding and the reason takes place."
-- Immanuel Kant, 1785

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



[PATCH] Fix a possibly problematic string comparison

2023-08-27 Thread Rudolf Adamkovič
* lisp/org-table.el (org-table-make-reference): Replace 'eq' with
'string-empty-p' to resolve "Warning: 'eq' called with literal string
that may never match" issued on every 'make' invocation.
---
 lisp/org-table.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index f5a433c7d..b82749469 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -2864,7 +2864,7 @@ list, `literal' is for the format specifier L."
   (if lispp
  (if (eq lispp 'literal)
  elements
-   (if (and (eq elements "") (not keep-empty))
+   (if (and (string-empty-p elements) (not keep-empty))
""
  (prin1-to-string
   (if numbers (string-to-number elements) elements
-- 
2.41.0




Re: ox-html: no tests, besides mathjax?

2023-08-09 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> We had no tests at all and then added some alongside with the MathJax
> 3 support.

Hello there. :)

/waves hands/

Rudy
-- 
"It is no paradox to say that in our most theoretical moods we may be
nearest to our most practical applications."
-- Alfred North Whitehead, 1861-1947

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] ob-sqlite: Use a transient in-memory database by default

2023-08-05 Thread Rudolf Adamkovič
Max Nikulin  writes:

> On 05/08/2023 05:57, Rudolf Adamkovič wrote:
>> +*** Make ~ob-sqlite~ use in-database by default
>
> "use in-memory database"

Oops!  Fixed.

>> +SQLite source blocks with no ~:db~ argument now execute against a
>> +transient in-memory database by default.
>
> I am unsure, but perhaps it would be more clear to say that the default 
> value of the header argument has changed and it is possible to omit 
> setting :db per-block or as a header argument. It should give a hint how 
> to revert this change in local configuration if somebody wish it.

Please see the attached Patch 0001A.

> Feel free to just ignore the following. Perhaps to get *really* default 
> behavior ob-sqlite should not check :db value and should not pass it to 
> the command in the case of nil.

This is a good idea!  Please see the attached
alternative Patch 0001B.

> As a result the command spits a warning.

It does?

Rudy
>From 144bd75183a9185786248d9404ddeee4b93ed30f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Wed, 3 May 2023 14:59:03 +0200
Subject: [PATCH] ob-sqlite: Use a transient in-memory database by default

* etc/ORG-NEWS (New features): Add a news entry.
* lisp/ob-sqlite.el (org-babel-default-header-args:sqlite): Default
':db' to ":memory:".
* testing/lisp/test-ob-sqlite.el (ob-sqlite/in-file): Test the old behavior.
* testing/lisp/test-ob-sqlite.el (ob-sqlite/in-memory): Test the new behavior.
---
 etc/ORG-NEWS   |  8 
 lisp/ob-sqlite.el  |  2 +-
 testing/lisp/test-ob-sqlite.el | 36 --
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 4f16eda24..569ec651b 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -489,6 +489,14 @@ Final hooks are added to the following commands:
 
 The prefix arguments are passed to ~org-insert-todo-heading~.
 
+*** Make ~ob-sqlite~ use in-memory databases by default
+
+The ~:db~ header argument of ~sqlite~ source blocks now defaults to
+~":memory:"~ which stands for a temporary in-memory database.  As a
+result, ~sqlite~ source blocks are usable out of the box, with no
+header arguments, matching the behavior and practicality of the
+official ~sqlite3~ shell.
+
 *** Add support for ~logind~ idle time in ~org-user-idle-seconds~
 
 When Emacs is built with =dbus= support and
diff --git a/lisp/ob-sqlite.el b/lisp/ob-sqlite.el
index 526b73ebd..75ef50913 100644
--- a/lisp/ob-sqlite.el
+++ b/lisp/ob-sqlite.el
@@ -39,7 +39,7 @@
 (declare-function orgtbl-to-csv "org-table" (table params))
 (declare-function org-table-to-lisp "org-table" ( txt))
 
-(defvar org-babel-default-header-args:sqlite '())
+(defvar org-babel-default-header-args:sqlite '((:db . ":memory:")))
 
 (defvar org-babel-header-args:sqlite
   '((db. :any)
diff --git a/testing/lisp/test-ob-sqlite.el b/testing/lisp/test-ob-sqlite.el
index 72d75c9b7..621a11b0b 100644
--- a/testing/lisp/test-ob-sqlite.el
+++ b/testing/lisp/test-ob-sqlite.el
@@ -39,8 +39,40 @@
   .import $tb TestTable
   select * from TestTable;
 #+end_src"
-	(org-babel-next-src-block)
-	(org-babel-execute-src-block)
+	   (org-babel-next-src-block)
+	   (org-babel-execute-src-block)
+
+(ert-deftest ob-sqlite/in-memory ()
+  "Test in-memory temporariness."
+  (should
+   (equal 0
+  (progn
+(org-test-with-temp-text
+	 "#+BEGIN_SRC sqlite
+PRAGMA user_version = 1;
+#+END_SRC"
+	 (org-babel-execute-src-block))
+(org-test-with-temp-text
+	 "#+BEGIN_SRC sqlite
+PRAGMA user_version;
+#+END_SRC"
+	 (org-babel-execute-src-block))
+
+(ert-deftest ob-sqlite/in-file ()
+  "Test in-file permanency."
+  (should
+   (equal 1
+  (let ((file (org-babel-temp-file "test" ".sqlite")))
+(org-test-with-temp-text
+	 (format "#+BEGIN_SRC sqlite :db %s
+PRAGMA user_version = 1;
+#+END_SRC" file)
+	 (org-babel-execute-src-block))
+(org-test-with-temp-text
+	 (format "#+BEGIN_SRC sqlite :db %s
+PRAGMA user_version;
+#+END_SRC" file)
+	 (org-babel-execute-src-block))
 
 (provide 'test-ob-sqlite)
 ;;; test-ob-sqlite.el ends here
-- 
2.37.1 (Apple Git-137.1)

>From 34f28236366affb510bfdb70a3577e765d9e0abb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Wed, 3 May 2023 14:59:03 +0200
Subject: [PATCH] ob-sqlite: Use a transient in-memory database by default

* etc/ORG-NEWS (New features): Add a news entry.
* lisp/ob-sqlite.el (org-babel-execute:sqlite): Default ':db' to
":memory:" instead of throwing an error.
* testing/lisp/test-ob-sqlite.el (ob-sqlite/in-file): Test the old behavior.
* testing/lisp/test-ob-sqlite.el (ob-sqlite/in-memory): Test the new behavior.
---
 etc/ORG-NEWS   

Re: [PATCH] ob-sqlite: Use a transient in-memory database by default

2023-08-04 Thread Rudolf Adamkovič
doc-sqlite.org
@@ -91,7 +91,8 @@ There are no language-specific default header arguments for SQLite.
 There are 11 SQLite-specific header arguments.
 
  - db :: a string with the name of the file that holds the SQLite
- database. Babel requires this header argument. 
+   database. Defaults to =":memory:"=, a special "file name" that
+   makes SQLite use a temporary in-memory database.
  - header :: if present, turn on headers in the output format. Headers
  are also output with the header argument =:colnames yes=.
  - echo :: if present, set the SQLite dot command =.echo= to =ON=.
-- 
2.37.1 (Apple Git-137.1)

-- 
"We shall not cease from exploration
 And the end of all our exploring
 Will be to arrive where we started
 And know the place for the first time"
--- T. S. Eliot, Little Gidding, Four Quarters, 1943

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


Re: [PATCH] ob-sqlite: Use a transient in-memory database by default

2023-08-03 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> As Max described, it might be a potential issue.

How about (1) we merge the patch, and then
(2) we add the lint warning if/when someone
has the [hypothesized] problem?

Rudy
-- 
"One can begin to reason only when a clear picture has been formed in
the imagination."
-- Walter Warwick Sawyer, Mathematician's Delight, 1943

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] ob-sqlite: Use a transient in-memory database by default

2023-06-19 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> I do not mind falling back to ":memory:" when :db is not specified, but
> we should display a warning to notify the users. Maybe not as a warning
> every time src block is executed, but at least via org-lint.
>
> Rudolf, WDYT?

I am not a fan of making the use of in-memory databases into a "smell",
as per Org Lint, because it would communicate to the user that "this is
a potential issue that you should probably fix".  I think that is not
true, given that SQLite defaults to in-memory for interactive use. It is
common and useful.  Showing a warning has the same problem.

Now, showing a message, such as "Using in-memory database", could do,
but it would feel like spam.  The SQLite shell prints "Connected to a
transient in-memory database" exactly once, not on every (re-)query.
Perhaps there is a precedent somewhere in Org Babel, and we could do
something similar?

Rudy
-- 
"Music is the mathematics of the sense, mathematics is the music of the reason."
-- James Joseph Sylvester, 1814-1897

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Re: [Pre-PATCH] Overhaul of the LaTeX preview system

2023-06-04 Thread Rudolf Adamkovič
Pedro Andres Aranda Gutierrez  writes:

> this might not be completely the case, but I recently reported a bug
> against native compilation in Emacs. What about trying without netive
> compilation?

I have just tried without native compilation.  No luck!  I get the exact
same error.

Rudy
-- 
"Great minds discuss ideas; average minds discuss events; small minds discuss
people."
--- Anna Eleanor Roosevelt (1884-1962)

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [Pre-PATCH] Overhaul of the LaTeX preview system

2023-05-26 Thread Rudolf Adamkovič
Timothy  writes:

> If you do come across any issues, please let me know either in a reply
> here or the org-mode matrix room.

First of all, thank you for working on this!

Here are some issues, after using your patch-set for 1 day:

ISSUE 1: CLIPPING

On my HiDPI screen, the new previews are clipped slightly at the edges.
I had this issue before and fixed it in [1][2].  Has the same bug crept
back?

[1] https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=52ebf6b45
[2] https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5337a49f3

ISSUE 2: TIKZ

I use LaTeX Babel blocks for TikZ, and these stopped working.  From the
*Messages* buffer:

Executing Latex unknown at position 846...
Processing LaTeX file 
/var/folders/ky/8r5j3qz55hb94lpg1jr9vl1cgn/T/babel-ntjCLq/latex-aGIYEN.tex...
Compiling 
/var/folders/ky/8r5j3qz55hb94lpg1jr9vl1cgn/T/babel-ntjCLq/latex-aGIYEN.tex...
org-compile-file: File 
"/var/folders/ky/8r5j3qz55hb94lpg1jr9vl1cgn/T/babel-ntjCLq/latex-aGIYEN.svg"
 wasn’t producedorg babel latex failed
PDF file produced.

The linked LaTeX file compiles without errors, and a PDF file with
correct content sits next to it.  Perhaps the preview system needs to
wait longer?

[Also notice the missing space in "producedorg".]

It would be *FABULOUS* if this patch-set could also make 'ob-babel' use
the same mechanism as the new previews, 'dvisvgm' (TeX to DVI to SVG)
instead of Inkscape (TeX to PDF to SVG).  It would fix, for example,
scaling.  On my system, LaTeX Babel outputs everything at half of the
correct size, and I cannot convince Inkscape to scale up to save my
life.  The previews and 'dvisvgm' work as expected, conversely.

It would be *SUPER-FABULOUS* if the new previews worked with TikZ out of
the box, as per the Org manual saying "any LaTeX environment is handled"
[1] when not using MathJax.  Currently, PGF plots show as "blobs of
letters" and the simplest TikZ pictures, such as

\begin{tikzpicture}
  \filldraw (0, 0) circle[radius = 1cm];
\end{tikzpicture}

make the preview system choke with

error in process filter: org-latex-preview--svg-make-fg-currentColor: Wrong 
type argument: stringp, nil
error in process filter: Wrong type argument: stringp, nil

[1] https://orgmode.org/manual/LaTeX-fragments.html

Rudy
-- 
"One can begin to reason only when a clear picture has been formed in
the imagination."
-- Walter Warwick Sawyer, Mathematician's Delight, 1943

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] ob-sqlite: Use a transient in-memory database by default

2023-05-06 Thread Rudolf Adamkovič
Max Nikulin  writes:

> Perhaps it is better to keep current behavior with error by default
> and just to recommend [...] a user is experimenting with sqlite
> features.

This is exactly the case where the user SHOULD use

#+PROPERTY: header-args:sqlite :db 

to avoid mistyping  across their SQLite blocks.

[Hence, defaulting to ":memory:" would NOT hurt.]

Org is primarily about INTERACTIVE use, not batch processing, so I think
it would make sense to match the usefulness of the official INTERACTIVE
SQLite shell, which defaults to in-memory for good reasons.

Rudy
-- 
"Thinking is a momentary dismissal of irrelevancies."
-- Richard Buckminster Fuller, 1969

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



[PATCH] ob-sqlite: Use a transient in-memory database by default

2023-05-03 Thread Rudolf Adamkovič
* etc/ORG-NEWS (New features): Add a news entry.
* lisp/ob-sqlite.el (org-babel-execute:sqlite): Default ':db' to ":memory:".
* testing/lisp/test-ob-sqlite.el (ob-sqlite/in-file): Test the old behavior.
* testing/lisp/test-ob-sqlite.el (ob-sqlite/in-memory): Test the new behavior.
---
 etc/ORG-NEWS   |  6 ++
 lisp/ob-sqlite.el  |  3 +--
 testing/lisp/test-ob-sqlite.el | 36 --
 3 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 03894f128..42bfc2be0 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -181,6 +181,12 @@ official 
[[https://clojure.org/guides/deps_and_cli][Clojure CLI tools]].
 The command can be customized with ~ob-clojure-cli-command~.
 
 ** New features
+*** Make =ob-sqlite= use in-database by default
+
+SQLite source blocks with no =:db= argument now execute against a
+transient in-memory database.  This makes SQLite source blocks more
+practical, and it matches the default behavior of the =sqlite3= shell.
+
 *** Add support for ~logind~ idle time in ~org-user-idle-seconds~
 
 When Emacs is built with =dbus= support and
diff --git a/lisp/ob-sqlite.el b/lisp/ob-sqlite.el
index 526b73ebd..60da488f7 100644
--- a/lisp/ob-sqlite.el
+++ b/lisp/ob-sqlite.el
@@ -66,7 +66,7 @@
   "Execute a block of Sqlite code with Babel.
 This function is called by `org-babel-execute-src-block'."
   (let ((result-params (split-string (or (cdr (assq :results params)) "")))
-   (db (cdr (assq :db params)))
+   (db (or (cdr (assq :db params)) ":memory:"))
(separator (cdr (assq :separator params)))
(nullvalue (cdr (assq :nullvalue params)))
(headers-p (equal "yes" (cdr (assq :colnames params
@@ -74,7 +74,6 @@ This function is called by `org-babel-execute-src-block'."
   (lambda (arg) (car (assq arg params)))
   (list :header :echo :bail :column
 :csv :html :line :list)
-(unless db (error "ob-sqlite: can't evaluate without a database"))
 (with-temp-buffer
   (insert
(org-babel-eval
diff --git a/testing/lisp/test-ob-sqlite.el b/testing/lisp/test-ob-sqlite.el
index 72d75c9b7..b76a82d98 100644
--- a/testing/lisp/test-ob-sqlite.el
+++ b/testing/lisp/test-ob-sqlite.el
@@ -39,8 +39,40 @@
   .import $tb TestTable
   select * from TestTable;
 #+end_src"
-   (org-babel-next-src-block)
-   (org-babel-execute-src-block)
+  (org-babel-next-src-block)
+  (org-babel-execute-src-block)
+
+(ert-deftest ob-sqlite/in-memory ()
+  "Test in-memory temporariness."
+  (should
+   (equal 0
+  (progn
+(org-test-with-temp-text
+"#+BEGIN_SRC sqlite
+PRAGMA user_version = 1;
+#+END_SRC"
+(org-babel-execute-src-block))
+(org-test-with-temp-text
+"#+begin_src sqlite
+PRAGMA user_version;
+#+end_src"
+(org-babel-execute-src-block))
+
+(ert-deftest ob-sqlite/in-file ()
+  "Test in-file permanency."
+  (should
+   (equal 1
+  (let ((file (org-babel-temp-file "test" ".sqlite")))
+(org-test-with-temp-text
+(format "#+BEGIN_SRC sqlite :db %s
+PRAGMA user_version = 1;
+#+END_SRC" file)
+(org-babel-execute-src-block))
+(org-test-with-temp-text
+(format "#+BEGIN_SRC sqlite :db %s
+PRAGMA user_version;
+#+END_SRC" file)
+(org-babel-execute-src-block))
 
 (provide 'test-ob-sqlite)
 ;;; test-ob-sqlite.el ends here
-- 
2.40.1




Re: [RFC] Limit inline image width by default (was: feature request: easy embedding of images)

2023-04-05 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> See the tentative patch.

This looks fantastic!  +1 for using the Fill Column by default.

Rudy
-- 
"The introduction of suitable abstractions is our only mental aid to
organize and master complexity."
-- Edsger Wybe Dijkstra, 1930-2002

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code

2023-04-01 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> I finally managed to fix the tests.

Thank you!  I have had this on my to-do list since you brought it up,but
I could not find the time to fix it.

Rudy
-- 
"'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and
if it were so, it would be; but as it isn't, it ain't.  That's logic.'"
-- Lewis Carroll, Through the Looking Glass, 1871/1872

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH v2] org-manual.org: $n$-th is not math

2023-03-23 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> $-based economy employs 25$-like prices.

Gotcha!  I think I am fully convinced now.  :)

Rudy
-- 
"Mathematics takes us still further from what is human into the region
of absolute necessity, to which not only the actual world, but every
possible world, must conform."
-- Bertrand Russell, 1902

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH v2] org-manual.org: $n$-th is not math

2023-03-22 Thread Rudolf Adamkovič
Timothy  writes:

> I feel the need to point out that this way lies madness.
>
> The behaviour [...] “weird things are happening”.

Thank you so much for taking the time to explain the problem to me; I
now understand it much better!  That said, if the heuristic is

   $  ...MATH...  $- 

then `$3 or =$5' to `$3-$5' would not cause any troubles, right?  What
common, real-world use-case would trigger problems with this simple
heuristic?

Rudy
-- 
"Thinking is a momentary dismissal of irrelevancies."
-- Richard Buckminster Fuller, 1969

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: org-ctags land grab

2023-03-21 Thread Rudolf Adamkovič
Nick Dokos  writes:

> It is also confusing. To quote the unfortunate victim:
>
>   Now, when I click on the link, or C-c C-o, I get a dialog to "visit
>   tags table"... ???

I have had this happen to me many times too, so +1.

Rudy
-- 
"'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and
if it were so, it would be; but as it isn't, it ain't.  That's logic.'"
-- Lewis Carroll, Through the Looking Glass, 1871/1872

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH v2] org-manual.org: $n$-th is not math

2023-03-21 Thread Rudolf Adamkovič
Max Nikulin  writes:

> I do not have strong opinion if support of $n$th is tightly bound to
> recognizing $n$-th. On the other hand I would not object deprecation
> of "$...$".

Funny, I the exact opposite of you; I would pay many to see $...$th and
$...$-th special-cased (with tests, so that it would not break again).

Rudy
-- 
"The introduction of suitable abstractions is our only mental aid to
organize and master complexity."
-- Edsger Wybe Dijkstra, 1930-2002

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Hyphen after LaTeX fragments

2023-03-21 Thread Rudolf Adamkovič
iem...@gmail.com writes:

> You can write \(n\)-dimensional space.

ROFL.

My apologies for the laugh, but this question will keep coming over and
over and over until the end of times.  Clearly, there is a need for the
dash, and given the quality and syntactic stability of TeX, the problem
is not going anywhere ... ever.

Rudy
-- 
"'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and
if it were so, it would be; but as it isn't, it ain't.  That's logic.'"
-- Lewis Carroll, Through the Looking Glass, 1871/1872

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH v2] org-manual.org: $n$-th is not math

2023-03-19 Thread Rudolf Adamkovič
Max Nikulin  writes:

>> Bummer the dash will not be supported. :(
>
> You had an opportunity to submit an alternative patch fixing regexps.

But why?  We have seen such attempts already, such as

  "[PATCH] Add support for $…$ latex fragments followed by a dash"

The attempts were always rejected.  So, just a "bummer".  :)

Rudy
-- 
"One can begin to reason only when a clear picture has been formed in
the imagination."
-- Walter Warwick Sawyer, Mathematician's Delight, 1943

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [Pre-PATCH] Overhaul of the LaTeX preview system

2023-03-15 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> What about
>
> (define-fringe-bitmap
> 'sand-clock
> [#b
>  #b1001
>  #b0110
>  #b0110
>  #b01101110
>  #b0000
>  #b00011000
>  #b00100100
>  #b0110
>  #b01011010
>  #b
>  #b])

The good old hourglass is back! :)

Love it!

Rudy
-- 
"Strange as it may sound, the power of mathematics rests on its evasion
of all unnecessary thought and on its wonderful saving of mental
operations."
-- Ernst Mach, 1838-1916

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] org-manual.org: $n$-th is not math

2023-03-15 Thread Rudolf Adamkovič
Bummer the dash will not be supported. :(

(I am super-happy with $...$, except for the dash case.)

Max Nikulin  writes:

> Prefer =\(...\)= for + inline snippets.

Fragments, not snippets.  Right?

> The =$...$= alternative has some restrictions and may be source of confusion.

I am not a native speaker, but "may be a source of confusion" (note the "a")
sounds more correct.

Rudy
-- 
"It is no paradox to say that in our most theoretical moods we may be
nearest to our most practical applications."
-- Alfred North Whitehead, 1861-1947

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] org-src: Improve the name of source editing buffers

2023-03-14 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> [...] it may affect existing uses of `display-buffer-alist' [...]  Canceled.

Yeah, I did not realize it would be a breaking change.

Thank you folks for discussing my patch!

Rudy
-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] org-src: Improve the name of source editing buffers

2023-03-08 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> net-utils.el also has "*ftp [host]*". Notably, with space.
> I found no other use of [...] in Emacs sources.

Looking at my buffers, I see:

- e.g. "FILE" from Project.el
- e.g. "*EGLOT (PROJECT/(MODE)) events*" from Eglot
- e.g. "magit-diff(FILE1 -- FILE2): PROJECT" from Magit

All "normal looking" (spacing-wise), unlike e.g. "*Org Src FILE[ MODE ]*".

> Could you list other packages that use Foo[bar] pattern in buffer names?

Most packages use (), but I went with a minimal change, fixing just the weird
use of whitespace.

P.S. <> is for projects, so we should not use that, IMO.

Rudy
-- 
"'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and
if it were so, it would be; but as it isn't, it ain't.  That's logic.'"
-- Lewis Carroll, Through the Looking Glass, 1871/1872

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: org-babel guile source block bug in handling multiple values

2023-03-07 Thread Rudolf Adamkovič
Zelphir Kaltstahl  writes:

> There seems to be an issue with returning multiple values,

By the way, (Common) Lisp also has problems with multiple values in Org, as I
have recently learned in a discussion with the author of SLY (the modern
alternative to SLIME), João Távora.  He says:

> But this is wrong anyway, because in good Lisp REPL tradition, it should
> return the string braced with quotes, so it is READ able, and this doesn't
> work for multiple values anyway.
> 
> #+begin_src lisp
> (values 1 2 3)
> #+end_src
> 
> #+RESULTS:
> : 1

See (at the bottom of):

https://github.com/joaotavora/sly/issues/334

Rudy
-- 
"Chop your own wood and it will warm you twice."
-- Henry Ford; Francis Kinloch, 1819; Henry David Thoreau, 1854

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] org-clock: Add a trailing space to the mode line string

2023-03-07 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Because I missed it.

Gotcha!  (Just wanted to make sure I understand.)

> Now, added the info link.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c0a9c9ede

Thank you!

Rudy
-- 
"Genius is 1% inspiration and 99% perspiration."
-- Thomas Alva Edison, 1932

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] org-src: Improve the name of source editing buffers

2023-03-07 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Could you elaborate about "more standard"?

Sure.  For example, when I look at my Mode Line now, I see that the major more
is "Message[Notmuch]".  When I look at the names of the currently open buffers,
I see "FOO" and "{FOO}" and "[FOO] BAR" and "FOO(BAR)".  All this is "standard"
in Emacs.  I have yet to see a buffer, or anything else, named `FOO BAR[ BAZ ]'.

> A safer way to fix the inconsistency in the docstring would be updating
> the docstring to reflect the reality.

But misses the point, for I set out to fix the name itself.  I noticed the
documentation error only after the fact.

Every time I see "Org Src FOO BAR[ BAZ ]", it makes me think for a moment that I
must have misconfigured the mode line string or something.  And why?  Because it
looks "non-standard", like nothing else.

Rudy
-- 
"It is no paradox to say that in our most theoretical moods we may be
nearest to our most practical applications."
-- Alfred North Whitehead, 1861-1947

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] Fix LaTeX misspelled as Latex

2023-03-07 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Applied, onto bugfix. I amended the commit message removing the
> duplicate comments.

Thank you!

Rudy
-- 
"The introduction of suitable abstractions is our only mental aid to
organize and master complexity."
-- Edsger Wybe Dijkstra, 1930-2002

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] org-src: Improve the name of source editing buffers

2023-03-05 Thread Rudolf Adamkovič
I had a little bit of spare time today to refine the patch.

Changes:

- The patch now comes with a test to avoid regressions.
- The patch has a slightly better commit message.

Please see the attached file.

Thank you!

Rudy
>From a831b9014b3aaef16846dca049882a485ebf1dd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Sun, 5 Mar 2023 22:21:40 +0100
Subject: [PATCH] org-src: Improve naming of source editing buffers

* lisp/org-src.el (org-src--construct-edit-buffer-name): Fix the name
given to a source editing buffer.  The original format was documented
as "ORG-BUFFER-NAME [ LANG ]" but in reality it was "ORG-BUFFER-NAME[
LANG ]", with different spacing.  We make the format more standard and
more compact, as well as, make the documentation match reality.
* testing/lisp/test-org-src.el (test-org-src/buffer-name): Test the
buffer name used for 'org-edit-special'.
---
 lisp/org-src.el  |  4 ++--
 testing/lisp/test-org-src.el | 13 +
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 9e4392811..bb894de9c 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -315,8 +315,8 @@ is 0.")
 
 (defun org-src--construct-edit-buffer-name (org-buffer-name lang)
   "Construct the buffer name for a source editing buffer.
-Format is \"*Org Src ORG-BUFFER-NAME [ LANG ]*\"."
-  (concat "*Org Src " org-buffer-name "[ " lang " ]*"))
+Format is \"*Org Src ORG-BUFFER-NAME [LANG]*\"."
+  (concat "*Org Src " org-buffer-name " [" lang "]*"))
 
 (defun org-src--edit-buffer (beg end)
   "Return buffer editing area between BEG and END.
diff --git a/testing/lisp/test-org-src.el b/testing/lisp/test-org-src.el
index 2a45ba66e..8829ce306 100644
--- a/testing/lisp/test-org-src.el
+++ b/testing/lisp/test-org-src.el
@@ -491,6 +491,19 @@ This is a tab:\t.
   (should (equal "#" (org-unescape-code-in-string "#")))
   (should (equal "," (org-unescape-code-in-string ","
 
+;;; Other
+
+(ert-deftest test-org-src/buffer-name ()
+  "Buffer has the correct name."
+  (org-test-with-temp-text "
+#+begin_src emacs-lisp
+  (message hello)
+#+end_src"
+(rename-buffer "Buffy")
+(org-edit-special)
+(should (equal "*Org Src Buffy [emacs-lisp]*"
+   (buffer-name)))
+(org-edit-src-exit)))
 
 (provide 'test-org-src)
 ;;; test-org-src.el ends here
-- 
2.39.2

-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


Re: [PATCH] Fix LaTeX misspelled as Latex

2023-03-05 Thread Rudolf Adamkovič
.  INFO is a plist holding contextual information."
 	 info caption label)
  (t (org-html--wrap-latex-environment latex-frag info caption label)
 
- Latex Fragment
+ LaTeX Fragment
 
 (defun org-html-latex-fragment (latex-fragment _contents info)
   "Transcode a LATEX-FRAGMENT object from Org to HTML.
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index dc2062df5..b84fe89db 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2618,7 +2618,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	(otherwise "\\lstlistoflistings")
 
 
- Latex Environment
+ LaTeX Environment
 
 (defun org-latex--environment-type (latex-environment)
   "Return the TYPE of LATEX-ENVIRONMENT.
@@ -2676,7 +2676,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	  (insert caption)
 	  (buffer-string))
 
- Latex Fragment
+ LaTeX Fragment
 
 (defun org-latex-latex-fragment (latex-fragment _contents _info)
   "Transcode a LATEX-FRAGMENT object from Org to LaTeX.
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 5cb79ef23..5be0ca22e 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -486,7 +486,7 @@ channel."
 (_ (org-export-with-backend 'html keyword contents info
 
 
- Latex Environment
+ LaTeX Environment
 
 (defun org-md-latex-environment (latex-environment _contents info)
   "Transcode a LATEX-ENVIRONMENT object from Org to Markdown.
@@ -501,7 +501,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 latex-frag)
 latex-frag
 
- Latex Fragment
+ LaTeX Fragment
 
 (defun org-md-latex-fragment (latex-fragment _contents info)
   "Transcode a LATEX-FRAGMENT object from Org to Markdown.
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 949c8f9b5..cf217c9e7 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -1986,7 +1986,7 @@ information."
 	  (ignore
 
 
- Latex Environment
+ LaTeX Environment
 
 ;; (eval-after-load 'ox-odt '(ad-deactivate 'org-format-latex-as-mathml))
 ;; (advice-add 'org-format-latex-as-mathml	; FIXME
@@ -2007,7 +2007,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 (org-odt-do-format-code latex-frag info)))
 
 
- Latex Fragment
+ LaTeX Fragment
 
 ;; (when latex-frag			; FIXME
 ;; 	(setq href (propertize href :title "LaTeX Fragment"
diff --git a/testing/examples/ob-maxima-test.org b/testing/examples/ob-maxima-test.org
index b6be52b5b..b83114a4f 100644
--- a/testing/examples/ob-maxima-test.org
+++ b/testing/examples/ob-maxima-test.org
@@ -79,7 +79,7 @@ m: genmatrix (lambda([i,j], i+j-1), 3, 3)$
 write_data(m, "/dev/stdout")$
 #+end_src
 
-* Latex output
+* LaTeX output
 #+begin_src maxima  :exports both :results latex :results verbatim
 assume(x>0);
 tex(ratsimp(diff(%e^(a*x), x)));
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 957e99194..304059c67 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1686,7 +1686,7 @@ Paragraph"
  (= (org-element-property :end (org-element-at-point)) (point-max)
 
 
- Latex Environment
+ LaTeX Environment
 
 (ert-deftest test-org-element/latex-environment-parser ()
   "Test `latex-environment' parser."
@@ -1751,7 +1751,7 @@ e^{i\\pi}+1=0
  (= (org-element-property :end (org-element-at-point)) (point-max)
 
 
- Latex Fragment
+ LaTeX Fragment
 
 (ert-deftest test-org-element/latex-fragment-parser ()
   "Test `latex-fragment' parser."
@@ -4162,7 +4162,7 @@ Text
   (org-element-type (org-element-at-point))
   (should-not (eq 'headline
   (org-test-with-temp-text "* H1\nP1\n*H2\n"
-(let ((org-element-use-cache t))  
+(let ((org-element-use-cache t))
   (org-element-cache-map #'ignore :granularity 'element)
   (backward-delete-char 1)
   (org-element-type (org-element-at-point))
-- 
2.39.2

-- 
"Programming reliably -- must be an activity of an undeniably
mathematical nature […] You see, mathematics is about thinking, and
doing mathematics is always trying to think as well as possible."
-- Edsger W. Dijkstra, 1981

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


[PATCH] Fix BibTeX spelled as Bibtex

2023-03-05 Thread Rudolf Adamkovič
* lisp/ol-bibtex.el: Spell BibTeX correctly
* etc/ORG-NEWS (Org-BibTeX -- major improvements): Spell BibTeX correctly
---
 etc/ORG-NEWS  |  2 +-
 lisp/ol-bibtex.el | 22 +++---
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 988dfea93..fcb4d2af0 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -6644,7 +6644,7 @@ that Calc formulas can operate on them.
 
 *** Hyperlinks
 
- Org-Bibtex -- major improvements
+ Org-BibTeX -- major improvements
 
  Provides support for managing bibtex bibliographical references
  data in headline properties.  Each headline corresponds to a
diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el
index 7d6ed8534..fd9517233 100644
--- a/lisp/ol-bibtex.el
+++ b/lisp/ol-bibtex.el
@@ -86,8 +86,8 @@
 ;;   the active region, then call `org-bibtex-write' in a .org file to
 ;;   insert a heading for the read bibtex entry
 ;;
-;; - All Bibtex information is taken from the document compiled by
-;;   Andrew Roberts from the Bibtex manual, available at
+;; - All BibTeX information is taken from the document compiled by
+;;   Andrew Roberts from the BibTeX manual, available at
 ;;   https://www.andy-roberts.net/res/writing/latex/bibentries.pdf
 ;;
 ;;; History:
@@ -99,7 +99,7 @@
 ;; and then implemented by Bastien Guerry.
 ;;
 ;; Eric Schulte eventually added the functions for translating between
-;; Org headlines and Bibtex entries, and for fleshing out the Bibtex
+;; Org headlines and BibTeX entries, and for fleshing out the BibTeX
 ;; fields of existing Org headlines.
 ;;
 ;; Org mode loads this module by default - if this is not what you want,
@@ -144,7 +144,7 @@
 (declare-function org-search-view "org-agenda" ( todo-only string 
edit-at))
 
 
-;;; Bibtex data
+;;; BibTeX data
 (defvar org-bibtex-types
   '((:article
  (:description . "An article from a journal or magazine")
@@ -202,7 +202,7 @@
  (:description . "A document having an author and title, but not formally 
published.")
  (:required :author :title :note)
  (:optional :month :year :doi :url)))
-  "Bibtex entry types with required and optional parameters.")
+  "BibTeX entry types with required and optional parameters.")
 
 (defvar org-bibtex-fields
   '((:address  . "Usually the address of the publisher or other type of 
institution.  For major publishing houses, van Leunen recommends omitting the 
information entirely.  For small publishers, on the other hand, you can help 
the reader by giving the complete address.")
@@ -231,7 +231,7 @@
 (:url  . "Uniform resource locator.")
 (:volume   . "The volume of a journal or multi-volume book.")
 (:year . "The year of publication or, for an unpublished work, the 
year it was written.  Generally it should consist of four numerals, such as 
1984, although the standard styles can handle any year whose last four 
nonpunctuation characters are numerals, such as '(about 1984)'"))
-  "Bibtex fields with descriptions.")
+  "BibTeX fields with descriptions.")
 
 (defvar org-bibtex-entries nil
   "List to hold parsed bibtex entries.")
@@ -439,7 +439,7 @@ at point."
 (error "Field:%s is not known" field))
   (save-window-excursion
 (let* ((name (substring (symbol-name field) 1))
-  (buf-name (format "*Bibtex Help %s*" name)))
+  (buf-name (format "*BibTeX Help %s*" name)))
   (with-output-to-temp-buffer buf-name
(princ (cdr (assoc field org-bibtex-fields
   (with-current-buffer buf-name (visual-line-mode 1))
@@ -496,7 +496,7 @@ With optional argument OPTIONAL, also prompt for optional 
fields."
 (org-bibtex-autokey)))
 
 
-;;; Bibtex link functions
+;;; BibTeX link functions
 (org-link-set-parameters "bibtex"
 :follow #'org-bibtex-open
 :store #'org-bibtex-store-link)
@@ -593,13 +593,13 @@ ARG, when non-nil, is a universal prefix argument.  See
 (add-hook 'org-execute-file-search-functions 
'org-execute-file-search-in-bibtex)
 
 
-;;; Bibtex <-> Org headline translation functions
+;;; BibTeX <-> Org headline translation functions
 (defun org-bibtex (filename)
   "Export each headline in the current file to a bibtex entry.
 Headlines are exported using `org-bibtex-headline'."
   (interactive
(list (read-file-name
- "Bibtex file: " nil nil nil
+ "BibTeX file: " nil nil nil
  (let ((file (buffer-file-name (buffer-base-buffer
(and file
 (file-name-nondirectory
@@ -619,7 +619,7 @@ Headlines are exported using `org-bibtex-headline'."
 nil
 (when error-point
   (goto-char error-point)
-  (message "Bibtex error at %S" (nth 4 (org-heading-components))
+  (message "BibTeX error at %S" (nth 4 (org-heading-components))
 
 (defun org-bibtex-check ( optional)
   "Check the current headline for required fields.
-- 
2.39.2




[PATCH] Fix LaTeX misspelled as Latex

2023-03-05 Thread Rudolf Adamkovič
* etc/ORG-NEWS (Non-floating minted listings in LaTeX export): Spell LaTeX
correctly.
* lisp/ob-latex.el: (org-babel-execute:latex): Spell LaTeX correctly.
* lisp/org-element.el (org-element-latex-fragment-parser): Spell LaTeX
correctly.
* lisp/ox-ascii.el (org-ascii-latex-fragment): Spell LaTeX correctly.
* lisp/ox-html.el (org-html-latex-fragment): Spell LaTeX correctly.
* lisp/ox-latex.el (org-latex-latex-fragment): Spell LaTeX correctly.
* lisp/ox-md.el (org-md-latex-fragment): Spell LaTeX correctly.
* lisp/ox-odt.el: Spell LaTeX correctly.
* testing/examples/ob-maxima-test.org (LaTeX output): Spell LaTeX correctly.
* testing/lisp/test-org-element.el (test-org-element/cache): Spell LaTeX
correctly.
---
 etc/ORG-NEWS| 4 ++--
 lisp/ob-latex.el| 2 +-
 lisp/org-element.el | 4 ++--
 lisp/ox-ascii.el| 4 ++--
 lisp/ox-html.el | 4 ++--
 lisp/ox-latex.el| 4 ++--
 lisp/ox-md.el   | 4 ++--
 lisp/ox-odt.el  | 4 ++--
 testing/examples/ob-maxima-test.org | 2 +-
 testing/lisp/test-org-element.el| 6 +++---
 10 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 988dfea93..388aa07a3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -437,7 +437,7 @@ When the block type starts from the upper case, structure 
template
 will now insert =#+BEGIN_TYPE=.  Previously, lower-case =#+begin_type= was 
inserted unconditionally.
 *** New ox-latex tabbing support for tables.
 
-Latex tables can now be exported to the latex tabbing environment
+LaTeX tables can now be exported to the latex tabbing environment
 tabbing environment]].
 This is done by adding =#+ATTR_LATEX: :mode tabbing= at the top
 of the table.
@@ -4388,7 +4388,7 @@ parameters specific to some pre-defined translators, e.g.,
 ~:environment~ and ~:booktabs~ for ~orgtbl-to-latex~.  See translators
 docstrings (including ~orgtbl-to-generic~) for details.
 
-*** Non-floating minted listings in Latex export
+*** Non-floating minted listings in LaTeX export
 
 It is not possible to specify =#+attr_latex: :float nil= in conjunction
 with source blocks exported by the minted package.
diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el
index 428907a27..730da01b9 100644
--- a/lisp/ob-latex.el
+++ b/lisp/ob-latex.el
@@ -141,7 +141,7 @@ exporting the literal LaTeX source."
   (org-trim body))
 
 (defun org-babel-execute:latex (body params)
-  "Execute a block of Latex code with Babel.
+  "Execute a block of LaTeX code with Babel.
 This function is called by `org-babel-execute-src-block'."
   (setq body (org-babel-expand-body:latex body params))
   (if (cdr (assq :file params))
diff --git a/lisp/org-element.el b/lisp/org-element.el
index f8442511c..7ccdb103d 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -2469,7 +2469,7 @@ CDR is a plist containing `:key', `:value', `:begin', 
`:end',
  (org-element-property :value keyword)))
 
 
- Latex Environment
+ LaTeX Environment
 
 (defconst org-element--latex-begin-environment
   "^[ \t]*begin{\\([A-Za-z0-9*]+\\)}"
@@ -3419,7 +3419,7 @@ CONTENTS is the contents of the object."
   (format "/%s/" contents))
 
 
- Latex Fragment
+ LaTeX Fragment
 
 (defun org-element-latex-fragment-parser ()
   "Parse LaTeX fragment at point, if any.
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index e5bdf92cb..e267b004b 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -1549,7 +1549,7 @@ information."
keyword info)
 
 
- Latex Environment
+ LaTeX Environment
 
 (defun org-ascii-latex-environment (latex-environment _contents info)
   "Transcode a LATEX-ENVIRONMENT element from Org to ASCII.
@@ -1561,7 +1561,7 @@ information."
  latex-environment info)))
 
 
- Latex Fragment
+ LaTeX Fragment
 
 (defun org-ascii-latex-fragment (latex-fragment _contents info)
   "Transcode a LATEX-FRAGMENT object from Org to ASCII.
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 37c474409..82e266dde 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2968,7 +2968,7 @@ CONTENTS is nil.  INFO is a plist holding contextual 
information."
 ((string= "listings" value) (org-html-list-of-listings info))
 ((string= "tables" value) (org-html-list-of-tables info
 
- Latex Environment
+ LaTeX Environment
 
 (defun org-html-format-latex (latex-frag processing-type info)
   "Format a LaTeX fragment LATEX-FRAG into HTML.
@@ -3085,7 +3085,7 @@ CONTENTS is nil.  INFO is a plist holding contextual 
information."
 info caption label)
  (t (org-html--wrap-latex-environment latex-frag info caption label)
 
- Latex Fragment
+ LaTeX Fragment
 
 (defun org-html-latex-fragment (latex-fragment _contents info)
   "Transcode a LATEX-FRAGMENT object from Org to HTML.
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index dc2062df5..b84fe89db 100644

Re: [PATCH] org-clock: Add a trailing space to the mode line string

2023-03-05 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Thanks!
> Applied, onto bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3d817c52c

Why not the one with the correct Info link, as per Max's excellent nitpick?

Rudy
-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] org-clock: Add a trailing space to the mode line string

2023-03-04 Thread Rudolf Adamkovič
Max Nikulin  writes:

> nitpick
>
> [...]
>
>> To make a hyperlink to Info documentation, [...]

That is a good nitpick, thank you!

Fixed in the attached patch (along with indentation).

Rudy
>From 60c86cf1991e5437084b3efb28f0866c5a50ca6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Thu, 2 Mar 2023 15:06:19 +0100
Subject: [PATCH] org-clock: Add a trailing space to the mode line string

* lisp/org-clock.el (org-clock-get-clock-string): End the mode line
element in a space, instead of beginning with space, to make it play
well with other mode line strings, which typically end a space.  For
reference, see the mode line string of the Display Time mode.
---
 lisp/org-clock.el  |  4 ++--
 testing/lisp/test-org-clock.el | 35 ++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index d46458536..a300df8ff 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -728,9 +728,9 @@ If not, show simply the clocked time like 01:50."
 'org-mode-line-clock-overrun
 			  'org-mode-line-clock)))
 	   (effort-str (org-duration-from-minutes effort-in-minutes)))
-	  (format (propertize " [%s/%s] (%s)" 'face 'org-mode-line-clock)
+	  (format (propertize "[%s/%s] (%s) " 'face 'org-mode-line-clock)
 		  work-done-str effort-str org-clock-heading))
-  (format (propertize " [%s] (%s)" 'face 'org-mode-line-clock)
+  (format (propertize "[%s] (%s) " 'face 'org-mode-line-clock)
 	  (org-duration-from-minutes clocked-time)
 	  org-clock-heading
 
diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index f732e471a..239634cb9 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -1276,5 +1276,40 @@ CLOCK: [2012-03-29 Thu 16:00]--[2012-03-29 Thu 17:00] =>  1:00"
   (test-org-clock-clocktable-contents
(format ":hidefiles t :scope (lambda () (list %S))" the-file
 
+;;; Mode line
+
+(ert-deftest test-org-clock/mode-line ()
+  "Test mode line string ends in a space.
+
+\"Elements that are added to [the mode line] should normally end
+in a space (to ensure that consecutive 'global-mode-string'
+elements display properly)\" per the Info node `(elisp)Mode Line
+Variables'."
+  ;; Test the variant without effort.
+  (should
+   (equal
+" [0:00] (Heading)  "
+(org-test-with-temp-text
+ "* Heading"
+ (org-clock-in)
+ (prog1 (concat " "
+(org-clock-get-clock-string)
+" ")
+   (org-clock-out)
+  ;; Test the variant with effort.
+  (should
+   (equal
+" [0:00/1:00] (Heading)  "
+(org-test-with-temp-text
+ "* Heading
+:PROPERTIES:
+:EFFORT: 1h
+:END:"
+ (org-clock-in)
+ (prog1 (concat " "
+(org-clock-get-clock-string)
+" ")
+   (org-clock-out))
+
 (provide 'test-org-clock)
 ;;; test-org-clock.el end here
-- 
2.39.2

-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


Re: [PATCH] org-clock: Add a trailing space to the mode line string

2023-03-03 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Rudolf, I am OK with the patch, but could you please add a comment
> explaining why trailing space, so that people do not wonder in future?

Please see the attached patch, revised as follows:

- no leading space in the mode line element to make it completely correct
- a clear explanation (with a citation) to avoid pointless discussions
- two new automated tests to avoid future regressions
- a clearer commit message

Rudy
>From 29aca1a54a68aae1f2b38c3a7885f7ee2f155b24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Thu, 2 Mar 2023 15:06:19 +0100
Subject: [PATCH] org-clock: Add a trailing space to the mode line string

* lisp/org-clock.el (org-clock-get-clock-string): End the mode line
element in a space, instead of beginning with space, to make it play
well with other mode line strings, which typically end a space.  For
reference, see the mode line string of the Display Time mode.
---
 lisp/org-clock.el  |  4 ++--
 testing/lisp/test-org-clock.el | 35 ++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index d46458536..a300df8ff 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -728,9 +728,9 @@ If not, show simply the clocked time like 01:50."
 'org-mode-line-clock-overrun
 			  'org-mode-line-clock)))
 	   (effort-str (org-duration-from-minutes effort-in-minutes)))
-	  (format (propertize " [%s/%s] (%s)" 'face 'org-mode-line-clock)
+	  (format (propertize "[%s/%s] (%s) " 'face 'org-mode-line-clock)
 		  work-done-str effort-str org-clock-heading))
-  (format (propertize " [%s] (%s)" 'face 'org-mode-line-clock)
+  (format (propertize "[%s] (%s) " 'face 'org-mode-line-clock)
 	  (org-duration-from-minutes clocked-time)
 	  org-clock-heading
 
diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index f732e471a..a1ca9e25b 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -1276,5 +1276,40 @@ CLOCK: [2012-03-29 Thu 16:00]--[2012-03-29 Thu 17:00] =>  1:00"
   (test-org-clock-clocktable-contents
(format ":hidefiles t :scope (lambda () (list %S))" the-file
 
+;;; Mode line
+
+(ert-deftest test-org-clock/mode-line ()
+  "Test mode line string ends in a space.
+
+\"Elements that are added to [the mode line] should normally end
+in a space (to ensure that consecutive 'global-mode-string'
+elements display properly)\" per Emacs manual, Section 24.4.4
+Variables Used in the Mode Line."
+  ;; Test the variant without effort.
+  (should
+   (equal
+" [0:00] (Heading)  "
+(org-test-with-temp-text
+"* Heading"
+  (org-clock-in)
+  (prog1 (concat " "
+ (org-clock-get-clock-string)
+ " ")
+(org-clock-out)
+  ;; Test the variant with effort.
+  (should
+   (equal
+" [0:00/1:00] (Heading)  "
+(org-test-with-temp-text
+"* Heading
+:PROPERTIES:
+:EFFORT: 1h
+:END:"
+  (org-clock-in)
+  (prog1 (concat " "
+ (org-clock-get-clock-string)
+ " ")
+(org-clock-out))
+
 (provide 'test-org-clock)
 ;;; test-org-clock.el end here
-- 
2.39.2

-- 
"One can begin to reason only when a clear picture has been formed in
the imagination."
-- Walter Warwick Sawyer, Mathematician's Delight, 1943

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


[PATCH] org-clock: Add a trailing space to the mode line string

2023-03-02 Thread Rudolf Adamkovič
* lisp/org-clock.el (org-clock-get-clock-string): End the mode line
string with a space character to make it play well with other mode
line strings which traditionally end with a space character.  For
reference, see the mode line string of the Display Time mode.
---
 lisp/org-clock.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index d46458536..0154c9a0c 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -728,9 +728,9 @@ If not, show simply the clocked time like 01:50."
'org-mode-line-clock-overrun
  'org-mode-line-clock)))
   (effort-str (org-duration-from-minutes effort-in-minutes)))
- (format (propertize " [%s/%s] (%s)" 'face 'org-mode-line-clock)
+ (format (propertize " [%s/%s] (%s) " 'face 'org-mode-line-clock)
  work-done-str effort-str org-clock-heading))
-  (format (propertize " [%s] (%s)" 'face 'org-mode-line-clock)
+  (format (propertize " [%s] (%s) " 'face 'org-mode-line-clock)
  (org-duration-from-minutes clocked-time)
  org-clock-heading
 
-- 
2.39.2




[PATCH] org-src: Improve the name of source editing buffers

2023-03-02 Thread Rudolf Adamkovič
* lisp/org-src.el (org-src--construct-edit-buffer-name): Fix the name
given to a source editing buffer.  The original format was documented
as "ORG-BUFFER-NAME [ LANG ]" but in reality it was 'ORG-BUFFER-NAME[
LANG ]', with different spacing.  We make the format more standard and
more compact, as well as, make the documentation match reality.
---
 lisp/org-src.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 9e4392811..bb894de9c 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -315,8 +315,8 @@ is 0.")
 
 (defun org-src--construct-edit-buffer-name (org-buffer-name lang)
   "Construct the buffer name for a source editing buffer.
-Format is \"*Org Src ORG-BUFFER-NAME [ LANG ]*\"."
-  (concat "*Org Src " org-buffer-name "[ " lang " ]*"))
+Format is \"*Org Src ORG-BUFFER-NAME [LANG]*\"."
+  (concat "*Org Src " org-buffer-name " [" lang "]*"))
 
 (defun org-src--edit-buffer (beg end)
   "Return buffer editing area between BEG and END.
-- 
2.39.2




Re: [PATCH 0/4] Structure editing when region is active

2023-02-15 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> They indeed do not. Only on selected list items. Patches welcome!

Oh, wait I see.  Non-recursive manipulation (l/r) works with marked regions but
recursive manipulation (L/R) does not work yet.  Then, it all behaves correctly
and "patches welcome" makes sense (to make it work in both cases).  Gotcha!

P.S. It took me a while to get all this because I do not use (nor have, for that
matter) arrow keys, and those nonsensical function names mean absolutely nothing
to me.

Rudy
-- 
"Chop your own wood and it will warm you twice."
-- Henry Ford; Francis Kinloch, 1819; Henry David Thoreau, 1854

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code

2023-02-15 Thread Rudolf Adamkovič
Max Nikulin  writes:

> Since content of subr-x.el consists of `defsubst' definitions, likely it 
> is preferable to use
>
>  (eval-when-compile (require 'subr-x))

All right, I added the 'require' to both files.  Better?

Rudy

>From 384515548a4eb790e9b947e484dd9da41bdece94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Mon, 6 Feb 2023 22:33:40 +0100
Subject: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection
 code

* lisp/ox-texinfo.el (org-texinfo-supports-math-p): Fix the incorrect
syntax @displaymath{1 + 1 = 2} used to detect whether Texinfo supports
TeX "math mode".  Instead, use the correct syntax @math{1 + 1 = 2}.
---
 lisp/ox-texinfo.el  | 16 ++--
 testing/lisp/test-ox-texinfo.el | 32 
 2 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index 8e3a04562..4ff482cc3 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -32,6 +32,8 @@
 (require 'cl-lib)
 (require 'ox)
 
+(eval-when-compile (require 'subr-x))
+
 (defvar orgtbl-exp-regexp)
 (defvar org-texinfo-supports-math--cache)
 
@@ -2025,12 +2027,14 @@ Once computed, the results remain cached."
   (unless (boundp 'org-texinfo-supports-math--cache)
 (setq org-texinfo-supports-math--cache
   (let ((math-example "1 + 1 = 2"))
-(let* ((input-file
-(make-temp-file "test" nil ".info"))
-   (input-content
-(concat (format "@setfilename %s" input-file) "\n"
-"@node Top" "\n"
-(format "@displaymath{%s}" math-example) "\n")))
+(let* ((input-file (make-temp-file "test" nil ".info"))
+   (input-content (string-join
+   (list (format "@setfilename %s" input-file)
+ "@node Top"
+ "@displaymath"
+ math-example
+ "@end displaymath")
+   "\n")))
   (with-temp-file input-file
 (insert input-content))
   (let* ((output-file (org-texinfo-compile input-file))
diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el
index 51fdb3606..38395500d 100644
--- a/testing/lisp/test-ox-texinfo.el
+++ b/testing/lisp/test-ox-texinfo.el
@@ -24,6 +24,8 @@
 (require 'cl-lib)
 (require 'ox-texinfo)
 
+(eval-when-compile (require 'subr-x))
+
 (unless (featurep 'ox-texinfo)
   (signal 'missing-test-dependency "org-export-texinfo"))
 
@@ -292,5 +294,35 @@
  nil
  '(:with-latex t))
 
+
+;;; End-to-end
+
+(ert-deftest test-ox-texinfo/end-to-end-inline ()
+  "Test end-to-end with inline TeX fragment."
+  (should
+   (org-test-with-temp-text
+"$a^2 = b$"
+(let ((export-buffer "*Test Texinfo Export*")
+  (org-export-show-temporary-export-buffer nil))
+  (org-export-to-buffer 'texinfo export-buffer
+nil nil nil nil nil
+#'texinfo-mode)
+
+(ert-deftest test-ox-texinfo/end-to-end-sanity-check-displayed ()
+  "Test end-to-end with LaTeX environment."
+  (should
+   (org-test-with-temp-text
+(string-join
+ (list "\\begin{equation}"
+   "a ^ 2 = b"
+   "b ^ 2 = c"
+   "\\end{equation}")
+ "\n")
+(let ((export-buffer "*Test Texinfo Export*")
+  (org-export-show-temporary-export-buffer nil))
+  (org-export-to-buffer 'texinfo export-buffer
+nil nil nil nil nil
+#'texinfo-mode)
+
 (provide 'test-ox-texinfo)
 ;;; test-ox-texinfo.el end here
-- 
2.39.0

-- 
"Chop your own wood and it will warm you twice."
-- Henry Ford; Francis Kinloch, 1819; Henry David Thoreau, 1854

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code

2023-02-07 Thread Rudolf Adamkovič
Max Nikulin  writes:

> Should not the format argument be corrected to have valid @displaymath 
> snippet instead?

Thank you, Max!  See, this happens when I write code 10 minutes before going to
bed: incorrect code and no tests, both equally bad.

Please see the attached patch.

Rudy
>From ce1062dbda870346b18ae35c28e9cc034c0de548 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Mon, 6 Feb 2023 22:33:40 +0100
Subject: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection
 code

* lisp/ox-texinfo.el (org-texinfo-supports-math-p): Fix the incorrect
syntax @displaymath{1 + 1 = 2} used to detect whether Texinfo supports
TeX "math mode".  Instead, use the correct syntax @math{1 + 1 = 2}.
---
 lisp/ox-texinfo.el  | 14 --
 testing/lisp/test-ox-texinfo.el | 30 ++
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index 8e3a04562..56564a5c5 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -2025,12 +2025,14 @@ Once computed, the results remain cached."
   (unless (boundp 'org-texinfo-supports-math--cache)
 (setq org-texinfo-supports-math--cache
   (let ((math-example "1 + 1 = 2"))
-(let* ((input-file
-(make-temp-file "test" nil ".info"))
-   (input-content
-(concat (format "@setfilename %s" input-file) "\n"
-"@node Top" "\n"
-(format "@displaymath{%s}" math-example) "\n")))
+(let* ((input-file (make-temp-file "test" nil ".info"))
+   (input-content (string-join
+   (list (format "@setfilename %s" input-file)
+ "@node Top"
+ "@displaymath"
+ math-example
+ "@end displaymath")
+   "\n")))
   (with-temp-file input-file
 (insert input-content))
   (let* ((output-file (org-texinfo-compile input-file))
diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el
index 51fdb3606..4bb902988 100644
--- a/testing/lisp/test-ox-texinfo.el
+++ b/testing/lisp/test-ox-texinfo.el
@@ -292,5 +292,35 @@
  nil
  '(:with-latex t))
 
+
+;;; End-to-end
+
+(ert-deftest test-ox-texinfo/end-to-end-inline ()
+  "Test end-to-end with inline TeX fragment."
+  (should
+   (org-test-with-temp-text
+"$a^2 = b$"
+(let ((export-buffer "*Test Texinfo Export*")
+  (org-export-show-temporary-export-buffer nil))
+  (org-export-to-buffer 'texinfo export-buffer
+nil nil nil nil nil
+#'texinfo-mode)
+
+(ert-deftest test-ox-texinfo/end-to-end-sanity-check-displayed ()
+  "Test end-to-end with LaTeX environment."
+  (should
+   (org-test-with-temp-text
+(string-join
+ (list "\\begin{equation}"
+   "a ^ 2 = b"
+   "b ^ 2 = c"
+   "\\end{equation}")
+ "\n")
+(let ((export-buffer "*Test Texinfo Export*")
+  (org-export-show-temporary-export-buffer nil))
+  (org-export-to-buffer 'texinfo export-buffer
+nil nil nil nil nil
+    #'texinfo-mode)
+
 (provide 'test-ox-texinfo)
 ;;; test-ox-texinfo.el end here
-- 
2.39.0

-- 
"Strange as it may sound, the power of mathematics rests on its evasion
of all unnecessary thought and on its wonderful saving of mental
operations."
-- Ernst Mach, 1838-1916

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


[PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code

2023-02-06 Thread Rudolf Adamkovič
* lisp/ox-texinfo.el (org-texinfo-supports-math-p): Fix the incorrect
syntax @displaymath{1 + 1 = 2} used to detect whether Texinfo supports
TeX "math mode".  Instead, use the correct syntax @math{1 + 1 = 2}.
---
 lisp/ox-texinfo.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index 8e3a04562..7ee4bc533 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -2030,7 +2030,7 @@ Once computed, the results remain cached."
(input-content
 (concat (format "@setfilename %s" input-file) "\n"
 "@node Top" "\n"
-(format "@displaymath{%s}" math-example) "\n")))
+(format "@math{%s}" math-example) "\n")))
   (with-temp-file input-file
 (insert input-content))
   (let* ((output-file (org-texinfo-compile input-file))
-- 
2.39.0




Re: [PATCH 0/4] Structure editing when region is active

2023-02-06 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Applied, onto main, dropping the patch to preserve region upon setting
> heading state. I also merged the NEWS patch into the corresponding
> feature patches.
>
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=b665f8de3
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c8a5fef91

FANTASTIC work, thank you!

However, I find it a bit surprising (confusing, really) that

  'C-c C-x R' and 'C-c C-x L'

do not promote/demote the selected subtrees, despite being documented as 

  "Demote subtree or insert table column."

and then

  'C-c C-x r' and 'C-c C-x l'

do promote/demote selected subtrees despite being documented as

  "Demote heading, list item at point or move table column right."

I immediately reached for the subtree manipulation commands, but they did not
work on the marked subtrees.  Confused, I tried the headline manipulation
commands, and they did work ... on the marked subtrees.

Rudy
-- 
"Mathematics takes us still further from what is human into the region
of absolute necessity, to which not only the actual world, but every
possible world, must conform."
-- Bertrand Russell, 1902

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Org html conversion with XyJax

2023-01-27 Thread Rudolf Adamkovič
Partha Pratim Ghosh  writes:

> #-*- mode: org -*-

FYI: You do not need this line if the file has an '.org' extension.

> #+TITLE: test
> #+AUTHOR: Partha

> #+latex_header:\usepackage{Documents/tex/essentials/symbols}

Note that this header applies to LaTeX and will not work with MathJax.

You can make Org to use actual LaTeX in HTML by adding

#+OPTIONS: tex:dvisvgm

to your document.

> Can I use \LaTeX ? Let us try: $f: A\rightarrow B$ is a function

MathJax ignores \LaTeX but renders the function correctly.

(I tried with plain 'emacs -Q' on Emacs 30.)

> $\xymatrix{ {A} \ar@{o->}[r] & {B} }$

MathJax does not recognize this, hence the "Misplaced &" error.

You have two options here: either (1) install the MathJax extension you
mentioned or (2) make Org to use LaTeX for HTML.

If you decide to go the MathJax/JavaScript route, please note that you need to
use Emacs 29 or later, where Org uses MathJax 3 and not 2.

> \Arr{f}{A}{B}

MathJax does not recognize this either.

> 2. The file exports perfectly to pdf:

That happens because Org always uses LaTeX for PDF documents.  If you want it to
use LaTeX for HTML too, see the OPTIONS above.

Rudy
-- 
"Chop your own wood and it will warm you twice."
-- Henry Ford; Francis Kinloch, 1819; Henry David Thoreau, 1854

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Babel (scheme): Evaluation errors are not shown

2023-01-06 Thread Rudolf Adamkovič
Bastien  writes:

> Sure, done.

Thank you for your understanding, Bastien!

> (Or write ob-fennel.el?)

It already exists, FYI:

https://gitlab.com/andreyorst/ob-fennel

Rudy
-- 
"Simplicity is complexity resolved."
-- Constantin Brâncuși, 1876-1957

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Babel (scheme): Evaluation errors are not shown

2023-01-03 Thread Rudolf Adamkovič
Bastien Guerry  writes:

> I just added you as the maintainer of ob-scheme.el.

A sudden turn of events:

My employer have just decided that we will convert all Scheme to Fennel,
a zero-runtime Lisp based on Lua, because it has a better bus factor,
meaning that, in the worst-case, the company can continue with Lua, a
language for which one can find programmers more easily than for Scheme.

So, my use of Scheme drops from 8 hours per day to effectively 0,
effective today.  As a result, I would like to kindly ask you to revert
the change, for without actively using something, I cannot maintain it.

That said, if my employer changes their mind during the transition from
Scheme to Fennel and decides to keep the current code base, I will
re-volunteer.

Thank you for understanding, and I again apologize for the churn!

Rudy
-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Radio links work only in small numbers

2022-12-19 Thread Rudolf Adamkovič
Max Nikulin  writes:

> On 14/12/2022 06:10, Rudolf Adamkovič wrote:
>> 
>> All [[link]]s in my notes perfectly match LEVEL-1 headings, so I figured
>> that I may as well ask Org to make links for me.  So, I replaced all the
>> ~4000 headings in my notes with radio <<>>.  However, Org now
>> errors out with "Regular expression too big".
>
> I think, you are abusing the feature. Too light markup requires too 
> heavy processing. What about <> and explicit [[target]]?

For context, I started using radio links back when I started studying
biology, and they helped me tremendously.  However, as I learned more,
Org "gave up".  Personally, I would not call taking some more notes
"abusing the feature", especially given the fact that the manual says
nothing about the limitation, and it stopped working pretty quickly.

That said, two days ago, I split my notebook into smaller files, so
radio links will not work for me anymore!

[1]: https://orgmode.org/manual/Radio-Targets.html
-- 
"Thinking is a momentary dismissal of irrelevancies."
-- Richard Buckminster Fuller, 1969

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Bash results broken?

2022-12-19 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Fixed on bugfix.

I can confirm that the fix works.  Thank you!

Rudy
-- 
"Programming reliably -- must be an activity of an undeniably
mathematical nature […] You see, mathematics is about thinking, and
doing mathematics is always trying to think as well as possible."
-- Edsger W. Dijkstra, 1981

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Babel (scheme): Evaluation errors are not shown

2022-12-19 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Note that we currently have no maintainer for ob-scheme and hence can
> only provide very limited support. New features are hard for us
> without experience with scheme and geiser.

I volunteer to maintain `ob-scheme'.

(I use Scheme and Geiser heavily at work, albeit not via Org.)

Rudy
-- 
"Mathematics takes us still further from what is human into the region
of absolute necessity, to which not only the actual world, but every
possible world, must conform."
-- Bertrand Russell, 1902

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Bash results broken?

2022-12-16 Thread Rudolf Adamkovič
Reproduction steps:

#+BEGIN_SRC bash :results list
echo 1
echo 2
echo 3
#+END_SRC

Actual:

#+RESULTS:
- (1)
- (2)
- (3)

Expected:

#+RESULTS:
- 1
- 2
- 3

Rudy
-- 
"Logic is a science of the necessary laws of thought, without which no
employment of the understanding and the reason takes place."
-- Immanuel Kant, 1785

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Radio links work only in small numbers

2022-12-14 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Can you try the attached patch?

No luck:

  "Regular expression too big"

Still too large:

  (length org-target-link-regexp) => 33219

:-(

Rudy
-- 
"Programming reliably -- must be an activity of an undeniably
mathematical nature […] You see, mathematics is about thinking, and
doing mathematics is always trying to think as well as possible."
-- Edsger W. Dijkstra, 1981

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Radio links work only in small numbers

2022-12-13 Thread Rudolf Adamkovič
Greetings smart people!

All [[link]]s in my notes perfectly match LEVEL-1 headings, so I figured
that I may as well ask Org to make links for me.  So, I replaced all the
~4000 headings in my notes with radio <<>>.  However, Org now
errors out with "Regular expression too big".

Does anyone know how to overcome this limitation?  Or, perhaps someone
has a patch in works that fixes it?  If so, please let me know!

Thank you.

Rudy
-- 
"The introduction of suitable abstractions is our only mental aid to
organize and master complexity."
-- Edsger Wybe Dijkstra, 1930-2002

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [HELP] Translate/extend `org-clock-clocktable-language-setup' for Spanish/Dutch/more languages

2022-12-13 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> A patch would make it easier for me to apply the change with a proper
> attribution ;)

Ihor patches code faster than others poll their e-mail.  Thanks!  :)

Rudy
-- 
"Thinking is a momentary dismissal of irrelevancies."
-- Richard Buckminster Fuller, 1969

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Flyspell process called frequently when using Org export (was: Flyspell causes severe slowdown when manipulating footnotes)

2022-12-11 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Rudolf Adamkovič  writes:
>
>> Unrelated to the footnotes mentioned above
>
> Note how I change the email subject to mark a new topic.
> In Emacs, it is M-x message-change-subject

TIL!  Thank you.

> I am unable to reproduce using the latest Org.

I apologize for not providing a sequence of reproduction steps.

Upon further investigation, Org frequently starts and kills the
spellchecker when the document contains `LocalWords' comments.

1. Start Emacs

   emacs -Q

2. Configure Flyspell

   (add-hook 'text-mode-hook #'flyspell-mode)
   (add-hook 'prog-mode-hook #'flyspell-prog-mode)

3. Create a new Org file

   # LocalWords: xyz
   
   Hello there!

4. Export the file to HTML

Expected:

  No Ispell process started on export.

Actual:

  A new Ispell process started on export.

P.S. I also see Org starting Ispell over and over when holding down
`C-v' in a long document that contains lots of scattered `LocalWords'
comments.

Rudy
-- 
"The whole science is nothing more than a refinement of everyday
thinking."
-- Albert Einstein, 1879-1955

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



  1   2   3   >