* Uniquely url-ify sentences?
@ 2011-03-05 19:38 Ross A. Laird
2011-03-07 21:54 ` Jason Dunsmore
2011-03-17 9:50 ` Bastien
0 siblings, 2 replies; 4+ messages in thread
From: Ross A. Laird @ 2011-03-05 19:38 UTC (permalink / raw)
To: emacs-orgmode
Although most users of orgmode and emacs seem to be members of the
programming world, a few professional writers also use these tools (and
I cannot imagine why everyone else uses Word...). As a writer and
non-programmer, I have a task that is probably very simple for a
programmer but seems a bit complicated to me. It's something that could
be done in many different ways, but I'd like to do it in orgmode/emacs with the
simplest possible workflow. Here's the situation:
I have a narrative manuscript. I'd like to post one sentence from this
manuscript every day as a tweet with a link back to the sentence (and
then show the previous and next paragraphs of the manuscript on the page
that is linked from the tweet). The manuscript is in an org file (I also
have a version in LaTeX). Given my limited knowledge, I imagine I
could do this with a macro in emacs:
1. From the beginning of the first sentence, search to dot-then-space
(or zap to dot, or something similar).
2. Insert line break (or move sentence into another buffer).
3. Go to end of sentence and insert unique link anchor (main url plus
incremented line number or part of sentence or something similar).
4. Use the list of sentences with links as daily tweets.
This type of macro workflow would probably work, with some fiddling, but
I find that with macros there is always something to mess up the
workflow at some point. For example, in this case, there may be some
situation in which dot-space does not define the sentence precisely
(ellipses, say, or a sentence that ends with an exclamation). I predict
this will happen (it seems to happen every time with macros), and I
wonder if I should try some other approach.
What do you think might be the best way to do this? Is there a way to
uniquely url-ify sentences? If so, I could just create a second version
of the manuscript and url-ify the whole thing in one step. All I really
need is to create a unique anchor (#) for each sentence. The main url
can be consistent through the whole thing.
Feedback and suggestions most welcome.
Ross
--
Ross A. Laird, PhD
www.rosslaird.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Uniquely url-ify sentences?
@ 2011-03-05 19:40 Ross A. Laird
0 siblings, 0 replies; 4+ messages in thread
From: Ross A. Laird @ 2011-03-05 19:40 UTC (permalink / raw)
To: emacs-orgmode
Although most users of orgmode and emacs seem to be members of the
programming world, a few professional writers also use these tools (and
I cannot imagine why everyone else uses Word...). As a writer and
non-programmer, I have a task that is probably very simple for a
programmer but seems a bit complicated to me. It's something that could
be done in many different ways, but I'd like to do it in orgmode/emacs with the
simplest possible workflow. Here's the situation:
I have a narrative manuscript. I'd like to post one sentence from this
manuscript every day as a tweet with a link back to the sentence (and
then show the previous and next paragraphs of the manuscript on the page
that is linked from the tweet). The manuscript is in an org file (I also
have a version in LaTeX). Given my limited knowledge, I imagine I
could do this with a macro in emacs:
1. From the beginning of the first sentence, search to dot-then-space
(or zap to dot, or something similar).
2. Insert line break (or move sentence into another buffer).
3. Go to end of sentence and insert unique link anchor (main url plus
incremented line number or part of sentence or something similar).
4. Use the list of sentences with links as daily tweets.
This type of macro workflow would probably work, with some fiddling, but
I find that with macros there is always something to mess up the
workflow at some point. For example, in this case, there may be some
situation in which dot-space does not define the sentence precisely
(ellipses, say, or a sentence that ends with an exclamation). I predict
this will happen (it seems to happen every time with macros), and I
wonder if I should try some other approach.
What do you think might be the best way to do this? Is there a way to
uniquely url-ify sentences? If so, I could just create a second version
of the manuscript and url-ify the whole thing in one step. All I really
need is to create a unique anchor (#) for each sentence. The main url
can be consistent through the whole thing.
Feedback and suggestions most welcome.
Ross
--
Ross A. Laird, PhD
www.rosslaird.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Uniquely url-ify sentences?
2011-03-05 19:38 Uniquely url-ify sentences? Ross A. Laird
@ 2011-03-07 21:54 ` Jason Dunsmore
2011-03-17 9:50 ` Bastien
1 sibling, 0 replies; 4+ messages in thread
From: Jason Dunsmore @ 2011-03-07 21:54 UTC (permalink / raw)
To: Ross A. Laird; +Cc: emacs-orgmode
ross@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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Uniquely url-ify sentences?
2011-03-05 19:38 Uniquely url-ify sentences? Ross A. Laird
2011-03-07 21:54 ` Jason Dunsmore
@ 2011-03-17 9:50 ` Bastien
1 sibling, 0 replies; 4+ messages in thread
From: Bastien @ 2011-03-17 9:50 UTC (permalink / raw)
To: Ross A. Laird; +Cc: emacs-orgmode
Hi Ross,
ross@rosslaird.com (Ross A. Laird) writes:
> Feedback and suggestions most welcome.
Jason replied -- did you get his code?
Thanks for confirming,
--
Bastien
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-17 9:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-05 19:38 Uniquely url-ify sentences? Ross A. Laird
2011-03-07 21:54 ` Jason Dunsmore
2011-03-17 9:50 ` Bastien
-- strict thread matches above, loose matches on Subject: below --
2011-03-05 19:40 Ross A. Laird
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).