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: Le Wang
Subject: Re: Putting a – on both sides of a region
Date: Wed, 30 Mar 2011 21:22:31 +0800

On Wed, Mar 30, 2011 at 8:17 PM, Cecil Westerhof <address@hidden> wrote:
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?

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

(defun wrap-region-maybe (arg)
  "wrap region in char or run `self-insert-command' if no region"
  (interactive "*p")
  (if (use-region-p)
      (let ((r-beg (region-beginning))
            (r-end (+ arg (region-end))))
        (goto-char r-beg)
        (self-insert-command arg)
        (goto-char r-end)
        (self-insert-command arg))
    (self-insert-command arg)))

--
Le

reply via email to

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