help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Putting a – on both sides of a region


From: Deniz Dogan
Subject: Re: Putting a – on both sides of a region
Date: Wed, 30 Mar 2011 14:55:52 +0200

2011/3/30 Cecil Westerhof <address@hidden>:
> I use a – –en dash– for sub sentences. What I would like is that when
> I insert this character and I have selected a region, that the en dash
> is inserted before the region and after it. Is this hard to implement?
>

I think it depends on how you insert this character. Here is a crude
command which does it for you:

(defun insert-or-wrap (string)
  (interactive "*")
  (if (not (use-region-p))
      (insert string)
    (let ((beg (region-beginning))
          (end (region-end)))
    (goto-char beg)
    (insert string)
    (goto-char (+ (length string) end))
    (insert string))))

So (insert-or-wrap "heh") wraps the region in "heh" if the region is
active, otherwise it simply inserts "heh" at point.

-- 
Deniz Dogan



reply via email to

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