summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-04-14 19:30:17 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-04-14 19:30:17 +0200
commit1a1e47198f685697bd208ad4777cf6b0574c5b36 (patch)
tree4bc19b76551a0b9a32df48b8be7e1dc901af695d
parent1976c02af0c5bbbc49ec9698ea40871093078a09 (diff)
downloadorg-mode-1a1e47198f685697bd208ad4777cf6b0574c5b36.tar.gz
Fix `org-{w3m|eww}-copy-for-org-mode' on blank links
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): * lisp/org-eww.el (org-eww-copy-for-org-mode): Do not error when called on blank links. Reported-by: Bob Newell <bobnewell@bobnewell.net> <http://lists.gnu.org/r/emacs-orgmode/2018-04/msg00255.html>
-rw-r--r--lisp/org-eww.el8
-rw-r--r--lisp/org-w3m.el17
2 files changed, 13 insertions, 12 deletions
diff --git a/lisp/org-eww.el b/lisp/org-eww.el
index 1b6112a..786c6a2 100644
--- a/lisp/org-eww.el
+++ b/lisp/org-eww.el
@@ -140,13 +140,13 @@ the structure of the Org file."
;; concat `org-mode' style url to `return-content'.
(setq return-content
(concat return-content
- (if (stringp link-location)
- ;; hint: link-location is different for form-elements.
+ (if (org-string-nw-p link-location)
+ ;; Hint: link-location is different
+ ;; for form-elements.
(org-make-link-string link-location link-title)
link-title))))
(goto-char temp-position) ; reset point before jump next anchor
- (setq out-bound t) ; for break out `while' loop
- ))
+ (setq out-bound t))) ; for break out `while' loop
;; Add the rest until end of the region to be copied.
(when (< (point) transform-end)
(setq return-content
diff --git a/lisp/org-w3m.el b/lisp/org-w3m.el
index 9690c8e..b2dfc77 100644
--- a/lisp/org-w3m.el
+++ b/lisp/org-w3m.el
@@ -76,13 +76,13 @@ so that it can be yanked into an Org buffer with links working correctly."
(message "Transforming links...")
(save-excursion
(goto-char transform-start)
- (while (and (not out-bound) ; still inside region to copy
+ (while (and (not out-bound) ; still inside region to copy
(not (org-w3m-no-next-link-p))) ; no next link current buffer
;; store current point before jump next anchor
(setq temp-position (point))
;; move to next anchor when current point is not at anchor
(or (get-text-property (point) 'w3m-href-anchor) (org-w3m-get-next-link-start))
- (if (<= (point) transform-end) ; if point is inside transform bound
+ (if (<= (point) transform-end) ; if point is inside transform bound
(progn
;; get content between two links.
(if (> (point) temp-position)
@@ -95,12 +95,13 @@ so that it can be yanked into an Org buffer with links working correctly."
(setq link-title (buffer-substring (point)
(org-w3m-get-anchor-end)))
;; concat Org style url to `return-content'.
- (setq return-content (concat return-content
- (org-make-link-string
- link-location link-title))))
- (goto-char temp-position) ; reset point before jump next anchor
- (setq out-bound t) ; for break out `while' loop
- ))
+ (setq return-content
+ (concat return-content
+ (if (org-string-nw-p link-location)
+ (org-make-link-string link-location link-title)
+ link-title))))
+ (goto-char temp-position) ; reset point before jump next anchor
+ (setq out-bound t))) ; for break out `while' loop
;; add the rest until end of the region to be copied
(if (< (point) transform-end)
(setq return-content