emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Bastien Guerry <bzg@gnu.org>
Cc: Anthony Carrico <acarrico@memebeam.org>, emacs-orgmode@gnu.org
Subject: Re: [PATCH] Re: what is the purpose of "This link has already been stored"?
Date: Mon, 14 Aug 2023 10:51:48 +0000	[thread overview]
Message-ID: <87wmxxq4l7.fsf@localhost> (raw)
In-Reply-To: <87fs4n2smr.fsf@bzg.fr>

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

Bastien Guerry <bzg@gnu.org> writes:

> Here is another suggestion:
>
> 1) Remove the option and make adding the dup link on top the default.
>
> (1) is because removing this option would be a breaking change, and
> inflincting a new option to every user to deal with a hypothetical
> use-case does not seem right.
>

See the attached tentative patch.

> 2) Also remove the current C-u C-u C-u arg and make it the default
>    when a region is active.
> ...
> (2) should be done anyway.

I studied this further and what you suggest will interfere with
`org-link-context-for-files'. It will no longer be possible to select
text <from here>very long
and multi-line link description<to here>, M-x org-store-link, and get
the selected text as stored link description.

The current default of using active region as description makes more
sense, IMHO.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-store-link-Never-allow-link-duplicates-in-org-st.patch --]
[-- Type: text/x-patch, Size: 4035 bytes --]

From 7d8ed8f767c632bbb94f236fd08ee31e0d573e39 Mon Sep 17 00:00:00 2001
Message-ID: <7d8ed8f767c632bbb94f236fd08ee31e0d573e39.1692010108.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Mon, 14 Aug 2023 13:39:47 +0300
Subject: [PATCH] org-store-link: Never allow link duplicates in
 `org-stored-links'

* lisp/ol.el (org-link-store-existing): Remove the previously added
custom option.
(org-store-link): Do not use `org-link-store-existing' removing all
the code branches for values other than 'move-to-front.
* etc/ORG-NEWS (~org-store-link~ now moves an already stored link to
front of the ~org-stored-links~): Remove reference to the removed
custom option.

Link: https://orgmode.org/list/87leeffd1z.fsf@localhost
---
 etc/ORG-NEWS |  6 ------
 lisp/ol.el   | 37 +++++++++++--------------------------
 2 files changed, 11 insertions(+), 32 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 1dc0a4519..6169dacf9 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -31,12 +31,6 @@ Now, ~org-store-link~ moves the stored link to front of the list of
 stored links.  This way, the link will show up first in the completion
 and when inserting all the stored links with ~org-insert-all-links~.
 
-The new behavior is controlled by new customization ~org-link-store-existing~.
-
-Users can set ~org-link-store-existing~ to nil to revert previous
-defaults.  The value of =store-duplicate= will force duplicate links
-in ~org-stored-links~.  The default value is =move-to-front=.
-
 *** Major changes and additions to Org API
 **** New term: "syntax node"
 
diff --git a/lisp/ol.el b/lisp/ol.el
index 3a8ca5f39..20aab6bb8 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -509,20 +509,6 @@ (defcustom org-link-keep-stored-after-insertion nil
   :type 'boolean
   :safe #'booleanp)
 
-(defcustom org-link-store-existing 'move-to-front
-  "Variable controlling how to deal with already stored links.
-When nil, ignore store request for an already stored link.
-When symbol `move-to-front', move the stored link to the front of
-`org-stored-links'.
-When symbol `store-duplicate', add a duplicate in front."
-  :group 'org-link-store
-  :type '(choice
-          (const :tag "Do no store duplicate" nil)
-          (const :tag "Move stored duplicate to front" move-to-front)
-          (const :tag "Store duplicate" store-duplicate))
-  :safe #'symbolp
-  :package-version '(Org . "9.7"))
-
 ;;; Public variables
 
 (defconst org-target-regexp (let ((border "[^<>\n\r \t]"))
@@ -1764,18 +1750,17 @@ (defun org-store-link (arg &optional interactive?)
       (if (not (and interactive? link))
 	  (or agenda-link (and link (org-link-make-string link desc)))
         (dotimes (_ (if custom-id 2 1)) ; Store 2 links when CUSTOM-ID is non-nil.
-          (pcase org-link-store-existing
-            ((or `store-duplicate
-                 (guard (not (member (list link desc) org-stored-links))))
-             (push (list link desc) org-stored-links)
-	     (message "Stored: %s" (or desc link)))
-            ((or`nil (guard (equal (list link desc) (car org-stored-links))))
-             (message "This link has already been stored"))
-            (`move-to-front
-             (setq org-stored-links
-                   (delete (list link desc) org-stored-links))
-             (push (list link desc) org-stored-links)
-             (message "Link moved to front: %s" (or desc link))))
+          (cond
+           ((not (member (list link desc) org-stored-links))
+            (push (list link desc) org-stored-links)
+	    (message "Stored: %s" (or desc link)))
+           ((equal (list link desc) (car org-stored-links))
+            (message "This link has already been stored"))
+           (t
+            (setq org-stored-links
+                  (delete (list link desc) org-stored-links))
+            (push (list link desc) org-stored-links)
+            (message "Link moved to front: %s" (or desc link))))
 	  (when custom-id
 	    (setq link (concat "file:"
 			       (abbreviate-file-name
-- 
2.41.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>

  parent reply	other threads:[~2023-08-14 10:57 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28  1:35 what is the purpose of "This link has already been stored"? Samuel Wales
2023-06-28  9:32 ` Ihor Radchenko
2023-06-28 16:19   ` Anthony Carrico
2023-06-28 16:48     ` Ihor Radchenko
2023-06-28 23:59   ` Samuel Wales
2023-06-29  0:04     ` Samuel Wales
2023-06-29  0:07       ` Samuel Wales
2023-06-29 10:28         ` Ihor Radchenko
2023-06-29 13:02           ` Anthony Carrico
2023-06-29 13:09             ` Ihor Radchenko
2023-06-30  3:00               ` Samuel Wales
2023-06-30  3:26                 ` Samuel Wales
2023-07-05 10:19               ` [PATCH] " Ihor Radchenko
2023-07-06  0:28                 ` Samuel Wales
2023-07-15 12:35                 ` Ihor Radchenko
2023-07-21  4:13                   ` Samuel Wales
2023-07-21  7:46                     ` Ihor Radchenko
2023-08-06 18:47                 ` Bastien
2023-08-06 20:53                   ` Samuel Wales
2023-08-08  9:08                     ` Ihor Radchenko
2023-08-08  9:04                   ` Ihor Radchenko
2023-08-08 13:37                     ` Bastien Guerry
2023-08-11  9:31                       ` Ihor Radchenko
2023-08-13  9:34                         ` Bastien Guerry
2023-08-13 10:32                           ` Ihor Radchenko
2023-08-14  0:36                             ` Samuel Wales
2023-08-14 10:19                               ` Ihor Radchenko
2023-08-14 10:51                           ` Ihor Radchenko [this message]
2023-08-14 16:29                             ` Bastien Guerry
2023-08-15 10:55                               ` Ihor Radchenko
2023-08-16 13:20                                 ` Bastien Guerry
2023-07-01  4:48 ` org-insert-link completion by description (Re: what is the purpose of "This link has already been stored"?) Max Nikulin
2023-07-01  5:15   ` Samuel Wales
2023-07-01  5:26     ` Samuel Wales
2023-07-01  6:12     ` Max Nikulin
2023-07-02  3:29       ` Max Nikulin
2023-07-02  5:02         ` Samuel Wales
2023-07-02  5:52           ` Max Nikulin
2023-07-02  6:03             ` Samuel Wales
2023-07-03 14:56               ` Max Nikulin
2023-07-03 23:28                 ` Samuel Wales
2023-07-03 23:42                   ` Samuel Wales
2023-07-03 23:48                   ` Samuel Wales
2023-07-03 23:49                     ` Samuel Wales
2023-07-03 23:50                       ` Samuel Wales
2023-07-04  0:27                         ` Samuel Wales
2023-07-04  0:28                           ` Samuel Wales
2023-07-04  1:45                             ` Max Nikulin
2023-07-04  2:29                               ` Samuel Wales
2023-07-04  9:31                                 ` Ihor Radchenko
2023-07-05  0:10                                   ` Samuel Wales
2023-07-05 11:00                                     ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wmxxq4l7.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=acarrico@memebeam.org \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).