all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Seweryn Kokot <sewkokot@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: how to insert single quotes around a command?
Date: Fri, 31 Oct 2008 15:33:56 +0100	[thread overview]
Message-ID: <87y704ltpn.fsf@poczta.po.opole.pl> (raw)
In-Reply-To: 490AFDB8.7030703@gmx.at

martin rudalics <rudalics@gmx.at> writes:

>> 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

Thank you for this very useful function! It took me some time to understand how
to use  this function  ;-), because invoking it by M-x `insert-hyphen-or-two'
inserts 
 character
-- 
regards,
Seweryn





  reply	other threads:[~2008-10-31 14:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-31 12:44 how to insert single quotes around a command? martin rudalics
2008-10-31 14:33 ` Seweryn Kokot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-10-31 21:42 martin rudalics
2008-10-31 21:42 martin rudalics
     [not found] <mailman.2562.1225457196.25473.help-gnu-emacs@gnu.org>
2008-10-31 20:09 ` Barry Margolin
2008-10-31 10:06 Seweryn Kokot
2008-10-31 18:30 ` Ian Eure
2008-10-31 20:22   ` Seweryn Kokot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y704ltpn.fsf@poczta.po.opole.pl \
    --to=sewkokot@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.