emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug in org-insert-link?
@ 2023-09-27 15:29 Guillaume MULLER
  2023-10-05 10:18 ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Guillaume MULLER @ 2023-09-27 15:29 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


[-- Attachment #1.1.1: Type: text/plain, Size: 1077 bytes --]

Hi,

Here is a situation that I often end up in:

- Open a .org file
- Type some text
- Select it
- Call org-insert-link
- Switch to another windows/desktop to find my running firefox
- Copy a URL
- Switch back to (Doom)Emacs ("window"/desktop)
- Click inside the Emacs "window" to give it focus
[Here is the problem: sometimes I forgot that I already started the org-insert-link]
- Call org-insert-link
- Paste the URL
- Validate the link creation

Then the link is inserted where I clicked last (to give focus to the Emacs "window").

Of course, the problem lies in my mistake of calling twice the org-insert-link method, but the behavior is very strange, and it took me some time to identify why my links were inserted at random places in my text.

However, wouldn't it be possible to prevent it from the beginning by forbidding me to call org-insert-link twice, i.e. making it a singleton/atomic function (I don't see a UseCase where this could be useful to be able to call it inside itself, but maybe I'm wrong)?

Thanks


-- 
Guillaume MULLER

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 673 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

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

* Re: Bug in org-insert-link?
  2023-09-27 15:29 Bug in org-insert-link? Guillaume MULLER
@ 2023-10-05 10:18 ` Ihor Radchenko
  2023-10-09 14:40   ` Guillaume MULLER
  0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2023-10-05 10:18 UTC (permalink / raw)
  To: Guillaume MULLER; +Cc: emacs-orgmode@gnu.org

Guillaume MULLER <guillaume.muller@emse.fr> writes:

> ...
> - Switch back to (Doom)Emacs ("window"/desktop)
> - Click inside the Emacs "window" to give it focus
> [Here is the problem: sometimes I forgot that I already started the org-insert-link]
> - Call org-insert-link
> - Paste the URL
> - Validate the link creation
>
> Then the link is inserted where I clicked last (to give focus to the Emacs "window").

By default, Emacs moves point to where you click. You can do the same
thing if you deliberately C-x o from the minibuffer. See 9.3 Editing in
the Minibuffer section of Emacs manual.
I see nothing wrong on the Org side.

> Of course, the problem lies in my mistake of calling twice the org-insert-link method, but the behavior is very strange, and it took me some time to identify why my links were inserted at random places in my text.
>
> However, wouldn't it be possible to prevent it from the beginning by forbidding me to call org-insert-link twice, i.e. making it a singleton/atomic function (I don't see a UseCase where this could be useful to be able to call it inside itself, but maybe I'm wrong)?

Check out 22.1 Mouse Commands for Editing section of Emacs manual.
`x-mouse-click-focus-ignore-position' might be something you want to
customize.

-- 
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] 9+ messages in thread

* Re: Bug in org-insert-link?
  2023-10-05 10:18 ` Ihor Radchenko
@ 2023-10-09 14:40   ` Guillaume MULLER
  2023-10-10 11:25     ` Ihor Radchenko
  2023-12-04 15:24     ` Guillaume MULLER
  0 siblings, 2 replies; 9+ messages in thread
From: Guillaume MULLER @ 2023-10-09 14:40 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode@gnu.org


[-- Attachment #1.1.1: Type: text/plain, Size: 1963 bytes --]

Hi,

Thanks for the answer... I'll have a look at your links.

However, since I wrote the email, I've seen the behavior occur without changing (at least voluntarily) the cursor position in the Org buffer...

On 10/5/23 12:18, Ihor Radchenko wrote:
> Guillaume MULLER <guillaume.muller@emse.fr> writes:
> 
>> ...
>> - Switch back to (Doom)Emacs ("window"/desktop)
>> - Click inside the Emacs "window" to give it focus
>> [Here is the problem: sometimes I forgot that I already started the org-insert-link]
>> - Call org-insert-link
>> - Paste the URL
>> - Validate the link creation
>>
>> Then the link is inserted where I clicked last (to give focus to the Emacs "window").
> 
> By default, Emacs moves point to where you click. You can do the same
> thing if you deliberately C-x o from the minibuffer. See 9.3 Editing in
> the Minibuffer section of Emacs manual.
> I see nothing wrong on the Org side.
> 
>> Of course, the problem lies in my mistake of calling twice the org-insert-link method, but the behavior is very strange, and it took me some time to identify why my links were inserted at random places in my text.
>>
>> However, wouldn't it be possible to prevent it from the beginning by forbidding me to call org-insert-link twice, i.e. making it a singleton/atomic function (I don't see a UseCase where this could be useful to be able to call it inside itself, but maybe I'm wrong)?
> 
> Check out 22.1 Mouse Commands for Editing section of Emacs manual.
> `x-mouse-click-focus-ignore-position' might be something you want to
> customize.
> 

-- 
Guillaume MULLER
Associate Professor, PhD
Fayol Institue - ISI Department
🚪 #426
☎ 04 77 42 02 71
🕸 https://www.mines-stetienne.fr
🧍= Physical Address =
   Espace Fauriel
   29 Rue Pierre et Dominique Ponchardier
   42100 Saint-Étienne
📬 = Postal Address =
   École des Mines de Saint-Étienne
   158 cours Fauriel
   42100 Saint-Étienne

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 673 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

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

* Re: Bug in org-insert-link?
  2023-10-09 14:40   ` Guillaume MULLER
@ 2023-10-10 11:25     ` Ihor Radchenko
  2023-10-10 11:33       ` Guillaume MULLER
  2023-12-04 15:24     ` Guillaume MULLER
  1 sibling, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2023-10-10 11:25 UTC (permalink / raw)
  To: Guillaume MULLER; +Cc: emacs-orgmode@gnu.org

Guillaume MULLER <guillaume.muller@emse.fr> writes:

> However, since I wrote the email, I've seen the behavior occur without changing (at least voluntarily) the cursor position in the Org buffer...

Clicking, by default, changes the cursor position.

-- 
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] 9+ messages in thread

* Re: Bug in org-insert-link?
  2023-10-10 11:25     ` Ihor Radchenko
@ 2023-10-10 11:33       ` Guillaume MULLER
  2023-10-10 11:38         ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Guillaume MULLER @ 2023-10-10 11:33 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode@gnu.org


[-- Attachment #1.1.1: Type: text/plain, Size: 615 bytes --]



On 10/10/23 13:25, Ihor Radchenko wrote:
> Guillaume MULLER <guillaume.muller@emse.fr> writes:
> 
>> However, since I wrote the email, I've seen the behavior occur without changing (at least voluntarily) the cursor position in the Org buffer...
> 
> Clicking, by default, changes the cursor position.

I forgot to mention, I'm using a WindowManager (i3) configured with "focus follows mouse" behavior, so I usually (~99% of the time) do not click in the Emacs window when I come back to it, so the cursor should not have moved when I do the manipulations I was talking about.


-- 
Guillaume MULLER

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 673 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

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

* Re: Bug in org-insert-link?
  2023-10-10 11:33       ` Guillaume MULLER
@ 2023-10-10 11:38         ` Ihor Radchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Ihor Radchenko @ 2023-10-10 11:38 UTC (permalink / raw)
  To: Guillaume MULLER; +Cc: emacs-orgmode@gnu.org

Guillaume MULLER <guillaume.muller@emse.fr> writes:

>> Clicking, by default, changes the cursor position.
>
> I forgot to mention, I'm using a WindowManager (i3) configured with "focus follows mouse" behavior, so I usually (~99% of the time) do not click in the Emacs window when I come back to it, so the cursor should not have moved when I do the manipulations I was talking about.

If no click even is produced, Emacs will not change cursor position.
But i3 might, in theory, emulate click. Or not.
You might consider checking if changing the focus alter cursor position
in non-Org buffers. If it is the case, you can file a bug report to
Emacs - you might get better help from people more familiar with these
peculiarities.

-- 
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] 9+ messages in thread

* Re: Bug in org-insert-link?
  2023-10-09 14:40   ` Guillaume MULLER
  2023-10-10 11:25     ` Ihor Radchenko
@ 2023-12-04 15:24     ` Guillaume MULLER
  2023-12-04 16:13       ` Guillaume MULLER
  1 sibling, 1 reply; 9+ messages in thread
From: Guillaume MULLER @ 2023-12-04 15:24 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


[-- Attachment #1.1.1: Type: text/plain, Size: 3808 bytes --]

Hi,

Sorry for coming back that late on this problem. The problem came back again today: Links get inserted into random places again.

I think I have (the beginning of) an idea where problem lies.

Context:
- I'm using (Doom)Emacs in emacs-client mode, and I'm putting my computer only on sleep at night, so Emacs (daemon) often runs for weeks
- I regularly do some updates/upgrades: `sh> doom upgrade` or `sh> doom sync -u` (from shell, outside DoomEmacs)
   - Sometimes it works, so I just continue using Emacs
   - But sometimes doing the updates/upgrades while DoomEmacs is running make it go berserk
   - In such cases, I start by running `M-x doom/reload` (from inside Emacs), and if org buffers are going berserk too, I also run `M-x org-reload`
   - If it still does not work (most of the time), I `pkill emacs` and start Emacs again from scratch

The last time the link insertion issue appeared, I had called `M-x org-reload` after a `M-x doom/reload` after a `sh> doom upgrade`.

Restarting Emacs solved it.

I tried calling `M-x org-reload` and inserting some link on the fresh new Emacs process, and it seems to work.

So the problem apparently comes when calling `M-x org-reload` (from inside Emacs) after calling `sh> doom upgrade` (from outside Emacs). (NOTE: I haven't been able to try if the problem appears when calling `M-x doom/upgrade` (from inside Emacs) yet, as my Emacs is the freshest possible for now).

My conclusion is that "the bug" probably comes from the fact that the "org-mode" being reloaded is a fresher version than the "org-mode" that was loaded when Emacs-client was started, several weeks ago.

Not sure if this issue should be pursued or if my franken-usage of Emacs is to be blamed :)

Cheers

On 10/9/23 16:40, Guillaume MULLER wrote:
> Hi,
> 
> Thanks for the answer... I'll have a look at your links.
> 
> However, since I wrote the email, I've seen the behavior occur without changing (at least voluntarily) the cursor position in the Org buffer...
> 
> On 10/5/23 12:18, Ihor Radchenko wrote:
>> Guillaume MULLER <guillaume.muller@emse.fr> writes:
>>
>>> ...
>>> - Switch back to (Doom)Emacs ("window"/desktop)
>>> - Click inside the Emacs "window" to give it focus
>>> [Here is the problem: sometimes I forgot that I already started the org-insert-link]
>>> - Call org-insert-link
>>> - Paste the URL
>>> - Validate the link creation
>>>
>>> Then the link is inserted where I clicked last (to give focus to the Emacs "window").
>>
>> By default, Emacs moves point to where you click. You can do the same
>> thing if you deliberately C-x o from the minibuffer. See 9.3 Editing in
>> the Minibuffer section of Emacs manual.
>> I see nothing wrong on the Org side.
>>
>>> Of course, the problem lies in my mistake of calling twice the org-insert-link method, but the behavior is very strange, and it took me some time to identify why my links were inserted at random places in my text.
>>>
>>> However, wouldn't it be possible to prevent it from the beginning by forbidding me to call org-insert-link twice, i.e. making it a singleton/atomic function (I don't see a UseCase where this could be useful to be able to call it inside itself, but maybe I'm wrong)?
>>
>> Check out 22.1 Mouse Commands for Editing section of Emacs manual.
>> `x-mouse-click-focus-ignore-position' might be something you want to
>> customize.
>>
> 

-- 
Guillaume MULLER
Associate Professor, PhD
Fayol Institute - ISI Department
🚪 #426
☎ 04 77 42 02 71
🕸 https://www.mines-stetienne.fr
🧍= Physical Address =
   Espace Fauriel
   29 Rue Pierre et Dominique Ponchardier
   42100 Saint-Étienne
📬 = Postal Address =
   École des Mines de Saint-Étienne
   158 cours Fauriel
   42100 Saint-Étienne

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 673 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

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

* Re: Bug in org-insert-link?
  2023-12-04 15:24     ` Guillaume MULLER
@ 2023-12-04 16:13       ` Guillaume MULLER
  2023-12-05 12:29         ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Guillaume MULLER @ 2023-12-04 16:13 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


[-- Attachment #1.1.1: Type: text/plain, Size: 4507 bytes --]

EDIT:

The problem is still here, and I managed to find the actual problem.

The problem happens when I do the "C-C C-l file:" then select a file. The root cause is that the mini-buffer then lists all the files in the current directory, and when there are many, the mini-buffer becomes quite big. Thus, the current buffer gets its size reduced, and when the cursor was very low in the buffer frame/window(?), the cursor "magically" jumps to a new position, in the part of the buffer that remained visible.

It is now perfectly reproducible on my side.

On 12/4/23 16:24, Guillaume MULLER wrote:
> Hi,
> 
> Sorry for coming back that late on this problem. The problem came back again today: Links get inserted into random places again.
> 
> I think I have (the beginning of) an idea where problem lies.
> 
> Context:
> - I'm using (Doom)Emacs in emacs-client mode, and I'm putting my computer only on sleep at night, so Emacs (daemon) often runs for weeks
> - I regularly do some updates/upgrades: `sh> doom upgrade` or `sh> doom sync -u` (from shell, outside DoomEmacs)
>    - Sometimes it works, so I just continue using Emacs
>    - But sometimes doing the updates/upgrades while DoomEmacs is running make it go berserk
>    - In such cases, I start by running `M-x doom/reload` (from inside Emacs), and if org buffers are going berserk too, I also run `M-x org-reload`
>    - If it still does not work (most of the time), I `pkill emacs` and start Emacs again from scratch
> 
> The last time the link insertion issue appeared, I had called `M-x org-reload` after a `M-x doom/reload` after a `sh> doom upgrade`.
> 
> Restarting Emacs solved it.
> 
> I tried calling `M-x org-reload` and inserting some link on the fresh new Emacs process, and it seems to work.
> 
> So the problem apparently comes when calling `M-x org-reload` (from inside Emacs) after calling `sh> doom upgrade` (from outside Emacs). (NOTE: I haven't been able to try if the problem appears when calling `M-x doom/upgrade` (from inside Emacs) yet, as my Emacs is the freshest possible for now).
> 
> My conclusion is that "the bug" probably comes from the fact that the "org-mode" being reloaded is a fresher version than the "org-mode" that was loaded when Emacs-client was started, several weeks ago.
> 
> Not sure if this issue should be pursued or if my franken-usage of Emacs is to be blamed :)
> 
> Cheers
> 
> On 10/9/23 16:40, Guillaume MULLER wrote:
>> Hi,
>>
>> Thanks for the answer... I'll have a look at your links.
>>
>> However, since I wrote the email, I've seen the behavior occur without changing (at least voluntarily) the cursor position in the Org buffer...
>>
>> On 10/5/23 12:18, Ihor Radchenko wrote:
>>> Guillaume MULLER <guillaume.muller@emse.fr> writes:
>>>
>>>> ...
>>>> - Switch back to (Doom)Emacs ("window"/desktop)
>>>> - Click inside the Emacs "window" to give it focus
>>>> [Here is the problem: sometimes I forgot that I already started the org-insert-link]
>>>> - Call org-insert-link
>>>> - Paste the URL
>>>> - Validate the link creation
>>>>
>>>> Then the link is inserted where I clicked last (to give focus to the Emacs "window").
>>>
>>> By default, Emacs moves point to where you click. You can do the same
>>> thing if you deliberately C-x o from the minibuffer. See 9.3 Editing in
>>> the Minibuffer section of Emacs manual.
>>> I see nothing wrong on the Org side.
>>>
>>>> Of course, the problem lies in my mistake of calling twice the org-insert-link method, but the behavior is very strange, and it took me some time to identify why my links were inserted at random places in my text.
>>>>
>>>> However, wouldn't it be possible to prevent it from the beginning by forbidding me to call org-insert-link twice, i.e. making it a singleton/atomic function (I don't see a UseCase where this could be useful to be able to call it inside itself, but maybe I'm wrong)?
>>>
>>> Check out 22.1 Mouse Commands for Editing section of Emacs manual.
>>> `x-mouse-click-focus-ignore-position' might be something you want to
>>> customize.
>>>
>>
> 

-- 
Guillaume MULLER
Associate Professor, PhD
Fayol Institute - ISI Department
🚪 #426
☎ 04 77 42 02 71
🕸 https://www.mines-stetienne.fr
🧍= Physical Address =
   Espace Fauriel
   29 Rue Pierre et Dominique Ponchardier
   42100 Saint-Étienne
📬 = Postal Address =
   École des Mines de Saint-Étienne
   158 cours Fauriel
   42100 Saint-Étienne

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 673 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

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

* Re: Bug in org-insert-link?
  2023-12-04 16:13       ` Guillaume MULLER
@ 2023-12-05 12:29         ` Ihor Radchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Ihor Radchenko @ 2023-12-05 12:29 UTC (permalink / raw)
  To: Guillaume MULLER; +Cc: emacs-orgmode@gnu.org

Guillaume MULLER <guillaume.muller@emse.fr> writes:

> The problem is still here, and I managed to find the actual problem.
>
> The problem happens when I do the "C-C C-l file:" then select a file. The root cause is that the mini-buffer then lists all the files in the current directory, and when there are many, the mini-buffer becomes quite big. Thus, the current buffer gets its size reduced, and when the cursor was very low in the buffer frame/window(?), the cursor "magically" jumps to a new position, in the part of the buffer that remained visible.
>
> It is now perfectly reproducible on my side.

If you can, please provide the detailed instructions how to reproduce
the problem on other PC. Ideally, without Doom.
See https://orgmode.org/manual/Feedback.html#Feedback

-- 
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] 9+ messages in thread

end of thread, other threads:[~2023-12-05 12:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-27 15:29 Bug in org-insert-link? Guillaume MULLER
2023-10-05 10:18 ` Ihor Radchenko
2023-10-09 14:40   ` Guillaume MULLER
2023-10-10 11:25     ` Ihor Radchenko
2023-10-10 11:33       ` Guillaume MULLER
2023-10-10 11:38         ` Ihor Radchenko
2023-12-04 15:24     ` Guillaume MULLER
2023-12-04 16:13       ` Guillaume MULLER
2023-12-05 12:29         ` 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).