aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-02-14 02:15:07 -0500
committerKyle Meyer <kyle@kyleam.com>2015-02-14 02:15:07 -0500
commitaf3a3a69f63d138477201e742fb34f0e2f445900 (patch)
treec81350ee11de52673262be4d46776ceac0bbbf3c
parentcb6c7d8b3feeb869dc7218f9686461d2ede3aaac (diff)
downloadorg-link-edit-af3a3a69f63d138477201e742fb34f0e2f445900.tar.gz
Trim only whitespace from slurped strings
-rw-r--r--org-link-edit.el4
-rw-r--r--test-org-link-edit.el16
2 files changed, 18 insertions, 2 deletions
diff --git a/org-link-edit.el b/org-link-edit.el
index 180e289..b670f29 100644
--- a/org-link-edit.el
+++ b/org-link-edit.el
@@ -127,7 +127,7 @@ If N is negative, slurp leading words instead of trailing words."
(let ((slurped (buffer-substring-no-properties end (point))))
(setq slurped (replace-regexp-in-string "\n" " " slurped))
(when (and (= (length desc) 0)
- (string-match "^\\W*\\(\\w.*\\)" slurped))
+ (string-match "^\\s-+\\(.*\\)" slurped))
(setq slurped (match-string 1 slurped)))
(setq desc (concat desc slurped)
end (+ end (length slurped)))
@@ -167,7 +167,7 @@ words."
(point)))
(let ((slurped (buffer-substring-no-properties (point) beg)))
(when (and (= (length desc) 0)
- (string-match "\\(.*\\w\\)\\W*$" slurped))
+ (string-match "\\(.*\\)\\s-+$" slurped))
(setq slurped (match-string 1 slurped)))
(setq slurped (replace-regexp-in-string "\n" " " slurped))
(setq desc (concat slurped desc)
diff --git a/test-org-link-edit.el b/test-org-link-edit.el
index b778dbd..53c4d87 100644
--- a/test-org-link-edit.el
+++ b/test-org-link-edit.el
@@ -105,6 +105,14 @@ website is"
"\[\[http://orgmode.org/\]\]website"
(org-link-edit-forward-slurp-word 1)
(buffer-string))))
+ ;; Slurp word beginning with non-word, non-whitespace character.
+ (should
+ (string=
+ "\[\[http://orgmode.org/\]\[-website\]\]"
+ (org-test-with-temp-text
+ "\[\[http://orgmode.org/\]\]-website"
+ (org-link-edit-forward-slurp-word 1)
+ (buffer-string))))
;; Slurp beyond the number of present words.
(should-error
(org-test-with-temp-text
@@ -172,6 +180,14 @@ website is"
"Here is<point>\[\[http://orgmode.org/\]\] Org's website"
(org-link-edit-backward-slurp-word 1)
(buffer-string))))
+ ;; Slurp word ending with non-word, non-whitespace character.
+ (should
+ (string=
+ "Here \[\[http://orgmode.org/\]\[is-\]\] Org's website"
+ (org-test-with-temp-text
+ "Here is-<point>\[\[http://orgmode.org/\]\] Org's website"
+ (org-link-edit-backward-slurp-word 1)
+ (buffer-string))))
;; Slurp beyond the number of present words.
(should-error
(org-test-with-temp-text