all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* keybinding help
@ 2006-05-15 18:46 Ryan Krauss
  2006-05-15 18:51 ` Michaël Cadilhac
  0 siblings, 1 reply; 8+ messages in thread
From: Ryan Krauss @ 2006-05-15 18:46 UTC (permalink / raw)


I know this is a simple question, but I can't seem to find the answer.
 I want to bind a key to insert some text that I am retyping a lot.
How do I do that?  I would like to bind C-c l to insert that text
'\lstinline!'.

Thanks,

Ryan

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

* Re: keybinding help
  2006-05-15 18:46 Ryan Krauss
@ 2006-05-15 18:51 ` Michaël Cadilhac
  2006-05-15 18:59   ` Ryan Krauss
  0 siblings, 1 reply; 8+ messages in thread
From: Michaël Cadilhac @ 2006-05-15 18:51 UTC (permalink / raw)
  Cc: help-gnu-emacs


[-- Attachment #1.1: Type: text/plain, Size: 739 bytes --]

"Ryan Krauss" <ryanlists@gmail.com> writes:

> I know this is a simple question, but I can't seem to find the answer.
> I want to bind a key to insert some text that I am retyping a lot.
> How do I do that?  I would like to bind C-c l to insert that text
> '\lstinline!'.

  The following (not tested) should work :

(global-set-key "\C-cl" (lambda () (interactive) (insert "\\lstinline!")))

  Regards,

-- 
 |      Michaël `Micha' Cadilhac   |   La culture c'est comme la confiture  |
 |         Epita/LRDE Promo 2007   |       c'est meilleur avec du pain.     |
 | http://www.lrde.org/~cadilh_m   |            -- MOI59                    |
 `--  -   JID: micha@amessage.be --'                                   -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

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

* Re: keybinding help
  2006-05-15 18:51 ` Michaël Cadilhac
@ 2006-05-15 18:59   ` Ryan Krauss
  0 siblings, 0 replies; 8+ messages in thread
From: Ryan Krauss @ 2006-05-15 18:59 UTC (permalink / raw)
  Cc: help-gnu-emacs

It does work.  Thank you.

Ryan

On 5/15/06, Michaël Cadilhac <michael.cadilhac@lrde.org> wrote:
> "Ryan Krauss" <ryanlists@gmail.com> writes:
>
> > I know this is a simple question, but I can't seem to find the answer.
> > I want to bind a key to insert some text that I am retyping a lot.
> > How do I do that?  I would like to bind C-c l to insert that text
> > '\lstinline!'.
>
>   The following (not tested) should work :
>
> (global-set-key "\C-cl" (lambda () (interactive) (insert "\\lstinline!")))
>
>   Regards,
>
> --
>  |      Michaël `Micha' Cadilhac   |   La culture c'est comme la confiture  |
>  |         Epita/LRDE Promo 2007   |       c'est meilleur avec du pain.     |
>  | http://www.lrde.org/~cadilh_m   |            -- MOI59                    |
>  `--  -   JID: micha@amessage.be --'                                   -  --'
>
>
>

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

* Re: keybinding help
       [not found] <mailman.1844.1147718776.9609.help-gnu-emacs@gnu.org>
@ 2006-05-15 19:12 ` Maarten Bergvelt
  2006-05-15 21:34   ` Ryan Krauss
  2006-05-15 19:12 ` Tassilo Horn
  2006-05-19 13:54 ` Mathias Dahl
  2 siblings, 1 reply; 8+ messages in thread
From: Maarten Bergvelt @ 2006-05-15 19:12 UTC (permalink / raw)


In article <mailman.1844.1147718776.9609.help-gnu-emacs@gnu.org>, 
Ryan Krauss wrote:
> I know this is a simple question, but I can't seem to find the answer.
>  I want to bind a key to insert some text that I am retyping a lot.
> How do I do that?  I would like to bind C-c l to insert that text
> '\lstinline!'.
Maybe you want check out the section "key-board macros" from the emacs
manual.

-- 
Maarten Bergvelt		

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

* Re: keybinding help
       [not found] <mailman.1844.1147718776.9609.help-gnu-emacs@gnu.org>
  2006-05-15 19:12 ` keybinding help Maarten Bergvelt
@ 2006-05-15 19:12 ` Tassilo Horn
  2006-05-19 13:54 ` Mathias Dahl
  2 siblings, 0 replies; 8+ messages in thread
From: Tassilo Horn @ 2006-05-15 19:12 UTC (permalink / raw)


"Ryan Krauss" <ryanlists@gmail.com> writes:

> I know this is a simple question, but I can't seem to find the answer.
> I want to bind a key to insert some text that I am retyping a lot.
> How do I do that?  I would like to bind C-c l to insert that text
> '\lstinline!'.

I assume you want that in LaTeX-mode, right? Then put something like
that into your ~/.emacs.

,----[ tested and worksforme ]
| (add-hook 'TeX-mode-hook
|           (lambda ()
|             (local-set-key (kbd "C-c l")
|                            (lambda ()
|                              (interactive)
|                              (insert "\\lstinline")))))
| 
| 
`----

Bye,
Tassilo
-- 
The problem with the French is that they dont have a word for
"entrepreneur".                              - George W. Bush

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

* Re: keybinding help
  2006-05-15 19:12 ` keybinding help Maarten Bergvelt
@ 2006-05-15 21:34   ` Ryan Krauss
  2006-05-15 23:39     ` Kevin Rodgers
  0 siblings, 1 reply; 8+ messages in thread
From: Ryan Krauss @ 2006-05-15 21:34 UTC (permalink / raw)
  Cc: help-gnu-emacs

I had read that section.  The thing that was keeping me from getting
what I wanted was the combination of keybindings with lambda functions
(which I didn't know existed in Lisp - or how to write them).

In the versions that I looked at, there was no simple example of
writing a key binding to insert text.

Ryan

On 5/15/06, Maarten Bergvelt <bergv@math.uiuc.edu> wrote:
> In article <mailman.1844.1147718776.9609.help-gnu-emacs@gnu.org>,
> Ryan Krauss wrote:
> > I know this is a simple question, but I can't seem to find the answer.
> >  I want to bind a key to insert some text that I am retyping a lot.
> > How do I do that?  I would like to bind C-c l to insert that text
> > '\lstinline!'.
> Maybe you want check out the section "key-board macros" from the emacs
> manual.
>
> --
> Maarten Bergvelt
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>

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

* Re: keybinding help
  2006-05-15 21:34   ` Ryan Krauss
@ 2006-05-15 23:39     ` Kevin Rodgers
  0 siblings, 0 replies; 8+ messages in thread
From: Kevin Rodgers @ 2006-05-15 23:39 UTC (permalink / raw)


Ryan Krauss wrote:
 > I had read that section.  The thing that was keeping me from getting
 > what I wanted was the combination of keybindings with lambda functions
 > (which I didn't know existed in Lisp - or how to write them).
 >
 > In the versions that I looked at, there was no simple example of
 > writing a key binding to insert text.

What you are calling a lambda function is actually an anonymous
function.  But strictly speaking, a Lisp function (anonymous or not) is
not necessary for this.

Assuming that all you need to do to insert "\lstinline!" is to type
those 10 characters literally, this is how you would define a keyboard
macro to do that:

C-x ( \lstinline! C-x )

Now `C-x e' will insert "\lstinline!".  You might next want to name that
macro and bind it to `C-c l':

M-x name-last-kbd-macro RET insert-lstinline RET
M-x global-set-key RET C-c l insert-lstinline RET

See the "Naming and Saving Keyboard Macros" section of the manual for
more details.  Or you could short circuit all of those commands and just
put this in your .emacs file:

(global-set-key "\C-cl" "\\lstinline!")

-- 
Kevin

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

* Re: keybinding help
       [not found] <mailman.1844.1147718776.9609.help-gnu-emacs@gnu.org>
  2006-05-15 19:12 ` keybinding help Maarten Bergvelt
  2006-05-15 19:12 ` Tassilo Horn
@ 2006-05-19 13:54 ` Mathias Dahl
  2 siblings, 0 replies; 8+ messages in thread
From: Mathias Dahl @ 2006-05-19 13:54 UTC (permalink / raw)


"Ryan Krauss" <ryanlists@gmail.com> writes:

> I know this is a simple question, but I can't seem to find the answer.
> I want to bind a key to insert some text that I am retyping a lot.
> How do I do that?  I would like to bind C-c l to insert that text
> '\lstinline!'.

I know you asked for a keybinding, and you have got a couple of
suggestions on how to that, but I wanted to also suggest that you try
the `abbrevs' functionality in Emacs. It is more general and you might
get ideas on other uses for it.

A simple example for you you test when you are in the buffer where you
wanted this key binding:

M-x define-mode-abbrev RET 1st RET \1stinline! RET

That defines a mode-specific abbreviation `1st', which will expand to
your text.

Next, enable `abbrev-mode' (if, that is, it isn't already enabled):

M-x abbrev-mode RET

Now type 1st and then a space (or return, or some other non-word
character).

When you exit Emacs it will ask you if you want to save the abbrevs
you have created.

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

end of thread, other threads:[~2006-05-19 13:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1844.1147718776.9609.help-gnu-emacs@gnu.org>
2006-05-15 19:12 ` keybinding help Maarten Bergvelt
2006-05-15 21:34   ` Ryan Krauss
2006-05-15 23:39     ` Kevin Rodgers
2006-05-15 19:12 ` Tassilo Horn
2006-05-19 13:54 ` Mathias Dahl
2006-05-15 18:46 Ryan Krauss
2006-05-15 18:51 ` Michaël Cadilhac
2006-05-15 18:59   ` Ryan Krauss

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.