From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: rvclayton@verizon.net (R. Clayton) Newsgroups: gmane.emacs.help Subject: Re: How to create a function to italicize in latex in emacs? Date: Wed, 27 Jul 2011 23:54:22 -0400 Message-ID: <874o2712mp.fsf@UlanBator.myhome.westell.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1311825759 22721 80.91.229.12 (28 Jul 2011 04:02:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 28 Jul 2011 04:02:39 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 28 06:02:36 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QmHnv-0002KZ-RC for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Jul 2011 06:02:35 +0200 Original-Received: from localhost ([::1]:49825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmHnv-0006zd-Co for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Jul 2011 00:02:35 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:36611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmHnq-0006zL-WD for help-gnu-emacs@gnu.org; Thu, 28 Jul 2011 00:02:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QmHnq-0004RN-28 for help-gnu-emacs@gnu.org; Thu, 28 Jul 2011 00:02:30 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:56242) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmHnp-0004RF-SB for help-gnu-emacs@gnu.org; Thu, 28 Jul 2011 00:02:30 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QmHno-0002Jz-KG for help-gnu-emacs@gnu.org; Thu, 28 Jul 2011 06:02:28 +0200 Original-Received: from pool-108-5-150-85.nwrknj.fios.verizon.net ([108.5.150.85]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 28 Jul 2011 06:02:28 +0200 Original-Received: from rvclayton by pool-108-5-150-85.nwrknj.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 28 Jul 2011 06:02:28 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 31 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: pool-108-5-150-85.nwrknj.fios.verizon.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:ZJVErR95VYurJ0KAbKy2e5R4ciU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81823 Archived-At: I would like to italicize a word in latex in emacs automatically. Instead of write \textit{word}, I would like to select the "word" and then write M-x and it's added textit around the word. Do I have to create a lisp function in .emacs? How do I do that? This is how I do it: (defun latex-surround-word (before after) "Add the given prefix and suffix to the word at point." (or (looking-at "\\<") (search-backward-regexp "\\<")) (insert before) (search-forward-regexp "\\>") (insert after)) (defun latex-ital-word () "Set the word at point in italics." (interactive) (latex-surround-word "{\\it " "\\/}")) (define-key latex-mode-map "\C-cfi" 'latex-ital-word) Put those and similar in a file and load the file as part of the latex mode hook.