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

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

[elpa] externals/org 4c40fc3d4d 1/3: org: Allow spaces in #+LINK abbrevi


From: ELPA Syncer
Subject: [elpa] externals/org 4c40fc3d4d 1/3: org: Allow spaces in #+LINK abbreviation definitions
Date: Sun, 20 Nov 2022 00:58:07 -0500 (EST)

branch: externals/org
commit 4c40fc3d4da90f9988bb6224920a9c325223bd15
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    org: Allow spaces in #+LINK abbreviation definitions
    
    * lisp/org.el (org-set-regexps-and-options): Allow spaces when
    defining link abbreviations via #+LINK keyword.
    * testing/lisp/test-org-element.el (test-org-element/link-parser): Add
    a new test.
    * doc/org-manual.org (Link Abbreviations): Add example demonstrating
    link abbreviation with spaces.
    
    Reported-by: Rudolf Adamkovič <salutis@me.com>
    Link: https://orgmode.org/list/87zgf7zujc.fsf@localhost
---
 doc/org-manual.org               | 3 +++
 lisp/org.el                      | 6 +++++-
 testing/lisp/test-org-element.el | 9 +++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 318a12bfa2..25e06fe2ae 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3652,8 +3652,11 @@ can define them in the file with
 #+begin_example
 ,#+LINK: bugzilla  https://10.1.2.9/bugzilla/show_bug.cgi?id=
 ,#+LINK: duckduckgo https://duckduckgo.com/?q=%s
+,#+LINK: "Nu Html Checker" https://validator.w3.org/nu/?doc=%h
 #+end_example
 
+The abbreviations containing spaces must be quoted.
+
 In-buffer completion (see [[*Completion]]) can be used after =[= to
 complete link abbreviations.  You may also define a Lisp function that
 implements special (e.g., completion) support for inserting such a
diff --git a/lisp/org.el b/lisp/org.el
index 857c3147c5..26a8db3535 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4227,7 +4227,11 @@ related expressions."
               (delq nil
                     (mapcar
                      (lambda (value)
-                       (and (string-match "\\`\\(\\S-+\\)[ \t]+\\(.+\\)" value)
+                       (and (or
+                              ;; "abbrev with spaces" spec
+                              (string-match "\\`\"\\(.+[^\\]\\)\"[ 
\t]+\\(.+\\)" value)
+                              ;; abbrev spec
+                              (string-match "\\`\\(\\S-+\\)[ \t]+\\(.+\\)" 
value))
                             (cons (match-string-no-properties 1 value)
                                   (match-string-no-properties 2 value))))
                      (cdr (assoc "LINK" alist))))))
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index eb5b95e86e..78a735efec 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -2007,6 +2007,15 @@ e^{i\\pi}+1=0
            (progn (org-mode-restart)
                   (goto-char (1- (point-max)))
                   (org-element-property :type (org-element-context))))))
+  ;; Link abbreviation with spaces.
+  (should
+   (equal "https"
+          (org-test-with-temp-text
+              "#+LINK: \"Nu Html Checker\" https://validator.w3.org/nu/?doc=%h
+              [[Nu Html Checker:test]]"
+           (progn (org-mode-restart)
+                  (goto-char (1- (point-max)))
+                  (org-element-property :type (org-element-context))))))
   ;; Link abbreviation in a secondary string.
   (should
    (equal "https"



reply via email to

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