emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Killing link located at beginning of line does not kill full link if region is selected to beginning or end of line by either mouse or arrow keys [9.5.2 (release_9.5.2-13-gdd6486 @ c:/Program Files/Emacs/emacs-29.0.50-snapshot/share/emacs/29.0.50/lisp/org/)]
@ 2023-04-11  2:23 Miguel Garza
  2023-04-12  8:53 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Miguel Garza @ 2023-04-11  2:23 UTC (permalink / raw)
  To: emacs-orgmode

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

Hello,

I have Emacs 28 on one machine and this build 29 on this machine--both running on Windows 10. I've encountered the same bug on both builds of Emacs. I believe it's a bug.

To reproduce the behavior, first make a link that begins a line, such as:

[[www.google.com][link]]

Org Mode will turn the above text into a clickable link called "link".

Now, select the link either by clicking and dragging the mouse from the end of the word "link" to the beginning of the word, or by starting a region at either the beginning or end of the word (or on the next line) and then using the arrow keys to move point to either the "l" or "k" in "link".

Your region should now encompass "link" and nothing else.

Now, kill the line or region.

You will see immediately that the full text was not killed. Instead, the link description is killed, along with, depending on where point was, possibly some of the brackets, leaving behind the opening brackets, the link URL, the URL closing bracket, and in some cases the final two brackets.

This behavior does not occur if the link is not at the beginning of a line. For example, write this instead:

This is a [[www.google.com][link]] to Google.

Now, mark the same area, just the link that Org Mode has made, called "link", using the mouse or using a region demarcated by using the arrow keys.

Now, kill the link.

You will see that the full link has been killed. Yank to confirm.

I believe org mode is not correctly finding the last characters to select before either the beginning or end of the line in these use cases.

Thank you!

Emacs  : GNU Emacs 29.0.50 (build 8, x86_64-w64-mingw32)
of 2022-02-11
Package: Org mode version 9.5.2 (release_9.5.2-13-gdd6486 @ c:/Program Files/Emacs/emacs-29.0.50-snapshot/share/emacs/29.0.50/lisp/org/)

current state:
==============
(setq
org-link-elisp-confirm-function 'yes-or-no-p
org-bibtex-headline-format-function #[257 "\300\x01\236A\207" [:title] 3 "\n\n(fn ENTRY)"]
org-export-before-parsing-hook '(org-attach-expand-links)
org-archive-hook '(org-attach-archive-delete-maybe)
org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
  org-cycle-show-empty-lines
  org-optimize-window-after-visibility-change)
org-mode-hook '(#[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-show-all append local]
   5]
#[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-babel-show-result-all
    append local]
   5]
org-babel-result-hide-spec org-babel-hide-all-hashes)
org-confirm-shell-link-function 'yes-or-no-p
outline-isearch-open-invisible-function 'outline-isearch-open-invisible
org-agenda-before-write-hook '(org-agenda-add-entry-text)
org-src-mode-hook '(org-src-babel-configure-edit-buffer
     org-src-mode-configure-edit-buffer)
org-confirm-elisp-link-function 'yes-or-no-p
org-speed-command-hook '(org-speed-command-activate
  org-babel-speed-command-activate)
org-tab-first-hook '(org-babel-hide-result-toggle-maybe
      org-babel-header-arg-expand)
org-link-shell-confirm-function 'yes-or-no-p
org-babel-pre-tangle-hook '(save-buffer)
org-agenda-loop-over-headlines-in-active-region nil
org-occur-hook '(org-first-headline-recenter)
org-metadown-hook '(org-babel-pop-to-session-maybe)
org-link-parameters '(("attachment" :follow org-attach-follow :complete
org-attach-complete-link)
       ("id" :follow org-id-open)
       ("eww" :follow org-eww-open :store org-eww-store-link)
       ("rmail" :follow org-rmail-open :store
org-rmail-store-link)
       ("mhe" :follow org-mhe-open :store org-mhe-store-link)
       ("irc" :follow org-irc-visit :store org-irc-store-link
:export org-irc-export)
       ("info" :follow org-info-open :export org-info-export
:store org-info-store-link)
       ("gnus" :follow org-gnus-open :store
org-gnus-store-link)
       ("docview" :follow org-docview-open :export
org-docview-export :store org-docview-store-link)
       ("bibtex" :follow org-bibtex-open :store
org-bibtex-store-link)
       ("bbdb" :follow org-bbdb-open :export org-bbdb-export
:complete org-bbdb-complete-link :store
org-bbdb-store-link)
       ("w3m" :store org-w3m-store-link)
       ("doi" :follow org-link-doi-open :export
org-link-doi-export)
       ("file+sys") ("file+emacs")
       ("shell" :follow org-link--open-shell)
       ("news" :follow
#[514 "\301\300\302\x04Q\x02\"\207"
  ["news" browse-url ":"] 6 "\n\n(fn URL ARG)"]
)
       ("mailto" :follow
#[514 "\301\300\302\x04Q\x02\"\207"
  ["mailto" browse-url ":"] 6 "\n\n(fn URL ARG)"]
)
       ("https" :follow
#[514 "\301\300\302\x04Q\x02\"\207"
  ["https" browse-url ":"] 6 "\n\n(fn URL ARG)"]
)
       ("http" :follow
#[514 "\301\300\302\x04Q\x02\"\207"
  ["http" browse-url ":"] 6 "\n\n(fn URL ARG)"]
)
       ("ftp" :follow
#[514 "\301\300\302\x04Q\x02\"\207" ["ftp" browse-url ":"]
  6 "\n\n(fn URL ARG)"]
)
       ("help" :follow org-link--open-help :store
org-link--store-help)
       ("file" :complete org-link-complete-file)
       ("elisp" :follow org-link--open-elisp))
org-metaup-hook '(org-babel-load-in-session-maybe)
)

[-- Attachment #2: Type: text/html, Size: 7746 bytes --]

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

* Re: [BUG] Killing link located at beginning of line does not kill full link if region is selected to beginning or end of line by either mouse or arrow keys [9.5.2 (release_9.5.2-13-gdd6486 @ c:/Program Files/Emacs/emacs-29.0.50-snapshot/share/emacs/29.0.50/lisp/org/)]
  2023-04-11  2:23 [BUG] Killing link located at beginning of line does not kill full link if region is selected to beginning or end of line by either mouse or arrow keys [9.5.2 (release_9.5.2-13-gdd6486 @ c:/Program Files/Emacs/emacs-29.0.50-snapshot/share/emacs/29.0.50/lisp/org/)] Miguel Garza
@ 2023-04-12  8:53 ` Ihor Radchenko
  2023-04-13  2:51   ` Miguel Garza
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2023-04-12  8:53 UTC (permalink / raw)
  To: Miguel Garza; +Cc: emacs-orgmode

"Miguel Garza" <miguelgarza@fastmail.com> writes:

> [[www.google.com][link]]
>
> Org Mode will turn the above text into a clickable link called "link".
>
> Now, select the link either by clicking and dragging the mouse from the end of the word "link" to the beginning of the word, or by starting a region at either the beginning or end of the word (or on the next line) and then using the arrow keys to move point to either the "l" or "k" in "link".
>
> Your region should now encompass "link" and nothing else.
>
> Now, kill the line or region.
>
> You will see immediately that the full text was not killed. Instead, the link description is killed, along with, depending on where point was, possibly some of the brackets, leaving behind the opening brackets, the link URL, the URL closing bracket, and in some cases the final two brackets.

Well. Part of the link text is indeed hidden, causing all kinds of
unexpected behaviours depending on the point move direction.
I am not sure what can be done here. I am not even sure what is the
expected behaviour.

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

* Re: [BUG] Killing link located at beginning of line does not kill full link if region is selected to beginning or end of line by either mouse or arrow keys [9.5.2 (release_9.5.2-13-gdd6486 @ c:/Program Files/Emacs/emacs-29.0.50-snapshot/share/emacs/29.0.50/lisp/org/)]
  2023-04-12  8:53 ` Ihor Radchenko
@ 2023-04-13  2:51   ` Miguel Garza
  2023-04-13 10:49     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Miguel Garza @ 2023-04-13  2:51 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

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

Yes, I think there could be arguments for different behaviors, but I suspect the expected behavior should be the same as when you select the link by other methods, such as starting a region at one end and then jumping to the beginning or end of the line with move-beginning-of-line or move-end-of-line. When killing the line or region after that movement, the entire text (URL, description, all brackets) is killed.

Also, when emphasis markers are hidden (org-hide-emphasis-markers t), and the same experiment is performed on a word at the beginning of a line that is emphasized , for example "/italicized/", all of the hidden slash characters are successfully killed. So I think that is another indication that the expected behavior would be to kill all of the characters, hidden or not. 

I think the fact that it is only some, perhaps underused, methods of selecting the text--arrow keys or mouse-dragging--that result in this unusual behavior, also points to the behavior not being intended.

On Wed, Apr 12, 2023, at 3:53 AM, Ihor Radchenko wrote:
> "Miguel Garza" <miguelgarza@fastmail.com> writes:
> 
> > [[www.google.com][link]]
> >
> > Org Mode will turn the above text into a clickable link called "link".
> >
> > Now, select the link either by clicking and dragging the mouse from the end of the word "link" to the beginning of the word, or by starting a region at either the beginning or end of the word (or on the next line) and then using the arrow keys to move point to either the "l" or "k" in "link".
> >
> > Your region should now encompass "link" and nothing else.
> >
> > Now, kill the line or region.
> >
> > You will see immediately that the full text was not killed. Instead, the link description is killed, along with, depending on where point was, possibly some of the brackets, leaving behind the opening brackets, the link URL, the URL closing bracket, and in some cases the final two brackets.
> 
> Well. Part of the link text is indeed hidden, causing all kinds of
> unexpected behaviours depending on the point move direction.
> I am not sure what can be done here. I am not even sure what is the
> expected behaviour.
> 
> -- 
> 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>
> 

[-- Attachment #2: Type: text/html, Size: 3281 bytes --]

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

* Re: [BUG] Killing link located at beginning of line does not kill full link if region is selected to beginning or end of line by either mouse or arrow keys [9.5.2 (release_9.5.2-13-gdd6486 @ c:/Program Files/Emacs/emacs-29.0.50-snapshot/share/emacs/29.0.50/lisp/org/)]
  2023-04-13  2:51   ` Miguel Garza
@ 2023-04-13 10:49     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-04-13 10:49 UTC (permalink / raw)
  To: Miguel Garza; +Cc: emacs-orgmode

"Miguel Garza" <miguelgarza@fastmail.com> writes:

> Yes, I think there could be arguments for different behaviors, but I suspect the expected behavior should be the same as when you select the link by other methods, such as starting a region at one end and then jumping to the beginning or end of the line with move-beginning-of-line or move-end-of-line. When killing the line or region after that movement, the entire text (URL, description, all brackets) is killed.

I am not sure.
Consider a user who wants to select on the description part of
[[https://orgmode.org][link]]

Currently, it is possible to place region start at "l" by moving cursor
leftwards. Rightwards will place region start before the first "[".

What you suggest will make the described use case impossible.

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

end of thread, other threads:[~2023-04-13 10:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-11  2:23 [BUG] Killing link located at beginning of line does not kill full link if region is selected to beginning or end of line by either mouse or arrow keys [9.5.2 (release_9.5.2-13-gdd6486 @ c:/Program Files/Emacs/emacs-29.0.50-snapshot/share/emacs/29.0.50/lisp/org/)] Miguel Garza
2023-04-12  8:53 ` Ihor Radchenko
2023-04-13  2:51   ` Miguel Garza
2023-04-13 10:49     ` 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).