help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to insert single quotes around a command?


From: Barry Margolin
Subject: Re: how to insert single quotes around a command?
Date: Fri, 31 Oct 2008 16:09:35 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <mailman.2562.1225457196.25473.help-gnu-emacs@gnu.org>,
 martin rudalics <rudalics@gmx.at> 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 ***


reply via email to

[Prev in Thread] Current Thread [Next in Thread]