unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Putting a – on both sides of a region
@ 2011-03-30 12:17 Cecil Westerhof
  2011-03-30 12:55 ` Deniz Dogan
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Cecil Westerhof @ 2011-03-30 12:17 UTC (permalink / raw)
  To: help-gnu-emacs

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


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

* Re: Putting a – on both sides of a region
  2011-03-30 12:17 Putting a – on both sides of a region Cecil Westerhof
@ 2011-03-30 12:55 ` Deniz Dogan
  2011-03-30 13:22 ` Le Wang
  2011-03-30 13:54 ` Pascal J. Bourguignon
  2 siblings, 0 replies; 8+ messages in thread
From: Deniz Dogan @ 2011-03-30 12:55 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: help-gnu-emacs

2011/3/30 Cecil Westerhof <Cecil@decebal.nl>:
> 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



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

* Re: Putting a – on both sides of a region
  2011-03-30 12:17 Putting a – on both sides of a region Cecil Westerhof
  2011-03-30 12:55 ` Deniz Dogan
@ 2011-03-30 13:22 ` Le Wang
  2011-03-30 13:54 ` Pascal J. Bourguignon
  2 siblings, 0 replies; 8+ messages in thread
From: Le Wang @ 2011-03-30 13:22 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 810 bytes --]

On Wed, Mar 30, 2011 at 8:17 PM, Cecil Westerhof <Cecil@decebal.nl> 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

[-- Attachment #2: Type: text/html, Size: 1213 bytes --]

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

* Re: Putting a – on both sides of a region
  2011-03-30 12:17 Putting a – on both sides of a region Cecil Westerhof
  2011-03-30 12:55 ` Deniz Dogan
  2011-03-30 13:22 ` Le Wang
@ 2011-03-30 13:54 ` Pascal J. Bourguignon
  2011-03-30 15:06   ` Teemu Likonen
                     ` (2 more replies)
  2 siblings, 3 replies; 8+ messages in thread
From: Pascal J. Bourguignon @ 2011-03-30 13:54 UTC (permalink / raw)
  To: help-gnu-emacs

Cecil Westerhof <Cecil@decebal.nl> writes:

> 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. 

You should not.  Typographically, it's the — em dash that's used for
this purpose.

> Is this hard to implement?

No.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


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

* Re: Putting a – on both sides of a region
  2011-03-30 13:54 ` Pascal J. Bourguignon
@ 2011-03-30 15:06   ` Teemu Likonen
       [not found]   ` <mailman.3.1301497661.5543.help-gnu-emacs@gnu.org>
  2011-03-30 16:51   ` Peter Dyballa
  2 siblings, 0 replies; 8+ messages in thread
From: Teemu Likonen @ 2011-03-30 15:06 UTC (permalink / raw)
  To: Pascal J. Bourguignon; +Cc: help-gnu-emacs

* 2011-03-30 15:54 (+0200), Pascal J. Bourguignon wrote:

> Cecil Westerhof <Cecil@decebal.nl> writes:
>> 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.
>
> You should not. Typographically, it's the — em dash that's used for
> this purpose.

Depends on the language.



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

* Re: Putting a – on both sides of a region
       [not found]   ` <mailman.3.1301497661.5543.help-gnu-emacs@gnu.org>
@ 2011-03-30 15:24     ` rusi
  0 siblings, 0 replies; 8+ messages in thread
From: rusi @ 2011-03-30 15:24 UTC (permalink / raw)
  To: help-gnu-emacs

On Mar 30, 8:06 pm, Teemu Likonen <tliko...@iki.fi> wrote:
> * 2011-03-30 15:54 (+0200), Pascal J. Bourguignon wrote:
>
> > Cecil Westerhof <Ce...@decebal.nl> writes:
> >> 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.
>
> > You should not. Typographically, it's the — em dash that's used for
> > this purpose.
>
> Depends on the language.

No consensus: http://en.wikipedia.org/wiki/Dash#En_dash_versus_em_dash


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

* Re: Putting a – on both sides of a region
  2011-03-30 13:54 ` Pascal J. Bourguignon
  2011-03-30 15:06   ` Teemu Likonen
       [not found]   ` <mailman.3.1301497661.5543.help-gnu-emacs@gnu.org>
@ 2011-03-30 16:51   ` Peter Dyballa
  2011-03-30 19:40     ` Putting a - " Drew Adams
  2 siblings, 1 reply; 8+ messages in thread
From: Peter Dyballa @ 2011-03-30 16:51 UTC (permalink / raw)
  To: Pascal J. Bourguignon; +Cc: help-gnu-emacs


Am 30.03.2011 um 15:54 schrieb Pascal J. Bourguignon:

> You should not.  Typographically, it's the — em dash that's used for
> this purpose.


This is bad US American taste. No European, including the British,  
would do so.

--
Greetings

   Pete

Who the fsck is "General Failure," and why is he reading my disk?




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

* RE: Putting a - on both sides of a region
  2011-03-30 16:51   ` Peter Dyballa
@ 2011-03-30 19:40     ` Drew Adams
  0 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2011-03-30 19:40 UTC (permalink / raw)
  To: 'Peter Dyballa', 'Pascal J. Bourguignon'; +Cc: help-gnu-emacs

> No European, including the British, would do so.

Real Europeans don't consider the British European.
Likewise, real Brits, no doubt.

Jusssst kidding. ;-)




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

end of thread, other threads:[~2011-03-30 19:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-30 12:17 Putting a – on both sides of a region Cecil Westerhof
2011-03-30 12:55 ` Deniz Dogan
2011-03-30 13:22 ` Le Wang
2011-03-30 13:54 ` Pascal J. Bourguignon
2011-03-30 15:06   ` Teemu Likonen
     [not found]   ` <mailman.3.1301497661.5543.help-gnu-emacs@gnu.org>
2011-03-30 15:24     ` rusi
2011-03-30 16:51   ` Peter Dyballa
2011-03-30 19:40     ` Putting a - " Drew Adams

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).