r...@rosslaird.com (Ross A. Laird) writes:

> I'd like to post one sentence from this manuscript every day as a
> tweet with a link back to the sentence

Will this do what you need?

--8<---------------cut here---------------start------------->8---
(defun org-linkify-sentence (url)
  "Converts a sentence to an Org-mode link."
  (interactive "sURL: ")
  (save-excursion
    (forward-char)
    (backward-sentence)
    (push-mark)
    (forward-sentence)
    (kill-region (region-beginning) (region-end))
    (insert "[[" url "][" (first kill-ring) "]]")))
--8<---------------cut here---------------end--------------->8---

Just put the cursor on the sentence and type M-x org-linkify-sentence
RET.  You might want to create a keybinding for it if you use it often:

(define-key org-mode-map "\C-cs" 'org-linkify-sentence)

Also, I'd recommend creating a link abbreviation if you link to the same
site often: http://orgmode.org/org.html#Link-abbreviations

I have a series of custom org-linkify-* functions that I use to convert
various pieces of text to Org-mode links.  I'm still trying to figure
out how they can be generalized to be useful to others.

Regards,
Jason

Reply via email to