unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: how to insert single quotes around a command?
@ 2008-10-31 12:44 martin rudalics
  2008-10-31 14:33 ` Seweryn Kokot
  0 siblings, 1 reply; 8+ messages in thread
From: martin rudalics @ 2008-10-31 12:44 UTC (permalink / raw)
  To: sewkokot; +Cc: help-gnu-emacs

 > 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





^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: how to insert single quotes around a command?
@ 2008-10-31 21:42 martin rudalics
  0 siblings, 0 replies; 8+ messages in thread
From: martin rudalics @ 2008-10-31 21:42 UTC (permalink / raw)
  To: barmar; +Cc: help-gnu-emacs

 > Why is it called "insert-hyphen-or-two" when it inserts quotes, not
 > hyphens?

I must have been drinking when I wrote that ;-)

martin





^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: how to insert single quotes around a command?
@ 2008-10-31 21:42 martin rudalics
  0 siblings, 0 replies; 8+ messages in thread
From: martin rudalics @ 2008-10-31 21:42 UTC (permalink / raw)
  To: sewkokot; +Cc: help-gnu-emacs

 > It took me some time to understand how
 > to use  this function  ;-), because invoking it by M-x `insert-hyphen-or-two'
 > inserts
 >  character

Sorry, I'll try to be less cryptic next time.  I use this function
because most often I first expand the name of the symbol and then
hitting "'" twice means I don't have to think about an extra command to
do what I want.  It doesn't work in c-mode because till now I was too
lazy to define a separate symbol-table for this.

martin





^ permalink raw reply	[flat|nested] 8+ messages in thread
[parent not found: <mailman.2562.1225457196.25473.help-gnu-emacs@gnu.org>]
* how to insert single quotes around a command?
@ 2008-10-31 10:06 Seweryn Kokot
  2008-10-31 18:30 ` Ian Eure
  0 siblings, 1 reply; 8+ messages in thread
From: Seweryn Kokot @ 2008-10-31 10:06 UTC (permalink / raw)
  To: help-gnu-emacs

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?

Thanks in advance.
-- 
regards,
Seweryn





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-10-31 21:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-31 12:44 how to insert single quotes around a command? martin rudalics
2008-10-31 14:33 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).