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: Seweryn Kokot
Subject: Re: how to insert single quotes around a command?
Date: Fri, 31 Oct 2008 21:22:02 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Ian Eure <ian@digg.com> writes:

> On Oct 31, 2008, at 3:06 AM, Seweryn Kokot wrote:
>
>> Hello,
>>
>> 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?
>>
>
> Sounds like you want insert-pair:
> (define-key (current-global-map) "\M-'" 'insert-pair)
> (define-key (current-global-map) "\C-c`" 'insert-pair)
>
> Which makes M-' insert a pair of single quotes, and C-c ` insert `'.
> Then you can do M-1 M-' or M-1 C-c ` to enclose the sexp following
> point in the correct quotes.
>
> insert-pair is super handy, I use M-(sym) for () "" [] etc.
>
>  - Ian


Thanks for inspiration. I also found `skeleton-pair-insert-maybe'
function from skeleton library 

(setq skeleton-pair t)
(global-set-key "(" 'skeleton-pair-insert-maybe) % ()
(global-set-key "[" 'skeleton-pair-insert-maybe) % []
(global-set-key "{" 'skeleton-pair-insert-maybe) % ""
(global-set-key "\"" 'skeleton-pair-insert-maybe) % ''
(global-set-key "`" 'skeleton-pair-insert-maybe) % `'

This inserts pairs of chars and also enclose a region. Now I have at
least three solutions and will see with time what fits me better.

-- 
regards,
Seweryn





reply via email to

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