unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* shortcut for align-regexp
@ 2013-04-17 12:35 Jannis
  2013-04-17 13:20 ` Doug Lewan
  0 siblings, 1 reply; 2+ messages in thread
From: Jannis @ 2013-04-17 12:35 UTC (permalink / raw)
  To: help-gnu-emacs

Hi emacs users,


this most probably is a beginners question ... googeling however yielded 
now exlanation suitable for my emacs experience.

I would love to bind single key combination (like C-a) to the 
align-regexp command and use = and <- as alignment regexpressions. How 
would I do this?

Without this I always have to type:

M-align-regexp RET <- RET


Thanks a lot
Jannis



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

* RE: shortcut for align-regexp
  2013-04-17 12:35 shortcut for align-regexp Jannis
@ 2013-04-17 13:20 ` Doug Lewan
  0 siblings, 0 replies; 2+ messages in thread
From: Doug Lewan @ 2013-04-17 13:20 UTC (permalink / raw)
  To: Jannis, help-gnu-emacs@gnu.org

The command align-regexp is written to prompt you for a regular expression if you use it interactively.

The following code does what you describe you want.

    (defun my-common-align (begin end)
      "Align text in the region on '=' and '<-'."
      (interactive "r")
      (let ((common-align-regexp "\\(?:=\\|<-\\)"))
	(align-regexp begin end common-align-regexp)))
    (global-set-key "\C-a" 'my-common-align)

The choice of key is yours, but `C-a' is move-beginning-of-line almost everywhere. I might recommend `C-c a' instead.

,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224

If the majority of cooking accidents happen in the kitchen, then why don't we just cook in other rooms?


-----Original Message-----
From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On Behalf Of Jannis
Sent: Wednesday, 2013 April 17 08:35
To: help-gnu-emacs@gnu.org
Subject: shortcut for align-regexp

Hi emacs users,


this most probably is a beginners question ... googeling however yielded 
now exlanation suitable for my emacs experience.

I would love to bind single key combination (like C-a) to the 
align-regexp command and use = and <- as alignment regexpressions. How 
would I do this?

Without this I always have to type:

M-align-regexp RET <- RET


Thanks a lot
Jannis




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

end of thread, other threads:[~2013-04-17 13:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-17 12:35 shortcut for align-regexp Jannis
2013-04-17 13:20 ` Doug Lewan

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