Browse Source

Merge branch 'master' of orgmode.org:org-mode

Bastien Guerry 11 years ago
parent
commit
e24f336cd3
3 changed files with 17 additions and 15 deletions
  1. 9 6
      lisp/org-element.el
  2. 5 5
      lisp/org.el
  3. 3 4
      testing/lisp/test-org-element.el

+ 9 - 6
lisp/org-element.el

@@ -2943,12 +2943,14 @@ Assume point is at the beginning of the link."
 	  raw-link link search-option application)
       (cond
        ;; Type 1: Text targeted from a radio target.
-       ((and org-target-link-regexp (looking-at org-target-link-regexp))
+       ((and org-target-link-regexp
+	     (save-excursion (or (bolp) (backward-char))
+			     (looking-at org-target-link-regexp)))
 	(setq type "radio"
-	      link-end (match-end 0)
-	      path (org-match-string-no-properties 0)
-	      contents-begin (match-beginning 0)
-	      contents-end (match-end 0)))
+	      link-end (match-end 1)
+	      path (org-match-string-no-properties 1)
+	      contents-begin (match-beginning 1)
+	      contents-end (match-end 1)))
        ;; Type 2: Standard link, i.e. [[http://orgmode.org][homepage]]
        ((looking-at org-bracket-link-regexp)
 	(setq contents-begin (match-beginning 3)
@@ -4184,8 +4186,9 @@ to an appropriate container (e.g., a paragraph)."
     (save-excursion
       (let ((limit (and org-target-link-regexp
 			(save-excursion
+			  (or (bolp) (backward-char))
 			  (re-search-forward org-target-link-regexp nil t))
-			(match-beginning 0)))
+			(match-beginning 1)))
 	    found)
 	(while (and (not found)
 		    (re-search-forward org-element--object-regexp limit t))

+ 5 - 5
lisp/org.el

@@ -6091,13 +6091,13 @@ by a #."
     (let ((case-fold-search t))
       (if (re-search-forward org-target-link-regexp limit t)
 	  (progn
-	    (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
-	    (add-text-properties (match-beginning 0) (match-end 0)
+	    (org-remove-flyspell-overlays-in (match-beginning 1) (match-end 1))
+	    (add-text-properties (match-beginning 1) (match-end 1)
 				 (list 'mouse-face 'highlight
 				       'keymap org-mouse-map
 				       'help-echo "Radio target link"
 				       'org-linked-text t))
-	    (org-rear-nonsticky-at (match-end 0))
+	    (org-rear-nonsticky-at (match-end 1))
 	    t)))))
 
 (defun org-update-radio-target-regexp ()
@@ -6192,13 +6192,13 @@ targets."
 The regular expression finds the targets also if there is a line break
 between words."
   (and targets
-       (concat "\\("
+       (concat "\\(?:^\\|[^[:alnum:]]\\)\\("
 	       (mapconcat
 		(lambda (x)
 		  (replace-regexp-in-string " +" "\\s-+" (regexp-quote x) t t))
 		targets
 		"\\|")
-	       "\\)")))
+	       "\\)\\(?:$\\|[^[:alnum:]]\\)")))
 
 (defun org-activate-tags (limit)
   (if (re-search-forward (org-re "^\\*+.*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \r\n]") limit t)

+ 3 - 4
testing/lisp/test-org-element.el

@@ -1336,12 +1336,11 @@ e^{i\\pi}+1=0
   (should
    (equal
     "radio"
-    (org-test-with-temp-text "A radio link"
+    (org-test-with-temp-text "<<<radio>>>A radio link"
+      (org-update-radio-target-regexp)
       (org-element-property
        :type
-       (org-element-map
-	   (let ((org-target-link-regexp "radio")) (org-element-parse-buffer))
-	   'link 'identity nil t)))))
+       (org-element-map (org-element-parse-buffer) 'link #'identity nil t)))))
   ;; Standard link.
   ;;
   ;; ... with description.