From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Chaitanya Krishna <icymist@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Word under cursor to internal link
Date: Thu, 18 Dec 2014 20:08:14 -0500 [thread overview]
Message-ID: <m2r3vwxx8h.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <CADNPybMb_D0sbFYmrdopTTmUyHsLjf=2v3mMWtdsErqpS1wcqg@mail.gmail.com> (Chaitanya Krishna's message of "Fri, 19 Dec 2014 01:31:34 +0100")
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 <icymist@gmail.com> 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
next prev parent reply other threads:[~2014-12-19 1:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-19 0:31 Word under cursor to internal link Chaitanya Krishna
2014-12-19 1:08 ` John Kitchin [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-12-19 1:45 Leu Zhe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2r3vwxx8h.fsf@andrew.cmu.edu \
--to=jkitchin@andrew.cmu.edu \
--cc=emacs-orgmode@gnu.org \
--cc=icymist@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).