emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 69b36beac7 5/6: ol.el: Always prompt for descriptio


From: ELPA Syncer
Subject: [elpa] externals/org 69b36beac7 5/6: ol.el: Always prompt for description in `org-insert-link'
Date: Thu, 15 Sep 2022 23:57:54 -0400 (EDT)

branch: externals/org
commit 69b36beac790bad95fdd9ce4a7bcfbbb46d39c64
Author: Max Nikulin <manikulin@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    ol.el: Always prompt for description in `org-insert-link'
    
    * lisp/ol.el (org-insert-link): Do not bypass code trying to generated
    description and prompt user when link path and description are
    identical.  Make behavior of description prompt more consistent.
    
    Remove confusing `auto-desc' local variable.  Originally the variable
    was added with implementation of completion of stored link target by the
    description in the commit 1e34c5d34 Bastien Guerry, "org.el: Fontify
    links to current buffer when inserting a link",
    2012-08-03 14:08:20 +0200.  The feature was broken soon by the commit
    7f096ad37 Tony Day, "org-insert-link: Use ido when inserting links",
    2012-10-12 14:39:53 +1100.  Last decade users were not asked to edit
    description in the case of the same link target and description
    (a remained side effect of 1e34c5d34).  Recent commit 0432f4fe6 Max
    Nikulin, "ol.el: Restore complete by description for insert link",
    2022-09-10 17:23:13 +0700 restored completion by description.
    Due to the commit 4fc2c8dd8 Ihor Radchenko, "org-store-link: Default to
    empty description for target/custom-id links", 2022-08-10 13:25:26 +0800
    description identical to link path became a more rare case.
    
    An alternative would be fixing condition to allow users to edit
    description when it is the same as the path, but use stored description
    without additional interaction when the link is chosen by description
    completion.  Despite it was likely the original intention, always asking
    the user to confirm or edit description may be more consistent behavior.
---
 lisp/ol.el | 72 ++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 35 insertions(+), 37 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index f3f6e04ef5..8f700397ed 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1822,7 +1822,7 @@ non-interactively, don't allow to edit the default 
description."
         (all-prefixes (append (mapcar #'car abbrevs)
                               (mapcar #'car org-link-abbrev-alist)
                               (org-link-types)))
-         entry auto-desc)
+         entry)
     (cond
      (link-location)                 ; specified by arg, just use it.
      ((org-in-regexp org-link-bracket-re 1)
@@ -1885,8 +1885,7 @@ Use TAB to complete link prefixes, then RET for 
type-specific completion support
            (unless (org-string-nw-p link) (user-error "No link selected"))
            (dolist (l org-stored-links)
              (when (equal link (cadr l))
-               (setq link (car l))
-               (setq auto-desc t)))
+               (setq link (car l))))
            (when (or (member link all-prefixes)
                      (and (equal ":" (substring link -1))
                           (member (substring link 0 -1) all-prefixes)
@@ -1963,41 +1962,40 @@ Use TAB to complete link prefixes, then RET for 
type-specific completion support
          (when (equal desc origpath)
            (setq desc path)))))
 
-    (unless auto-desc
-      (let* ((type
-              (cond
-               ((and all-prefixes
-                     (string-match (rx-to-string `(: string-start (submatch 
(or ,@all-prefixes)) ":")) link))
-                (match-string 1 link))
-               ((file-name-absolute-p link) "file")
-               ((string-match "\\`\\.\\.?/" link) "file")))
-             (initial-input
-             (cond
-              (description)
-               (desc)
-               ((org-link-get-parameter type :insert-description)
-                (let ((def (org-link-get-parameter type :insert-description)))
-                  (condition-case nil
-                      (cond
-                       ((stringp def) def)
-                       ((functionp def)
-                        (funcall def link desc)))
-                    (error
-                     (message "Can't get link description from org link 
parameter `:insert-description': %S"
-                             def)
-                    (sit-for 2)
-                     nil))))
-              (org-link-make-description-function
+    (let* ((type
+            (cond
+             ((and all-prefixes
+                   (string-match (rx-to-string `(: string-start (submatch (or 
,@all-prefixes)) ":")) link))
+              (match-string 1 link))
+             ((file-name-absolute-p link) "file")
+             ((string-match "\\`\\.\\.?/" link) "file")))
+           (initial-input
+            (cond
+             (description)
+             (desc)
+             ((org-link-get-parameter type :insert-description)
+              (let ((def (org-link-get-parameter type :insert-description)))
                 (condition-case nil
-                   (funcall org-link-make-description-function link desc)
-                 (error
-                  (message "Can't get link description from %S"
-                           org-link-make-description-function)
-                  (sit-for 2)
-                  nil))))))
-       (setq desc (if (called-interactively-p 'any)
-                      (read-string "Description: " initial-input)
-                    initial-input))))
+                    (cond
+                     ((stringp def) def)
+                     ((functionp def)
+                      (funcall def link desc)))
+                  (error
+                   (message "Can't get link description from org link 
parameter `:insert-description': %S"
+                            def)
+                   (sit-for 2)
+                   nil))))
+             (org-link-make-description-function
+              (condition-case nil
+                  (funcall org-link-make-description-function link desc)
+                (error
+                 (message "Can't get link description from %S"
+                          org-link-make-description-function)
+                 (sit-for 2)
+                 nil))))))
+      (setq desc (if (called-interactively-p 'any)
+                     (read-string "Description: " initial-input)
+                   initial-input)))
 
     (unless (org-string-nw-p desc) (setq desc nil))
     (when remove (apply #'delete-region remove))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]