all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to complete \] when I input \[ .
@ 2008-08-16 13:09 xiaopeng hu
  2008-08-16 13:15 ` David Hansen
  0 siblings, 1 reply; 8+ messages in thread
From: xiaopeng hu @ 2008-08-16 13:09 UTC (permalink / raw)
  To: help-gnu-emacs

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

When I input \[ , how to complete \] and put point at middle?

Thanks

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

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

* Re: How to complete \] when I input \[ .
  2008-08-16 13:09 How to complete \] when I input \[ xiaopeng hu
@ 2008-08-16 13:15 ` David Hansen
  2008-08-16 14:00   ` xiaopeng hu
       [not found]   ` <mailman.16899.1218895239.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: David Hansen @ 2008-08-16 13:15 UTC (permalink / raw)
  To: help-gnu-emacs

On Sat, 16 Aug 2008 21:09:46 +0800 xiaopeng hu wrote:

> When I input \[ , how to complete \] and put point at middle?
>

Should work:

(global-set-key (kbd "[") #'insert-pair)

David





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

* Re: How to complete \] when I input \[ .
  2008-08-16 13:15 ` David Hansen
@ 2008-08-16 14:00   ` xiaopeng hu
  2008-08-16 14:55     ` Thierry Volpiatto
                       ` (2 more replies)
       [not found]   ` <mailman.16899.1218895239.18990.help-gnu-emacs@gnu.org>
  1 sibling, 3 replies; 8+ messages in thread
From: xiaopeng hu @ 2008-08-16 14:00 UTC (permalink / raw)
  To: help-gnu-emacs

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

I mean \[ \].  thanks

2008/8/16 David Hansen <david.hansen@gmx.net>

> On Sat, 16 Aug 2008 21:09:46 +0800 xiaopeng hu wrote:
>
> > When I input \[ , how to complete \] and put point at middle?
> >
>
> Should work:
>
> (global-set-key (kbd "[") #'insert-pair)
>
> David
>
>
>
>

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

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

* Re: How to complete \] when I input \[ .
  2008-08-16 14:00   ` xiaopeng hu
@ 2008-08-16 14:55     ` Thierry Volpiatto
  2008-08-16 15:46     ` David Hansen
       [not found]     ` <mailman.16901.1218898721.18990.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 8+ messages in thread
From: Thierry Volpiatto @ 2008-08-16 14:55 UTC (permalink / raw)
  To: xiaopeng hu; +Cc: help-gnu-emacs

"xiaopeng hu" <huxiaopengstat@gmail.com> writes:

> I mean \[ \].  thanks
>
> 2008/8/16 David Hansen <david.hansen@gmx.net>
>
>> On Sat, 16 Aug 2008 21:09:46 +0800 xiaopeng hu wrote:
>>
>> > When I input \[ , how to complete \] and put point at middle?
>> >
>>
>> Should work:
>>
>> (global-set-key (kbd "[") #'insert-pair)
>>
>> David

,----
| (defun insert-second-hook ()
|   (interactive)
|   (insert "\[\\]")
|   (goto-char (- (point) 2)))
| (global-set-key (kbd "\[") 'insert-second-hook)
`----

-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France




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

* Re: How to complete \] when I input \[ .
  2008-08-16 14:00   ` xiaopeng hu
  2008-08-16 14:55     ` Thierry Volpiatto
@ 2008-08-16 15:46     ` David Hansen
       [not found]     ` <mailman.16901.1218898721.18990.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 8+ messages in thread
From: David Hansen @ 2008-08-16 15:46 UTC (permalink / raw)
  To: help-gnu-emacs

On Sat, 16 Aug 2008 22:00:35 +0800 xiaopeng hu wrote:

> I mean \[ \].  thanks
>

(defun dh-escaped-bracket-pair ()
  (interactive)
  (if (eq ?\\ (char-before))
      (progn
        (insert "[")
        (save-excursion
          (insert "\\]")))
    (self-insert-command 1)))


(global-set-key (kbd "[") #'dh-escaped-bracket-pair)





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

* Re: How to complete \] when I input \[ .
       [not found]   ` <mailman.16899.1218895239.18990.help-gnu-emacs@gnu.org>
@ 2008-08-16 15:56     ` Chat
  0 siblings, 0 replies; 8+ messages in thread
From: Chat @ 2008-08-16 15:56 UTC (permalink / raw)
  To: help-gnu-emacs

"xiaopeng hu" <huxiaopengstat@gmail.com> writes:

> I mean \[ \].  thanks2008/8/16 David Hansen <span dir="ltr"><mailto:david.hansen@gmx.net></span>
> On Sat, 16 Aug 2008 21:09:46 +0800 xiaopeng hu wrote:
>
>> When I input \[ , how to complete \] and put point at middle?
>>
>
> Should work:
>
> (global-set-key (kbd "[") #&#39;insert-pair)
>
> David

I find this kind of behavior irritating when editing existing code.
Have you looked at expand package? Seems to do it only when there is nothing
else on the line following point.


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

* Re: How to complete \] when I input \[ .
       [not found]     ` <mailman.16901.1218898721.18990.help-gnu-emacs@gnu.org>
@ 2008-09-15  2:38       ` David Combs
  2008-09-15  5:57         ` Thierry Volpiatto
  0 siblings, 1 reply; 8+ messages in thread
From: David Combs @ 2008-09-15  2:38 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.16901.1218898721.18990.help-gnu-emacs@gnu.org>,
Thierry Volpiatto  <thierry.volpiatto@gmail.com> wrote:
>"xiaopeng hu" <huxiaopengstat@gmail.com> writes:
>
>> I mean \[ \].  thanks
>>
>> 2008/8/16 David Hansen <david.hansen@gmx.net>
>>
>>> On Sat, 16 Aug 2008 21:09:46 +0800 xiaopeng hu wrote:
>>>
>>> > When I input \[ , how to complete \] and put point at middle?
>>> >
>>>
>>> Should work:
>>>
>>> (global-set-key (kbd "[") #'insert-pair)
>>>
>>> David
>
>,----
>| (defun insert-second-hook ()
>|   (interactive)
>|   (insert "\[\\]")
>|   (goto-char (- (point) 2)))
>| (global-set-key (kbd "\[") 'insert-second-hook)
>`----
>
>-- 
>A + Thierry Volpiatto
>Location: Saint-Cyr-Sur-Mer - France

If you're got time, please briefly explain how it works, what it does, etc.

Thanks!

David






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

* Re: How to complete \] when I input \[ .
  2008-09-15  2:38       ` David Combs
@ 2008-09-15  5:57         ` Thierry Volpiatto
  0 siblings, 0 replies; 8+ messages in thread
From: Thierry Volpiatto @ 2008-09-15  5:57 UTC (permalink / raw)
  To: David Combs; +Cc: help-gnu-emacs

dkcombs@panix.com (David Combs) writes:

> In article <mailman.16901.1218898721.18990.help-gnu-emacs@gnu.org>,
> Thierry Volpiatto  <thierry.volpiatto@gmail.com> wrote:
>>"xiaopeng hu" <huxiaopengstat@gmail.com> writes:
>>
>>> I mean \[ \].  thanks
>>>
>>> 2008/8/16 David Hansen <david.hansen@gmx.net>
>>>
>>>> On Sat, 16 Aug 2008 21:09:46 +0800 xiaopeng hu wrote:
>>>>
>>>> > When I input \[ , how to complete \] and put point at middle?
>>>> >
>>>>
>>>> Should work:
>>>>
>>>> (global-set-key (kbd "[") #'insert-pair)
>>>>
>>>> David
>>
>>,----
>>| (defun insert-second-hook ()
>>|   (interactive)
>>|   (insert "\[\\]")
>>|   (goto-char (- (point) 2)))
>>| (global-set-key (kbd "\[") 'insert-second-hook)
>>`----
>>
>>-- 
>>A + Thierry Volpiatto
>>Location: Saint-Cyr-Sur-Mer - France
>
> If you're got time, please briefly explain how it works, what it does, etc.

If i remember OP wanted completion on \[ with \] with the "\" included
thats why there is \ in insert.
This version complete the "[" with "]" and put point between the [].

,----[ insert pair of [] ]
| (defun insert-second-hook ()
|   (interactive)
|   (insert "[]")
|   (goto-char (- (point) 1)))
| (global-set-key (kbd "\[") 'insert-second-hook)
`----

when you press key [ it insert the two [] and then go back one char.
Note that is a very simple code and can be much better, look at
pair-mode.el.
Note also you can set key [ locally for a special mode with
`define-key' instead of setting it globally with `global-set-key'.

Personnaly i don't like completion on pairs so i don't use that :)

-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France




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

end of thread, other threads:[~2008-09-15  5:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-16 13:09 How to complete \] when I input \[ xiaopeng hu
2008-08-16 13:15 ` David Hansen
2008-08-16 14:00   ` xiaopeng hu
2008-08-16 14:55     ` Thierry Volpiatto
2008-08-16 15:46     ` David Hansen
     [not found]     ` <mailman.16901.1218898721.18990.help-gnu-emacs@gnu.org>
2008-09-15  2:38       ` David Combs
2008-09-15  5:57         ` Thierry Volpiatto
     [not found]   ` <mailman.16899.1218895239.18990.help-gnu-emacs@gnu.org>
2008-08-16 15:56     ` Chat

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.