all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: sewkokot@gmail.com
Cc: help-gnu-emacs@gnu.org
Subject: Re: how to insert single quotes around a command?
Date: Fri, 31 Oct 2008 13:44:40 +0100	[thread overview]
Message-ID: <490AFDB8.7030703@gmx.at> (raw)

 > 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





             reply	other threads:[~2008-10-31 12:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-31 12:44 martin rudalics [this message]
2008-10-31 14:33 ` how to insert single quotes around a command? Seweryn Kokot
  -- 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=490AFDB8.7030703@gmx.at \
    --to=rudalics@gmx.at \
    --cc=help-gnu-emacs@gnu.org \
    --cc=sewkokot@gmail.com \
    /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.