Re: inconsistency links and code line labels

2023-07-06 Thread gerard . vermeulen




On 06.07.2023 14:49, Dan Drake wrote:


There's a bug [[(my-code-line-label)][right here]].

This seems inconsistent. Why do I have to omit the ref: bit? This
always confuses me; it seems like it would be simpler to just make the
label and the links to that line of code be exactly the same. I don't
see any particular reference to this in the org manual
(https://orgmode.org/manual/Internal-Links.html [2]). Any insights?

My idea would be to get rid of the special behavior for code line
labels and just make this work with dedicated targets: in regular
parts of my org file, I use <> and can make links to
that. It would be simple and consistent to make that also work the
same when <> is inside a code block.


Such link targets would conflict with <> references
See: https://orgmode.org/manual/Noweb-Reference-Syntax.html

Therefore something like the behavior described in
https://orgmode.org/manual/Literal-Examples.html
must have been invented (look at the description of the -n, -r, and
-l switches).

Regards -- Gerard



Re: [PATCH] Several typo fixes

2023-07-06 Thread Ihor Radchenko
Shynur Xie  writes:

>> Ihor> the patch does not apply onto the latest WORG master:
>
> Sorry for that; I’m new to Org and don’t know WORG before.
>
> The PATCH I wrote is for the repository cloned fron
> .

Oh, that's my fault.
I somehow thought that the patch is for several pages in
https://orgmode.org/worg/, which is a different report.

I now applied your patch in the main Org mode repository.
Thanks!

Applied, onto main, adding TINYCHANGE cookie to the commit message (see 
https://orgmode.org/worg/org-contribute.html#first-patch).
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=501be358b

You are now listed as an Org contributor.
https://git.sr.ht/~bzg/worg/commit/afcb41dd

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



Re: [PATCH] Several typo fixes

2023-07-06 Thread Shynur Xie
> Ihor> the patch does not apply onto the latest WORG master:

Sorry for that; I’m new to Org and don’t know WORG before.

The PATCH I wrote is for the repository cloned fron
.


inconsistency links and code line labels

2023-07-06 Thread Dan Drake
Hello -- I'm wondering about my question from here:

https://emacs.stackexchange.com/questions/77768/why-the-inconsistency-with-org-mode-code-line-labels-and-links

Copying my question: in a source code special block, I can add code line
labels, which have ref: in the label -- but when I make a link there, I
have to omit the ref:. For example:

#+begin_src csharp
1044 string foo = someFunction(1234);
1045 if (foo == "1")
1046 {
1047 bar = 5; //  (ref:my-code-line-label)
1048 }
// etc etc
#+end_src

There's a bug [[(my-code-line-label)][right here]].

This seems inconsistent. Why do I have to omit the ref: bit? This always
confuses me; it seems like it would be simpler to just make the label and
the links to that line of code be exactly the same. I don't see any
particular reference to this in the org manual (
https://orgmode.org/manual/Internal-Links.html). Any insights?

My idea would be to get rid of the special behavior for code line labels
and just make this work with dedicated targets: in regular parts of my org
file, I use <> and can make links to that. It would be simple
and consistent to make that also work the same when <> is
inside a code block.

Thanks!

-- 
Ceci n'est pas une .signature.


Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)]

2023-07-06 Thread Sébastien Miquel


Ihor Radchenko writes:

May you now rebase the patch onto the latest main, add a Link: to this
discussion to the commit message, and apply the attached extra comments?


Here it is. Thanks for helping with this.

--
Sébastien MiquelFrom 7906d7b7fa2d376e95156ab7177494f2cececaff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= 
Date: Tue, 27 Jun 2023 09:23:01 +0200
Subject: [PATCH] org-src.el: Use native value of `indent-tabs-mode' for
 indentation

* lisp/org.el (org-indent-line): Simplify native indentation inside
src block.  Ensure we add the org indentation if the line is empty.
* lisp/org-macs.el (org-do-remove-indentation): Preserve
indentation (spaces vs tabs) past the common indentation to remove.
Do not empty blank lines.
* lisp/org-src.el (org-src--contents-for-write-back): Preserve the
native indentation (spaces vs tabs).  If necessary, add a common org
indentation to the block according to org's `indent-tabs-mode'.
(org-src-font-lock-fontify-block): Display the native indentation tab
characters with a fixed width, according to the native tab width
value, to preserve vertical alignement in the org buffer.
* testing/lisp/test-org-src.el (test-org-src/indented-blocks): Update
tests.  Indentation no longer obeys `indent-tabs-mode' from the org
buffer, but is separated in an eventual org part, and the native part.

Link: https://list.orgmode.org/87a5wcez7e.fsf@localhost/T/#t
---
 lisp/org-macs.el |  9 +++--
 lisp/org-src.el  | 57 ---
 lisp/org.el  | 23 ---
 testing/lisp/test-org-src.el | 75 ++--
 4 files changed, 94 insertions(+), 70 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index d6879e8cf..aa5c4845e 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -402,9 +402,12 @@ line.  Return nil if it fails."
 (when skip-fl (forward-line))
 	(while (not (eobp))
 	  (let ((ind (progn (skip-chars-forward " \t") (current-column
-	(cond ((eolp) (delete-region (line-beginning-position) (point)))
-		  ((< ind n) (throw :exit nil))
-		  (t (indent-line-to (- ind n
+	(cond ((< ind n)
+   (if (eolp) (delete-region (line-beginning-position) (point))
+ (throw :exit nil)))
+		  (t (delete-region (line-beginning-position)
+(progn (move-to-column n t)
+   (point)
 	(forward-line)))
 	;; Signal success.
 	t
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 317682844..e1f7d50dc 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -326,9 +326,6 @@ is 0.")
   "File name associated to Org source buffer, or nil.")
 (put 'org-src-source-file-name 'permanent-local t)
 
-(defvar-local org-src--preserve-blank-line nil)
-(put 'org-src--preserve-blank-line 'permanent-local t)
-
 (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 ]*\"."
@@ -481,12 +478,17 @@ Assume point is in the corresponding edit buffer."
  (list (buffer-substring (point-min) eol)
(buffer-substring eol (point-max))
 	(write-back org-src--allow-write-back)
-(preserve-blank-line org-src--preserve-blank-line)
-marker)
+marker indent-str)
+;; Compute the exact sequence of tabs and spaces used to indent up
+;; to `indentation-offset' in the Org buffer.
+(setq indent-str
+  (with-temp-buffer
+;; Reproduce indentation parameters from org buffer.
+(setq indent-tabs-mode use-tabs?)
+(when (> source-tab-width 0) (setq tab-width source-tab-width))
+(indent-to indentation-offset)
+(buffer-string)))
 (with-current-buffer write-back-buf
-  ;; Reproduce indentation parameters from source buffer.
-  (setq indent-tabs-mode use-tabs?)
-  (when (> source-tab-width 0) (setq tab-width source-tab-width))
   ;; Apply WRITE-BACK function on edit buffer contents.
   (insert (org-no-properties (car contents)))
   (setq marker (point-marker))
@@ -496,15 +498,14 @@ Assume point is in the corresponding edit buffer."
   ;; Add INDENTATION-OFFSET to every line in buffer,
   ;; unless indentation is meant to be preserved.
   (when (> indentation-offset 0)
-	(when preserve-fl (forward-line))
+;; LaTeX-fragments are inline. Do not add indentation to their
+;; first line.
+(when preserve-fl (forward-line))
 (while (not (eobp))
-	  (skip-chars-forward " \t")
-  (when (or (not (eolp))   ; not a blank line
-(and (eq (point) (marker-position marker)) ; current line
- preserve-blank-line))
-	(let ((i (current-column)))
-	  (delete-region (line-beginning-position) (point))
-	  (ind

Re: [PATCH] Several typo fixes

2023-07-06 Thread Ihor Radchenko
Shynur Xie  writes:

> From 34d8d8a4a532eea67e485347a690781674ee3f09 Mon Sep 17 00:00:00 2001
> From: Shynur 
> Date: Wed, 5 Jul 2023 22:23:44 +0800
> Subject: [PATCH] Several typo fixes

Thanks, but the patch does not apply onto the latest WORG master:

128 git … am --3way -- /tmp/0001-Several-typo-fixes.patch
Applying: Several typo fixes
error: sha1 information is lacking or useless (CONTRIBUTE.org).
error: could not build fake ancestor
Patch failed at 0001 Several typo fixes
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

May you please rebase the patch onto the latest master?

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



Re: [BUG] org-indent-mode breaks indentation in source blocks

2023-07-06 Thread Ihor Radchenko
Vladyslav Zapolskyi  writes:

> For example(written as it looks):
> (abababa abab :abab abab
>   "abab")
> #+end_src
> * aba
> ...
> When copying and pasting the indent is right for every level of indent,
> not only first and 4th(i am guessing every 4th?)

Looks similar to what we are trying to solve in
https://list.orgmode.org/orgmode/ZIZLzousCaylbUz1@ws/

I will take a closer look after installing the patch we are discussing there.

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



Re: [PATCH] Fix Emacs-26 compatibility (was: Re: [BUG] org-element loading fails with "regexp" argument not "stringp")

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

> On 05/07/2023 17:35, Ihor Radchenko wrote:
>> However, you will see many more failures with Emacs 26 on the latest
>> main.
>
> With the couple of attached patches the only failing test is
>
> ...
> Test test-org/delete-indentation condition:
>  (wrong-number-of-arguments
>   (0 . 1)
>   3)
> FAILED   935/1069  test-org/delete-indentation

Yup, it is because `org-delete-indentation' now uses 3 arguments when
calling `delete-indentation', while in Emacs 26 `delete-indentation'
only accepted up to 1.

And there are many warnings of which I have clue about the origin.
Except `string-search' undefined, which is not yet available in Emacs 26.

> From 2f2d330e90b10a86aa6b3b9ff279bc012b339396 Mon Sep 17 00:00:00 2001
> From: Max Nikulin 
> Date: Wed, 5 Jul 2023 22:50:44 +0700
> Subject: [PATCH 2/2] org-compat.el: Define `flatten-tree' for Emacs-26
>  compatibility
>
> * lisp/org-compat.el (flatten-tree): New compatibility function
> earlier used as `org-protocol-flatten'.
> * lisp/org-protocol.el (org-protocol-flatten): Remove the definition
> of the function.
> (org-protocol-flatten-greedy): Use `flatten-tree' instead of
> `org-protocol-flatten'.

You are removing `org-protocol-flatten' function, which is a breaking
change. We should leave an obsolete alias.

Also, you are defining `flatten-tree' function, which is outside Org's
namespace. We should better avoid it and use something like
`org-flatten-tree'.

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



Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-06 Thread Liu Hui
Jack Kamm  于2023年7月6日周四 11:49写道:

> I would propose the following instead: for ":results output graphics",
> ob-python should plot the gcf, and clear it beforehand. But for
> ":results value graphics", the ob-python block should return a
> matplotlib Figure object to plot, which would allow keeping and
> modifying a Figure between blocks.
>
> I actually proposed that behavior before in this patch:
>
> https://list.orgmode.org/87eenpfe77@gmail.com/
>
> But never wound up applying it -- the patch was rather large, with a lot
> of extra features, and I wasn't sure they were all worth the extra
> complexity.  Then life got in the way, and I never got around to
> revisiting ob-python plotting, until now.

I think your proposal about ":results graphics" is more flexible and
complies the documentation. Since the patch has no real problem and
the feature is useful indeed, I hope it can be merged instead of mine
after the problem of documentation is resolved.

As for other features in the patch, maybe it is better to convert
dict/dataframe/array to table/list only when the result type is
explicitly set to table or list?



[PATCH] Several typo fixes

2023-07-06 Thread Shynur Xie


0001-Several-typo-fixes.patch
Description: 0001-Several-typo-fixes.patch