The rst-mode for emacs is very useful but it still lacks some basic features such automatically insert reference links. I wrote my first piece of "real" elisp code to do this, but consider that is only very few lines and probably someone wrote this better.
In the future I plan to ask integration into the mainstream rst-mode.el but for now just copy this into your .emacs/init.el startup file; then try selecting a word (or a phrase) and call the insert-rst-reference function (M-x insert-rst-reference).
(defun insert-rst-reference (url) "Inserts footnote link in rst format" (interactive "sURL: ") (if (use-region-p) (let ( (beg (region-beginning)) (end (region-end)) (name (buffer-substring-no-properties (region-beginning) (region-end)))) (goto-char beg) (insert "`") (goto-char end) (forward-char) (insert "`_") (deactivate-mark) (save-excursion (goto-char (point-max)) (newline) (insert ".. _" name ": " url)))) (error "No region selected!")) (global-set-key (kbd "C-c l") 'insert-rst-reference)
I binded that to C-c l. Next task is to write a more complex function to autodetect if the cursor is on a word, a selction or something else and behave accordingly.