[O] Word under cursor to internal link

2014-12-18 Thread Leu Zhe
You can use the function below to make it.
But in order to replace it rightly, you need to put you cursor inside the
word or at the beginning of the word.

(defun word-to-link ()
  (interactive)
  (let ((word (thing-at-point 'word)))
(forward-word)
(kill-word -1)
(insert (format "[[%s]]" word

Hope it helps. And any improvement will be welcome.


Re: [O] Word under cursor to internal link

2014-12-18 Thread John Kitchin

Something like this seems to do approximately what you want:

#+BEGIN_SRC emacs-lisp
(defun word-to-link ()
  (interactive)
  (save-excursion
(let (start end word)
  (backward-word)  
  (setq start (point))
  (forward-word)
  (setq end (point))
  (setq word (buffer-substring start end))
  (setf (buffer-substring start end)
(format "[[%s]]" word)
#+END_SRC

Chaitanya Krishna  writes:

> Hello there,
>
> Is there a shortcut to change word under cursor to an internal link?
> Basically it is a pain trying to surround with two braces all the
> time!
>
> C-c C-l does not prompt me to create an internal link.
>
> Best regards,
> Chai
>

-- 
---
John Kitchin
Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu



[O] Word under cursor to internal link

2014-12-18 Thread Chaitanya Krishna
Hello there,

Is there a shortcut to change word under cursor to an internal link?
Basically it is a pain trying to surround with two braces all the time!

C-c C-l does not prompt me to create an internal link.

Best regards,
Chai