From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.help Subject: Re: how to insert single quotes around a command? Date: Fri, 31 Oct 2008 13:44:40 +0100 Message-ID: <490AFDB8.7030703@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1225457243 16749 80.91.229.12 (31 Oct 2008 12:47:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 Oct 2008 12:47:23 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: sewkokot@gmail.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 31 13:48:25 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 1KvtQ5-0004cM-Gg for geh-help-gnu-emacs@m.gmane.org; Fri, 31 Oct 2008 13:48:06 +0100 Original-Received: from localhost ([127.0.0.1]:56176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KvtOx-0001yA-Sk for geh-help-gnu-emacs@m.gmane.org; Fri, 31 Oct 2008 08:46:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KvtOc-0001xK-Tf for help-gnu-emacs@gnu.org; Fri, 31 Oct 2008 08:46:34 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KvtOb-0001vb-9t for help-gnu-emacs@gnu.org; Fri, 31 Oct 2008 08:46:34 -0400 Original-Received: from [199.232.76.173] (port=48514 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KvtOb-0001vX-6t for help-gnu-emacs@gnu.org; Fri, 31 Oct 2008 08:46:33 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]:60350) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1KvtOa-0000x8-1r for help-gnu-emacs@gnu.org; Fri, 31 Oct 2008 08:46:32 -0400 Original-Received: (qmail invoked by alias); 31 Oct 2008 12:46:19 -0000 Original-Received: from 62-47-55-41.adsl.highway.telekom.at (EHLO [62.47.55.41]) [62.47.55.41] by mail.gmx.net (mp017) with SMTP; 31 Oct 2008 13:46:19 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1+UQcVv9qSU8Sj/itjvieGsLk5CB8VdIvtSskTiZG wvo6hisqHEHRDb User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) Original-References: 87ej1x3wp5.fsf@poczta.po.opole.pl X-Y-GMX-Trusted: 0 X-FuHaFi: 0.68 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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:59286 Archived-At: > 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 () (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