|
From: | martin rudalics |
Subject: | Re: how to insert single quotes around a command? |
Date: | Fri, 31 Oct 2008 13:44:40 +0100 |
User-agent: | Thunderbird 2.0.0.16 (Windows/20080708) |
> 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
[Prev in Thread] | Current Thread | [Next in Thread] |