From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: how to insert single quotes around a command? Date: Fri, 31 Oct 2008 16:09:35 -0400 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1225485726 20256 80.91.229.12 (31 Oct 2008 20:42:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 Oct 2008 20:42:06 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 31 21:43:08 2008 connect(): Connection refused Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kw0ph-0004bD-Pi for geh-help-gnu-emacs@m.gmane.org; Fri, 31 Oct 2008 21:43:02 +0100 Original-Received: from localhost ([127.0.0.1]:42251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kw0ob-0005LN-6Y for geh-help-gnu-emacs@m.gmane.org; Fri, 31 Oct 2008 16:41:53 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!feeder.news-service.com!feeder.news-service.com!85.214.105.209.MISMATCH!news.eternal-september.org!news.motzarella.org!motzarella.org!registered.motzarella.org!barmar Original-Newsgroups: gnu.emacs.help Original-Lines: 44 Original-X-Trace: registered.motzarella.org U2FsdGVkX1+imnuiha4Y9n+bp9Kg9+SMSYVq2jrmFrZMeYdwdfSLdvJAV2xmRwWmXKvLvQ0VkRhwcZ/bTmLtO+rz24tGwn6RlsgdUFL13EYlF3xcyOfmnb9zwky6iatzasU3fbMzy/xtHSy45ya2EQ== Original-X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers Original-NNTP-Posting-Date: Fri, 31 Oct 2008 20:09:35 +0000 (UTC) X-Auth-Sender: U2FsdGVkX1/DBM3pIGhBba/XiQOQH5OiDt0f+wKI3VU= Cancel-Lock: sha1:Okr+RxOKYGlzjWcoRxTcGDPFE0Q= User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Mail-Copies-To: nobody Original-Xref: news.stanford.edu gnu.emacs.help:163966 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:59309 Archived-At: In article , martin rudalics wrote: > > Many times when I write doc strings for elisp functions I forget to insert > > single-quotes around commands or variables like `a-command' or insert it > > wrong like 'a-command'. Is there a function or keybinding to do it > > properly? Maybe a function which enclose a selected command with > > single-quotes? > > I'm using: > > (defun insert-hyphen-or-two () Why is it called "insert-hyphen-or-two" when it inserts quotes, not hyphens? > (interactive) > (cond > ((or (bolp) (not (looking-back "'"))) > ;; insert just one ' > (self-insert-command 1)) > ((save-excursion > (backward-char) > ;; Skip symbol backwards. > (and (not (zerop (skip-syntax-backward "w_"))) > (not (looking-back "`")) > (or (insert-and-inherit "`") t)))) > (t > ;; insert `' around following symbol > (delete-backward-char 1) > (unless (looking-back "`") (insert-and-inherit "`")) > (save-excursion > (skip-syntax-forward "w_") > (unless (looking-at "'") (insert-and-inherit "'")))))) > > (global-set-key [39] 'insert-hyphen-or-two) > > martin -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***