Re: [BUG] SPACE jumps to tag in header line after hidden emphasis marker [9.7-pre (release_9.6.7-562-g5b6268 @ /home/jschmidt/work/org-mode/lisp/)]

2023-07-18 Thread Ihor Radchenko
Jens Schmidt  writes:

>> Fixed, on main.
>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3e3b873d3
>
> Well, I have one not-so-minor nit here: With that commit you cannot 
> insert text *before* some text having hidden emphasis without breaking 
> the emphasis.  More concretely (in an empty org-mode buffer):
>
> ...
>   C-;; left-word
>   C-;; left-word
>   SPC  ;; org-self-insert-command
>
> The last SPC breaks the emphasis around the middle "test", which it did 
> not previously.  Previously, the SPC would just move the whole 
> emphasized word one space to the right.  Which I somehow got used to, 
> and probably many others as well.

OMG. What we had in the past is because of an obscure internal,
undocumented implementation detail of how Emacs adjusts point when it
ends up inside invisible region:

  /* If the preceding character is both intangible and invisible,
 and the invisible property is `rear-sticky', perturb it so
 that the search starts one character earlier -- this ensures
 that point can never move to the end of an invisible/
 intangible/rear-sticky region.  */

Except that we do not have intanglible property there and the code below
that comment does not always check for intanglible property.

> OTOH, to fix my bug, only the first of the new `org-rear-nonsticky-at' 
> calls is actually needed.  So probably we could have something like the 
> following to get my bug fixed without any changes in behavior (diff on 
> top of main, that is, in addition to your commit):

I am not sure if it is a proper fix. The basic problem is that Org's
syntax table does not declare emphasis markup as part of a word.

I need to consult Emacs devs about rules of point adjustment.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[PATCH] lisp/org-table.el: Allow named columns on lhs

2023-07-18 Thread Gavin Downard
This patch does prioritize named columns over named fields, which can
break compatibility in tables with a named column and named field with
the same name. Alternatively, we could prioritize named fields to
preserve compatibility, but since named columns are prioritized on the
rhs, it could be pretty confusing.

>From c6ebbf02e0cb89839606338e8bbc4032810ea398 Mon Sep 17 00:00:00 2001
From: Gavin Downard 
Date: Sat, 1 Jul 2023 13:26:46 -0700
Subject: [PATCH] lisp/org-table.el: Allow named columns on lhs

* lisp/org-table.el (org-table-recalculate): Add support for named
columns on the lhs of spreadsheet formulas, prioritizing named columns
over named fields if there is a conflict.
(org-table-edit-formulas): Modify category name to include column
formulas with field formulas.
(org-table-get-stored-formulas): Remove comment mentioning lack of named
columns in the lhs.
* testing/lisp/test-org-table.el (test-org-table/named-column): Add test
case for named columns.
* etc/ORG-NEWS (Spreadsheets now support named columns on the lhs):
Document the change

This change breaks compatibility in tables with a named field and named
column with the same name, when that name is used on the lhs of a formula.
---
 etc/ORG-NEWS   | 4 
 lisp/org-table.el  | 9 +
 testing/lisp/test-org-table.el | 9 +
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a4725ae8c..42f39fd45 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -534,6 +534,10 @@ special repeaters ~++~ and ~.+~ are skipped.
 A capture template can target ~(here)~ which is the equivalent of
 invoking a capture template with a zero prefix.
 
+*** Spreadsheets now support named columns on the lhs
+
+Spreadsheet formulas can now use named column references on the lhs.
+
 ** New functions and changes in function arguments
 *** =TYPES= argument in ~org-element-lineage~ can now be a symbol
 
diff --git a/lisp/org-table.el b/lisp/org-table.el
index c5efe8f0c..34b0a562e 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -2253,8 +2253,7 @@ LOCATION is a buffer position, consider the formulas there."
 			((not (match-end 2)) m)
 			;; Is it a column reference?
 			((string-match-p "\\`\\$\\([0-9]+\\|[<>]+\\)\\'" m) m)
-			;; Since named columns are not possible in
-			;; LHS, assume this is a named field.
+			;; This is either a named field or column.
 			(t (match-string 2 string)
 		(rhs (match-string 3 string)))
 		(push (cons lhs rhs) eq-alist)
@@ -2963,7 +2962,9 @@ existing formula for column %s"
 		  (t old-lhs)
 	  (if (string-match-p "\\`\\$[0-9]+\\'" lhs)
 		  (push (cons lhs rhs) eqlcol)
-		(push (cons lhs rhs) eqlfield
+(if-let ((named-column (assoc lhs org-table-column-names)))
+(push (cons (concat "$" (cdr named-column)) rhs) eqlcol)
+  (push (cons lhs rhs) eqlfield)
 	  (setq eqlcol (nreverse eqlcol))
 	  ;; Expand ranges in lhs of formulas
 	  (setq eqlfield (org-table-expand-lhs-ranges (nreverse eqlfield)))
@@ -3355,7 +3356,7 @@ Parameters get priority."
 	  (sel-win (selected-window))
 	  (titles '((column . "# Column Formulas\n")
 		(field . "# Field and Range Formulas\n")
-		(named . "# Named Field Formulas\n"
+		(named . "# Named Field and Named Column Formulas\n"
   (org-switch-to-buffer-other-window "*Edit Formulas*")
   (erase-buffer)
   ;; Keep global-font-lock-mode from turning on font-lock-mode
diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el
index 27aeb5ab3..8cd01049a 100644
--- a/testing/lisp/test-org-table.el
+++ b/testing/lisp/test-org-table.el
@@ -2158,6 +2158,15 @@ See also `test-org-table/copy-field'."
 | ! | name |   |
 |   |1 |   |
 #+TBLFM: @2$3=$name"
+  (org-table-calc-current-TBLFM)
+  (buffer-string
+  (should
+   (string-match-p
+"| +# +| +1 +| +1 +|"
+(org-test-with-temp-text "
+| ! | lhs | rhs |
+| # | |   1 |
+#+TBLFM: $lhs=$rhs"
   (org-table-calc-current-TBLFM)
   (buffer-string)
 
-- 
2.40.1



Re: [BUG] SPACE jumps to tag in header line after hidden emphasis marker [9.7-pre (release_9.6.7-562-g5b6268 @ /home/jschmidt/work/org-mode/lisp/)]

2023-07-18 Thread Jens Schmidt
[Resent with correct identity to make this visible on the list as well - 
sorry for the hassle.]


On 2023-07-18  10:13, Ihor Radchenko wrote:


Confirmed.


Thanks for caring about this so quickly ...


https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64696


... and for the discussion with Eli & co.  Which I did not try to follow 
TBH.



Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3e3b873d3


Well, I have one not-so-minor nit here: With that commit you cannot 
insert text *before* some text having hidden emphasis without breaking 
the emphasis.  More concretely (in an empty org-mode buffer):


 t   ;; org-self-insert-command
 e   ;; org-self-insert-command
 s   ;; org-self-insert-command
 t   ;; org-self-insert-command
 SPC ;; org-self-insert-command
 =   ;; org-self-insert-command
 t   ;; org-self-insert-command
 e   ;; org-self-insert-command
 s   ;; org-self-insert-command
 t   ;; org-self-insert-command
 =   ;; org-self-insert-command
 SPC ;; org-self-insert-command
 t   ;; org-self-insert-command
 e   ;; org-self-insert-command
 s   ;; org-self-insert-command
 t   ;; org-self-insert-command
 C-;; left-word
 C-;; left-word
 SPC ;; org-self-insert-command

The last SPC breaks the emphasis around the middle "test", which it did 
not previously.  Previously, the SPC would just move the whole 
emphasized word one space to the right.  Which I somehow got used to, 
and probably many others as well.


OTOH, to fix my bug, only the first of the new `org-rear-nonsticky-at' 
calls is actually needed.  So probably we could have something like the 
following to get my bug fixed without any changes in behavior (diff on 
top of main, that is, in addition to your commit):


diff --git a/lisp/org.el b/lisp/org.el
index 0d8b5386c..71f482f64 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5153,8 +5153,7 @@ stacked delimiters is N.  Escaping delimiters is 
not possible."
 ;; 
https://orgmode.org/list/8b691a7f-6b62-d573-e5a8-80fac3dc9...@vodafonemail.de

 (org-rear-nonsticky-at (match-beginning 5))
(add-text-properties (match-beginning 3) (match-end 3)
-'(invisible t))
-(org-rear-nonsticky-at (match-end 3)))
+'(invisible t)))
  (throw :exit t

 (defun org-emphasize ( char)




[PATCH] Testing: Ensure 'org-id-locations-file' is set before updating

2023-07-18 Thread Morgan Smith
Previously, when trying to run the tests in a container limited to the
org repository, it fails because it can't create the directory
"~/.emacs.d/.org-id-locations".

* testing/org-test.el (org-test-load): Move setting
'org-id-locations-file' from here ...
org-test-update-id-locations: ... to here
---

Hello!  This fix allows me to run the tests without giving it access to the
filesystem outside of the repository.  I have no clue what org-id-locations are
and I'm hoping someone else does so I don't have to learn.  I'm not sure if
this is the best fix, but it works.

 testing/org-test.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testing/org-test.el b/testing/org-test.el
index 47687b9f7..3f086f30c 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -387,8 +387,6 @@ Tramp related features.  We mostly follow
 (defun org-test-load ()
   "Load up the Org test suite."
   (interactive)
-  (setq org-id-locations-file
-(expand-file-name ".test-org-id-locations" org-test-dir))
   (cl-flet ((rld (base)
 ;; Recursively load all files, if files throw errors
 ;; then silently ignore the error and continue to the
@@ -447,6 +445,8 @@ Tramp related features.  We mostly follow
   (when (buffer-live-p b) (kill-buffer b)
 
 (defun org-test-update-id-locations ()
+  (setq org-id-locations-file
+(expand-file-name ".test-org-id-locations" org-test-dir))
   (org-id-update-id-locations
(directory-files
 org-test-example-dir 'full
-- 
2.41.0




Re: Org markup and non-ASCII punctuation (was: org parser and priorities of inline elements)

2023-07-18 Thread Ihor Radchenko
Tom Gillespie  writes:

>> We might probably generalize to
>> PRE  = Zs Zl Pc Pd Ps Pi ' "
>> POST = Zs Zl Pc Pd Pe Pf . ; : ! ? ' " \ [
>
> If this works I think it is reasonable. We might want to
> specify what to do in cases where an org implementation
> might not fully support unicode,

Just fall back to ASCII subset? If the implementation does not support
unicode, it probably cannot properly work with UTF-encoded documents
anyway.

> ...and might want to do a
> review of related issues in syntax with respect to ascii
> vs unicode, because iirc there is some ambiguity in
> the current syntax doc.
> For example, I'm pretty sure that I'm mixing and matching
> unicode and ascii whitespace in the tokenizer I have in Racket.

Feel free to open new bug reports about such ambiguities.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] WORG example for ob-lilypond is no longer working as described (was: Moving some lisp/ob-*.el files to org-contrib - your advice?)

2023-07-18 Thread Ihor Radchenko
Jonathan Gregory  writes:

>> I also checked what will happen with future versions, and it 
>> looks like \version "2.24.1" actually means >=.
>
> That's good to know.
>
> I know version 2.20.0 works without the update, so perhaps we 
> could set those variables conditionally, WDYT?
>
> \version "2.20"
> #(if (ly:get-option 'use-paper-size-for-page)
>  (begin (ly:set-option 'use-paper-size-for-page #f)
> (ly:set-option 'tall-page-formats 'pdf)))

I do not mind.
But remember that we are talking just about an example file.
What you are suggesting appears to be closer to what we might do in
ob-lilypond itself, when calculating default layout.

Side note: ob-lilypond even has `org-babel-lilypond-toggle-midi-play'
that plays sound corresponding to the lilypond source. Pretty cool,
especially in the context of the discussion about non-textual output
types in babel. https://list.orgmode.org/orgmode/87ttu95xst.fsf@localhost/

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Testing: Add tests for 'org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item'

2023-07-18 Thread Ihor Radchenko
Morgan Smith  writes:

> * testing/lisp/test-org-agenda.el
> (test-org-agenda/check-for-timestamp-as-reason-to-ignore-todo-item):
> New test.

Thanks for the patch, but I am not sure if what we want to test is this
function.

`org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item' is
semi-internal function, which is simply serving to group some common
skip tests together.

It will be more reliable to test the final agenda behaviour - what is
display in the actual agenda view and what not.
Basically, instead of testing the return value of
`org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item', test
using `org-test-agenda-with-agenda' and check the agenda buffer
contents.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Dates in headlines

2023-07-18 Thread Ihor Radchenko
Max Nikulin  writes:

> A patch for `org-store-link' tests reminded me about this topic. The 
> footnote on dates in heading title was added in response to
>
> Links to datestamped headings broken? Thu, 24 Feb 2011 16:49:14 +1300
> https://list.orgmode.org/86pqqi9jnp.wl%25sgu...@bayfield-high.school.nz/T/#u
>
> 3765304c8 2011-06-28 15:30:50 +0200 Bastien Guerry: doc/org.texi: 
> footnote: don't put timestamps in headlines.
>
> however removing of timestamps was dropped during migration to org-element:

I have removed this footnote in 5adde9f3f.
Are you saying that there are still some bugs related to this topic?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] Error in data input and output format for org-columns--summary-estimate

2023-07-18 Thread Ihor Radchenko
and...@fedeli.eu writes:

>> About possibile abuses, org documentation, to date, clearly tells
>> org estimate utilizes times.
>
>> May you please elaborate?

> AF: Sure! Clause 8.5 of current
>(2023.Jul.14) org documentation,
>https://orgmode.org/manual/Effort-Estimates.html, refers to effort
>estimates giving examples that are all appearing to fall in time
>domain.

I see what you mean.
However, est+ column summary does not have to be applied to EFFORT
columns.

One can, for example, use %SCORE{est+} column specification to summarize
values stored in SCORE property. Org has no right to demand SCORE to be
in time units and only time units.

>> Similarly, I'd not spend too much code to check the format; i
>> understand the intent to preserve backward compatibility, bit if
>> that format adaptation mistake slipped forward to these days I
>> doubt that nice feature was used much so far...
>
>Yes, but it is easy to have a fallback, so why not.

>Because this way you persist in allowing a mistaken usage of that
>function. A number is a number but a duration is NOT just a number,
>and having something like (just for example) 10kg-0.5ton be taken
>as 10-0.5 is in my opinion NOT helpful to any user.

We may provide a linter (for M-x org-lint) that will ensure EFFORT
estimates to be in understandable format.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [ANN] lisp/ob-tangle-sync.el

2023-07-18 Thread Ihor Radchenko
Mehmet Tekman  writes:

>> ... I will rewrite to to conform to the
>> `org-test-with-temp-text' examples.
>
> So I've just rewritten the `merge-params' testing function I
> wrote before, this time using the `org-test-with-temp-text'
> method/macro.

Side note: You are re-implementing the already available ERT features
for failed test reporting. Instead of controlling which tests failed
manually, you should better follow the example of all other tests and
simply use a sequence of `should'/`should-not' forms.

If you did that, ERT would by itself report which tests fail and why.

> I seem to be getting 5 failing tests for reasons that I'm not
> quite sure why. I've tested it against upstream/main, but still
> getting the same errors. Maybe you can try it and see where I'm
> going wrong?

I am getting the following failures:

6 Failed Blocks: (tangle-file-with-spaces 
override-document-and-heading-tfile-with-yes 
ignore-document-header-take-last-tfile-and-sync-action 
inherit-document-tfile-take-only-last-local-sync-action 
inherit-document-header-with-local-sync-action inherit-document-header-args)

> +  (let ((idtest-alist '((inherit-document-header-args
> + :tangle "\
> +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
> +* One
> +#+begin_src conf
> +  (:tangle . /tmp/default_tangle.txt)
> +#+end_src")

This is failing because of subtlety in `org-test-with-temp-text' that
inserts text after activating org-mode.
PROPERTY lines are only computed when org-mode is activated, unless you
explicitly call `org-set-regexps-and-options' to refresh them.

Your code does not refresh those and PROPERTY line is not being handled
by Org.

Same story for other tests with PROPERTY.

> +(tangle-file-with-spaces
> + :tangle "\
> +* One
> +:PROPERTIES:
> +:header-args: :tangle \"foo.txt\"
> +:END:
> +** Two
> +#+begin_src :tangle \"file with spaces.txt\"
> +   (:tangle . \"file with spaces.txt\")
> +#+end_src")))

This fails because you did not provide LANG for source block.
override-document-and-heading-tfile-with-yes test is also missing LANG.

P.S. There going to be Emacs meetup this Saturday, July 22
(https://emacs-apac.gitlab.io/announcements/july-2023/). I plan to be
there and, if you need it, we can try to resolve difficulties in more
interactive way.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: org-fontify-emphasized-text

2023-07-18 Thread Ihor Radchenko
Henrik Frisk  writes:

>> Can't get rid even after re-starting Emacs?
>>
>
> Exactly, I've had it for weeks annoyingly.

So, it is something in your config.
Did you try bisecting?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] SPACE jumps to tag in header line after hidden emphasis marker [9.7-pre (release_9.6.7-562-g5b6268 @ /home/jschmidt/work/org-mode/lisp/)]

2023-07-18 Thread Ihor Radchenko
Jens Schmidt  writes:

> [emacs-29]$ ./src/emacs -Q -L ~jschmidt/work/org-mode/lisp/
>
> (org-version nil t)
> "Org mode version 9.7-pre (release_9.6.7-562-g5b6268 @ 
> /home/jschmidt/work/org-mode/lisp/)"
>
> (setq org-hide-emphasis-markers t)
> t
>
> ...
> The final SPC after the closing equal sign lets point jump to before the 
> colon of the ":test:" tag.

Confirmed.

> Most likely, this is not limited to space, but that is just the 
> character I most frequently type after closing emphasis.

No, it is space. In particular, it is `org--align-tags-here' + some bug
in Emacs that screws up column computation.

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64696

Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3e3b873d3

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at