emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* link can not be created in a line with another link.
@ 2024-04-28  6:33 Alexandros Prekates
  2024-04-28 12:40 ` Ihor Radchenko
  0 siblings, 1 reply; 12+ messages in thread
From: Alexandros Prekates @ 2024-04-28  6:33 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


Emacs  : GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.37, cairo version 1.16.0) of 2023-09-11, modified by Debian
Package: Org mode version 9.6.6 (release_9.6.6 @
/usr/share/emacs/29.1/lisp/org/)


In  the example below i  underline to show that a link has been created.

Given that lines :

 [[sysadmInstallSoftware a [[deb][deb package]]
 [[sysadmInstallSoftware a    deb package 
                              -----------
 If i try to complete the left link with:
 [[sysadmInstallSoftware][Install]]
                        /\
                        |
                     the moment i insert that left bracket i will get:
                 a [[deb][deb package
                 --------------------

If i try that into a line with no other links it will work ok.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: link can not be created in a line with another link.
  2024-04-28  6:33 link can not be created in a line with another link Alexandros Prekates
@ 2024-04-28 12:40 ` Ihor Radchenko
  2024-04-29 12:45   ` Alexandros Prekates
  0 siblings, 1 reply; 12+ messages in thread
From: Ihor Radchenko @ 2024-04-28 12:40 UTC (permalink / raw)
  To: Alexandros Prekates; +Cc: emacs-orgmode@gnu.org

Alexandros Prekates <aprekates@posteo.net> writes:

> In  the example below i  underline to show that a link has been created.
>
> Given that lines :
>
>  [[sysadmInstallSoftware a [[deb][deb package]]
>  [[sysadmInstallSoftware a    deb package 
>                               -----------
>  If i try to complete the left link with:
>  [[sysadmInstallSoftware][Install]]
>                         /\
>                         |
>                      the moment i insert that left bracket i will get:
>                  a [[deb][deb package
>                  --------------------
>
> If i try that into a line with no other links it will work ok.

Thanks for reporting, but I do not fully understand what you did.
May you please explain step by step, starting from emacs -Q, what you
did, what you saw, and what you expected to see?

Please list what exactly you input into the buffer, and which
keys/commands you use.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: link can not be created in a line with another link.
  2024-04-28 12:40 ` Ihor Radchenko
@ 2024-04-29 12:45   ` Alexandros Prekates
  2024-04-29 13:19     ` Ihor Radchenko
  2024-05-01 10:59     ` Max Nikulin
  0 siblings, 2 replies; 12+ messages in thread
From: Alexandros Prekates @ 2024-04-29 12:45 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode@gnu.org

On Sun, 28 Apr 2024 12:40:44 +0000
Ihor Radchenko <yantar92@posteo.net> wrote:

> Alexandros Prekates <aprekates@posteo.net> writes:
> 
> > In  the example below i  underline to show that a link has been
> > created.
> >
> > Given that lines :
> >
> >  [[sysadmInstallSoftware a [[deb][deb package]]
> >  [[sysadmInstallSoftware a    deb package 
> >                               -----------
> >  If i try to complete the left link with:
> >  [[sysadmInstallSoftware][Install]]
> >                         /\
> >                         |
> >                      the moment i insert that left bracket i will
> > get: a [[deb][deb package
> >                  --------------------
> >
> > If i try that into a line with no other links it will work ok.
> 
> Thanks for reporting, but I do not fully understand what you did.
> May you please explain step by step, starting from emacs -Q, what you
> did, what you saw, and what you expected to see?
> 
> Please list what exactly you input into the buffer, and which
> keys/commands you use.
> 

The same behavior happens with emacs -Q.

Having <<foo>> and <<boo>> anchors somewhere in an org file
in a line a have an internal link :

bla [[foo]]

If i add :
[[boo]] bla [[foo]]  
org will create the two links.

But if i add:
[[boo][  bla [[foo]]
with the intention to type: [[boo][description]]  bla [[foo]]
then what i will get is: a link to boo with description : bla [[foo

Alexandros .


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: link can not be created in a line with another link.
  2024-04-29 12:45   ` Alexandros Prekates
@ 2024-04-29 13:19     ` Ihor Radchenko
  2024-04-29 22:33       ` Alexandros Prekates
  2024-05-01 20:08       ` Alexandros Prekates
  2024-05-01 10:59     ` Max Nikulin
  1 sibling, 2 replies; 12+ messages in thread
From: Ihor Radchenko @ 2024-04-29 13:19 UTC (permalink / raw)
  To: Alexandros Prekates; +Cc: emacs-orgmode@gnu.org

Alexandros Prekates <aprekates@posteo.net> writes:

> The same behavior happens with emacs -Q.
>
> Having <<foo>> and <<boo>> anchors somewhere in an org file
> in a line a have an internal link :
>
> bla [[foo]]
>
> If i add :
> [[boo]] bla [[foo]]  
> org will create the two links.
>
> But if i add:
> [[boo][  bla [[foo]]
> with the intention to type: [[boo][description]]  bla [[foo]]
> then what i will get is: a link to boo with description : bla [[foo

This is expected, as per Org mode's link syntax [[path][description]].

[[boo][  bla [[foo]]

is indeed a link with path "boo" and description spanning between [...]:
"  blah [[foo".

For you workflow, it may be more convenient to set
`org-link-descriptive' to nil. Then, Org mode will not hide the path
part of the links and you can edit the plain text as you wish without
being distracted by Org mode trying to detect the markup as you type.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: link can not be created in a line with another link.
  2024-04-29 13:19     ` Ihor Radchenko
@ 2024-04-29 22:33       ` Alexandros Prekates
  2024-05-01 20:08       ` Alexandros Prekates
  1 sibling, 0 replies; 12+ messages in thread
From: Alexandros Prekates @ 2024-04-29 22:33 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode@gnu.org

On Mon, 29 Apr 2024 13:19:15 +0000
Ihor Radchenko <yantar92@posteo.net> wrote:

> For you workflow, it may be more convenient to set
> `org-link-descriptive' to nil. Then, Org mode will not hide the path
> part of the links and you can edit the plain text as you wish without
> being distracted by Org mode trying to detect the markup as you type.
> 

If you mean :‘org-toggle-link-display’ or (setq org-descriptive-links
nil) that can indeed help to instert many links in the same line will
less headache . Thanks.

Alexandros


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: link can not be created in a line with another link.
  2024-04-29 12:45   ` Alexandros Prekates
  2024-04-29 13:19     ` Ihor Radchenko
@ 2024-05-01 10:59     ` Max Nikulin
  2024-05-01 16:36       ` Alexandros Prekates
  2024-05-02 11:15       ` Ihor Radchenko
  1 sibling, 2 replies; 12+ messages in thread
From: Max Nikulin @ 2024-05-01 10:59 UTC (permalink / raw)
  To: Alexandros Prekates; +Cc: emacs-orgmode@gnu.org

On 29/04/2024 19:45, Alexandros Prekates wrote:
> 
> The same behavior happens with emacs -Q.
> 
> bla [[foo]]
> 
> If i add :
> [[boo]] bla [[foo]]
> org will create the two links.
> 
> But if i add:
> [[boo][  bla [[foo]]
> with the intention to type: [[boo][description]]  bla [[foo]]
> then what i will get is: a link to boo with description : bla [[foo

This case you can keep calm and continue typing "description]]".

I have a more weird example. Consider you are going to get

- [[#foo]] and [[#bar]]

starting from

- <point>[[#bar]]

There is no problem till

- [[#foo<point>[[#bar]]

However in response to "]" point is moved after "["

- [[#foo][<point>[#bar]]

that is displayed as

- <point>[#bar

I do not see other ways than undo, SPC, and moving back. It would be 
great to keep point between brackets "]<point>[" this case. I have no 
idea if it is feasible to postpone hiding link target when such pattern 
is typed.

I have descriptive links enabled despite most of links in my notes are 
like [[#CUSTOM_ID]]. There are still some links with descriptions.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: link can not be created in a line with another link.
  2024-05-01 10:59     ` Max Nikulin
@ 2024-05-01 16:36       ` Alexandros Prekates
  2024-05-02 11:15       ` Ihor Radchenko
  1 sibling, 0 replies; 12+ messages in thread
From: Alexandros Prekates @ 2024-05-01 16:36 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode@gnu.org

On Wed, 1 May 2024 17:59:11 +0700
Max Nikulin <manikulin@gmail.com> wrote:

> On 29/04/2024 19:45, Alexandros Prekates wrote:
> > 
> > The same behavior happens with emacs -Q.
> > 
> > bla [[foo]]
> > 
> > If i add :
> > [[boo]] bla [[foo]]
> > org will create the two links.
> > 
> > But if i add:
> > [[boo][  bla [[foo]]
> > with the intention to type: [[boo][description]]  bla [[foo]]
> > then what i will get is: a link to boo with description : bla [[foo
> 
> This case you can keep calm and continue typing "description]]".
> 

Thanks for the tip! :-)






^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: link can not be created in a line with another link.
  2024-04-29 13:19     ` Ihor Radchenko
  2024-04-29 22:33       ` Alexandros Prekates
@ 2024-05-01 20:08       ` Alexandros Prekates
  2024-05-01 20:57         ` Ihor Radchenko
  1 sibling, 1 reply; 12+ messages in thread
From: Alexandros Prekates @ 2024-05-01 20:08 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode@gnu.org

On Mon, 29 Apr 2024 13:19:15 +0000
Ihor Radchenko <yantar92@posteo.net> wrote:

> Alexandros Prekates <aprekates@posteo.net> writes:
> 
> > The same behavior happens with emacs -Q.
> >
> > Having <<foo>> and <<boo>> anchors somewhere in an org file
> > in a line a have an internal link :
> >
> > bla [[foo]]
> >
> > If i add :
> > [[boo]] bla [[foo]]  
> > org will create the two links.
> >
> > But if i add:
> > [[boo][  bla [[foo]]
> > with the intention to type: [[boo][description]]  bla [[foo]]
> > then what i will get is: a link to boo with description : bla [[foo
> 
> This is expected, as per Org mode's link syntax [[path][description]].
> 
> [[boo][  bla [[foo]]
> 
> is indeed a link with path "boo" and description spanning between
> [...]: "  blah [[foo".
> 

I give a couple of examples that i think highligth some foggy semantics
of links.

In the example below . is the pointer and single quotes is for
recognized links and $ for the start of the line.

   $[[foo]].
   $'foo'.
   $.'foo'         // here while we could think that the pointer is
                   // before the link , if we type a char it will 
                   // be inserted into the link.
   $'xfoo'         // not x'foo'

Also what if we type :
   $and [[foo]].
   $and 'foo'.
   $.and 'foo'
   $[[goo. and 'foo' //Could not be seen as [[ goo and  [[foo ]]    ?
                     //                        'goo and [[foo'
                                             
                     // But that doesnt happens.
                     // Org sees it as :
   $[[goo.  and  'foo' 
   $[[goo]]  and 'foo'
   $'goo' and 'foo'
                      

Alexandros


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: link can not be created in a line with another link.
  2024-05-01 20:08       ` Alexandros Prekates
@ 2024-05-01 20:57         ` Ihor Radchenko
  0 siblings, 0 replies; 12+ messages in thread
From: Ihor Radchenko @ 2024-05-01 20:57 UTC (permalink / raw)
  To: Alexandros Prekates; +Cc: emacs-orgmode@gnu.org

Alexandros Prekates <aprekates@posteo.net> writes:

> I give a couple of examples that i think highligth some foggy semantics
> of links.
>
> In the example below . is the pointer and single quotes is for
> recognized links and $ for the start of the line.
>
>    $[[foo]].
>    $'foo'.
>    $.'foo'         // here while we could think that the pointer is
>                    // before the link , if we type a char it will 
>                    // be inserted into the link.
>    $'xfoo'         // not x'foo'

This is not about semantics. The point position when there is hidden
text is generally ambiguous. Emacs chooses to put point before or after
invisible text depending on the "direction" of the last command. See
22.6 Adjusting Point After Commands section of Elisp manual, if you want
to know the details. The scenario when invisible text is right at bol is
the most tricky. 

> Also what if we type :
>    $and [[foo]].
>    $and 'foo'.
>    $.and 'foo'
>    $[[goo. and 'foo' //Could not be seen as [[ goo and  [[foo ]]    ?
>                      //                        'goo and [[foo'
>                                              
>                      // But that doesnt happens.
>                      // Org sees it as :
>    $[[goo.  and  'foo' 
>    $[[goo]]  and 'foo'
>    $'goo' and 'foo'

Unescaped brackets are not allowed in the link path.
See 4.1 Link Format section of the manual

      [[LINK][DESCRIPTION]]
     
     or alternatively
     
          [[LINK]]
     
        Some ‘\’, ‘[’ and ‘]’ characters in the LINK part need to be
     “escaped”, i.e., preceded by another ‘\’ character.  More specifically,
     the following characters, and only them, must be escaped:
     
       1. all ‘[’ and ‘]’ characters,
       2. every ‘\’ character preceding either ‘]’ or ‘[’,
       3. every ‘\’ character at the end of the link.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: link can not be created in a line with another link.
  2024-05-01 10:59     ` Max Nikulin
  2024-05-01 16:36       ` Alexandros Prekates
@ 2024-05-02 11:15       ` Ihor Radchenko
  2024-05-03 10:39         ` Max Nikulin
  1 sibling, 1 reply; 12+ messages in thread
From: Ihor Radchenko @ 2024-05-02 11:15 UTC (permalink / raw)
  To: Max Nikulin; +Cc: Alexandros Prekates, emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 675 bytes --]

Max Nikulin <manikulin@gmail.com> writes:

> I have a more weird example. Consider you are going to get
>
> - [[#foo]] and [[#bar]]
>
> starting from
>
> - <point>[[#bar]]
>
> There is no problem till
>
> - [[#foo<point>[[#bar]]
>
> However in response to "]" point is moved after "["
>
> - [[#foo][<point>[#bar]]
>
> that is displayed as
>
> - <point>[#bar
>
> I do not see other ways than undo, SPC, and moving back. It would be 
> great to keep point between brackets "]<point>[" this case. I have no 
> idea if it is feasible to postpone hiding link target when such pattern 
> is typed.

May you try the attached patch (on top of the latest main)?
Does it feel better?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Honor-org-fold-catch-invisible-edits-when-editing-li.patch --]
[-- Type: text/x-patch, Size: 10601 bytes --]

From fce16d736a97943f2f2cde521806dd78ed97a9bc Mon Sep 17 00:00:00 2001
Message-ID: <fce16d736a97943f2f2cde521806dd78ed97a9bc.1714648357.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Thu, 2 May 2024 11:49:00 +0300
Subject: [PATCH] Honor `org-fold-catch-invisible-edits' when editing links

* lisp/org.el (org-activate-links): Mark links with 'org-link text
property.
* lisp/org-fold.el (org-fold-show-set-visibility): Reveal links at
point for 'local detail.
(org-fold-check-before-invisible-edit): When editing after links, do
not warn about inserting after invisible.
*
testing/lisp/test-org-fold.el (test-org-fold/org-catch-invisible-edits):
Update tests.
* lisp/org-fold-core.el (org-fold-core-region): Do not re-fontify
unnecessarily.
---
 lisp/org-fold-core.el         |  6 ++++--
 lisp/org-fold.el              | 37 +++++++++++++++++++--------------
 lisp/org.el                   |  1 +
 testing/lisp/test-org-fold.el | 39 +++++++++++++++++++++--------------
 4 files changed, 50 insertions(+), 33 deletions(-)

diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el
index 41b16851f..1b2e41cf5 100644
--- a/lisp/org-fold-core.el
+++ b/lisp/org-fold-core.el
@@ -1047,9 +1047,11 @@ (defun org-fold-core-region (from to flag &optional spec-or-alias)
        ;; past the ellipsis.  See bug#65896.  The face properties are
        ;; assigned via `org-activate-folds'.
        (when (or (not spec) (org-fold-core-get-folding-spec-property spec :font-lock))
-         (when (equal ?\n (char-after from))
+         (when (and (equal ?\n (char-after from))
+                    (or flag (org-fold-folded-p from)))
            (font-lock-flush from (1+ from)))
-         (when (equal ?\n (char-after to))
+         (when (and (equal ?\n (char-after to))
+                    (or flag (org-fold-folded-p to)))
            (font-lock-flush to (1+ to)))
          (dolist (region (org-fold-core-get-regions :from from :to to :specs spec))
            (when (equal ?\n (char-after (cadr region)))
diff --git a/lisp/org-fold.el b/lisp/org-fold.el
index 1b62168c4..2c11383ba 100644
--- a/lisp/org-fold.el
+++ b/lisp/org-fold.el
@@ -658,8 +658,6 @@ (defun org-fold-show-set-visibility (detail)
     (org-fold-show-entry)
     ;; If point is hidden make sure to expose it.
     (when (org-invisible-p)
-      ;; FIXME: No clue why, but otherwise the following might not work.
-      (redisplay)
       ;; Reveal emphasis markers.
       (when (eq detail 'local)
         (let (org-hide-emphasis-markers
@@ -668,6 +666,7 @@ (defun org-fold-show-set-visibility (detail)
               (org-hide-macro-markers nil)
               (region (or (org-find-text-property-region (point) 'org-emphasis)
                           (org-find-text-property-region (point) 'org-macro)
+                          (org-find-text-property-region (point) 'org-link)
                           (org-find-text-property-region (point) 'invisible))))
           ;; Silence byte-compiler.
           (ignore org-hide-macro-markers)
@@ -882,30 +881,34 @@ (defun org-fold-check-before-invisible-edit (kind)
   "Check if editing KIND is dangerous with invisible text around.
 The detailed reaction depends on the user option
 `org-fold-catch-invisible-edits'."
+  ;; When cursor is at a link that was revealed during previous edit,
+  ;; re-fold it, so that we refresh the fontification.
+  (font-lock-ensure (max (point-min) (1- (point))) (point))
   ;; First, try to get out of here as quickly as possible, to reduce overhead
   (when (and org-fold-catch-invisible-edits
 	     (or (not (boundp 'visible-mode)) (not visible-mode))
 	     (or (org-invisible-p)
 		 (org-invisible-p (max (point-min) (1- (point))))))
-    ;; OK, we need to take a closer look.  Only consider invisibility
-    ;; caused by folding of headlines, drawers, and blocks.  Edits
-    ;; inside links will be handled by font-lock.
-    (let* ((invisible-at-point (org-fold-folded-p (point) '(headline drawer block)))
+    ;; OK, we need to take a closer look.
+    (let* ((invisible-at-point (org-invisible-p (point)))
 	   (invisible-before-point
-	    (and (not (bobp))
-	         (org-fold-folded-p (1- (point)) '(headline drawer block))))
+	    (and (not (bobp)) (org-invisible-p (1- (point)))))
+           (folded-before-point
+	    (and (not (bobp)) (org-fold-folded-p (1- (point)))))
 	   (border-and-ok-direction
 	    (or
 	     ;; Check if we are acting predictably before invisible
 	     ;; text.
 	     (and invisible-at-point (not invisible-before-point)
 		  (memq kind '(insert delete-backward)))
-             ;; Check if we are acting predictably after invisible text
-             ;; This works not well, and I have turned it off.  It seems
-             ;; better to always show and stop after invisible text.
-             ;; (and (not invisible-at-point) invisible-before-point
-             ;;  (memq kind '(insert delete)))
-             )))
+             ;; Check if we are acting predictably after invisible
+             ;; text.  After the folds (which are usually multi-line,
+             ;; always raise a warning; after inline invisible text
+             ;; (links or hidden markup markers), allow editing
+             ;; forward.
+             (and (not invisible-at-point) invisible-before-point
+                  (not folded-before-point)
+                  (memq kind '(insert delete))))))
       (when (or invisible-at-point invisible-before-point)
 	(when (eq org-fold-catch-invisible-edits 'error)
 	  (user-error "Editing in invisible areas is prohibited, make them visible first"))
@@ -922,10 +925,12 @@ (defun org-fold-check-before-invisible-edit (kind)
 	    ;; That's it, we do the edit after showing
 	    (message
 	     "Unfolding invisible region around point before editing")
-	    (sit-for 1))
+	    (sit-for 0.2))
 	   ((and (eq org-fold-catch-invisible-edits 'smart)
 		 border-and-ok-direction)
-	    (message "Unfolding invisible region around point before editing"))
+	    (message "Unfolding invisible region around point before editing")
+            ;; Flash links before they get hidden back due to fontification after edit.
+            (sit-for 0.2))
 	   (t
 	    ;; Don't do the edit, make the user repeat it in full visibility
 	    (user-error "Edit in invisible region aborted, repeat to confirm with text visible"))))))))
diff --git a/lisp/org.el b/lisp/org.el
index ad4d1b9d3..809fd8ba3 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5351,6 +5351,7 @@ (defun org-activate-links (limit)
 								     :htmlize-link)
 					((and (pred functionp) f) (funcall f))
 					(_ `(:uri ,link)))
+                        'org-link t
 			'font-lock-multiline t)))
 	    (org-remove-flyspell-overlays-in start end)
 	    (org-rear-nonsticky-at end)
diff --git a/testing/lisp/test-org-fold.el b/testing/lisp/test-org-fold.el
index f58642be6..904bc6578 100644
--- a/testing/lisp/test-org-fold.el
+++ b/testing/lisp/test-org-fold.el
@@ -616,7 +616,8 @@ (ert-deftest test-org-fold/org-catch-invisible-edits ()
           (test-org-fold-with-default-template
             (dolist (txt '("Folded Paragraph inside heading"
                            "Folded Paragraph inside drawer"
-                           "Folded block"))
+                           "Folded block"
+                           "hiddenlink"))
               (search-forward txt)
               (message "Inside invisible %S" txt)
               (pcase org-fold-catch-invisible-edits
@@ -631,16 +632,13 @@ (ert-deftest test-org-fold/org-catch-invisible-edits ()
                  (should-not (org-invisible-p)))
                 (`error
                  (should-error (org-fold-check-before-invisible-edit kind))
-                 (should (org-invisible-p)))))
-            (search-forward "hiddenlink")
-            (message "Inside hidden link")
-            (org-fold-check-before-invisible-edit kind)
-            (should (org-invisible-p)))
+                 (should (org-invisible-p))))))
           ;; Edits at the left border.
           (test-org-fold-with-default-template
             (dolist (txt '("Folded heading"
                            ":FOLDED-DRAWER:"
-                           "#+begin_src emacs-lisp"))
+                           "#+begin_src emacs-lisp"
+                           "[link"))
               (search-forward txt)
               (message "Left of folded %S" txt)
               (pcase org-fold-catch-invisible-edits
@@ -660,12 +658,7 @@ (ert-deftest test-org-fold/org-catch-invisible-edits ()
                  (should-not (org-invisible-p (1+ (point)))))
                 (`error
                  (should-error (org-fold-check-before-invisible-edit kind))
-                 (should (org-invisible-p (1+ (point)))))))
-            (search-forward "hiddenlink")
-            (search-forward "lin")
-            (message "Left border of ]] in link")
-            (org-fold-check-before-invisible-edit kind)
-            (should (org-invisible-p (1+ (point)))))
+                 (should (org-invisible-p (1+ (point))))))))
           ;; Edits at the right border.
           (test-org-fold-with-default-template
             (dolist (txt '("Folded Paragraph inside heading."
@@ -689,8 +682,24 @@ (ert-deftest test-org-fold/org-catch-invisible-edits ()
             (search-forward "hiddenlink")
             (search-forward "link]]")
             (message "Right border of ]] in link")
-            (org-fold-check-before-invisible-edit kind)
-            (should (org-invisible-p (1- (point))))))))))
+            (pcase org-fold-catch-invisible-edits
+              (`nil
+               (org-fold-check-before-invisible-edit kind)
+               (should (org-invisible-p (1- (point)))))
+              (`show
+               (org-fold-check-before-invisible-edit kind)
+               (should-not (org-invisible-p (1- (point)))))
+              (`smart
+               (if (memq kind '(insert delete))
+                   (org-fold-check-before-invisible-edit kind)
+                 (should-error (org-fold-check-before-invisible-edit kind)))
+               (should-not (org-invisible-p (1- (point)))))
+              (`show-and-error
+               (should-error (org-fold-check-before-invisible-edit kind))
+               (should-not (org-invisible-p (1- (point)))))
+              (`error
+               (should-error (org-fold-check-before-invisible-edit kind))
+               (should (org-invisible-p (1- (point))))))))))))
 
 (ert-deftest test-org-fold/org-fold-display-inline-images ()
   "Test inline images displaying when cycling."
-- 
2.44.0


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: link can not be created in a line with another link.
  2024-05-02 11:15       ` Ihor Radchenko
@ 2024-05-03 10:39         ` Max Nikulin
  2024-05-03 13:32           ` Ihor Radchenko
  0 siblings, 1 reply; 12+ messages in thread
From: Max Nikulin @ 2024-05-03 10:39 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Alexandros Prekates

On 02/05/2024 18:15, Ihor Radchenko wrote:
> May you try the attached patch (on top of the latest main)?
> Does it feel better?

I see regressions only (Emacs 28).

[[#foo]]
[[#bar]]<point>

SPC causes permanent appearance of square brackets for [[#foo]].

I do not like flashes especially since they do not help to avoid issues 
with prepending a new link

- <point>[[#bar]]


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: link can not be created in a line with another link.
  2024-05-03 10:39         ` Max Nikulin
@ 2024-05-03 13:32           ` Ihor Radchenko
  0 siblings, 0 replies; 12+ messages in thread
From: Ihor Radchenko @ 2024-05-03 13:32 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode, Alexandros Prekates

Max Nikulin <manikulin@gmail.com> writes:

> On 02/05/2024 18:15, Ihor Radchenko wrote:
>> May you try the attached patch (on top of the latest main)?
>> Does it feel better?
>
> I see regressions only (Emacs 28).
>
> [[#foo]]
> [[#bar]]<point>
>
> SPC causes permanent appearance of square brackets for [[#foo]].

That's minor. I can fix this edge case.

> I do not like flashes especially since they do not help to avoid issues 
> with prepending a new link
>
> - <point>[[#bar]]

This is a more important problem.
But what would you consider better? Maybe something akin
https://github.com/awth13/org-appear, but for the whole line?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-05-03 13:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-28  6:33 link can not be created in a line with another link Alexandros Prekates
2024-04-28 12:40 ` Ihor Radchenko
2024-04-29 12:45   ` Alexandros Prekates
2024-04-29 13:19     ` Ihor Radchenko
2024-04-29 22:33       ` Alexandros Prekates
2024-05-01 20:08       ` Alexandros Prekates
2024-05-01 20:57         ` Ihor Radchenko
2024-05-01 10:59     ` Max Nikulin
2024-05-01 16:36       ` Alexandros Prekates
2024-05-02 11:15       ` Ihor Radchenko
2024-05-03 10:39         ` Max Nikulin
2024-05-03 13:32           ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).