[Ilugc] adding brackets in emacs

  • From: vijaykumar@xxxxxxxxxxxx (Vijay Kumar)
  • Date: Sat Nov 10 10:09:07 2007

Kenneth Gonsalves wrote:

a common task is adding strings for i18n. Say I have a string - 
mystring. I need to mark it like so:

_("mystring").  What I want to do is: select the string and press a key 
so it will mark it. How is this done in emacs?

The following elisp function will mark the string under cursor with 
_(...). It will not work for one special case in which there is a double 
quotes within the string.

(defun mark-i18n ()
   (interactive)
   (save-excursion
     (search-backward "\"")
     (insert "_(")
     (forward-char 1)
     (search-forward "\"")
     (insert ")")))


Put this definition in your .emacs and bind the function to the key of 
your choice.

Regards,
Vijay

Other related posts: