unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How can I bind a shell command to a key?
@ 2006-05-22  2:51 LUK
  2006-05-22  7:01 ` Mathias Dahl
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: LUK @ 2006-05-22  2:51 UTC (permalink / raw)


Hi, I want to bind a shell command "find . -type f -name "*" -print |
etags -" 
to"F1",
what should I write in ".emacs"?
Thanks!

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

* Re: How can I bind a shell command to a key?
  2006-05-22  2:51 How can I bind a shell command to a key? LUK
@ 2006-05-22  7:01 ` Mathias Dahl
  2006-05-22  7:02 ` Burton Samograd
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Mathias Dahl @ 2006-05-22  7:01 UTC (permalink / raw)


"LUK" <700MHz@gmail.com> writes:

> Hi, I want to bind a shell command "find . -type f -name "*" -print |
> etags -" 
> to"F1",
> what should I write in ".emacs"?

You could record a keyboard macro, give that a name and insert it into
your .emacs file or you could write a simple elisp function; then you
could bind F1 to one of those.

Keyboard macro approach:

C-x (
M-!
type shell command here
C-x )

Now the macro is defined. Give it a name:

M-x name-last-kbd-macro RET my-macro-name RET

Insert it into your .emacs:

M-x insert-kbd-macro RET my-macro-name RET

Bind F1 to the macro:

(global-set-key [F1] 'my-macro-name)

Function approach:

(defun my-shell-command ()
  (interactive)
  (shell-command "type shell command here"))

And then:

(global-set-key [F1] 'my-shell-command)

Remember that in the function approach you have to quote the quotation
marks with \. This:

"*" should be written \"*\" inside the string.

Good luck!

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

* Re: How can I bind a shell command to a key?
  2006-05-22  2:51 How can I bind a shell command to a key? LUK
  2006-05-22  7:01 ` Mathias Dahl
@ 2006-05-22  7:02 ` Burton Samograd
  2006-05-22  7:04 ` Ye Wenbin
  2006-05-22  7:44 ` LUK
  3 siblings, 0 replies; 5+ messages in thread
From: Burton Samograd @ 2006-05-22  7:02 UTC (permalink / raw)


"LUK" <700MHz@gmail.com> writes:

> Hi, I want to bind a shell command "find . -type f -name "*" -print |
> etags -" 
> to"F1",
> what should I write in ".emacs"?

(global-set-key [f1]
  '(lambda () 
      (interactive) 
      (shell-command "find . -type f -name "*" -print | etags -")))
      
> Thanks!

np.

-- 
burton samograd					kruhft .at. gmail
kruhft.blogspot.com	www.myspace.com/kruhft	metashell.blogspot.com

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

* Re: How can I bind a shell command to a key?
  2006-05-22  2:51 How can I bind a shell command to a key? LUK
  2006-05-22  7:01 ` Mathias Dahl
  2006-05-22  7:02 ` Burton Samograd
@ 2006-05-22  7:04 ` Ye Wenbin
  2006-05-22  7:44 ` LUK
  3 siblings, 0 replies; 5+ messages in thread
From: Ye Wenbin @ 2006-05-22  7:04 UTC (permalink / raw)
  Cc: help-gnu-emacs@gnu.org


I think abbrev is better way to do this:
(define-abbrev-table 'shell-mode-abbrev-table '(
     ("findx" "find . -type f -name \"*\" -print |etags -" nil 0)
     ))

On 21 May 2006 19:51:51 -0700, LUK <700MHz@gmail.com> wrote:

>
> Hi, I want to bind a shell command "find . -type f -name "*" -print |
> etags -"
> to"F1",
> what should I write in ".emacs"?
> Thanks!
>
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/

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

* Re: How can I bind a shell command to a key?
  2006-05-22  2:51 How can I bind a shell command to a key? LUK
                   ` (2 preceding siblings ...)
  2006-05-22  7:04 ` Ye Wenbin
@ 2006-05-22  7:44 ` LUK
  3 siblings, 0 replies; 5+ messages in thread
From: LUK @ 2006-05-22  7:44 UTC (permalink / raw)



Thank you very much!

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

end of thread, other threads:[~2006-05-22  7:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-22  2:51 How can I bind a shell command to a key? LUK
2006-05-22  7:01 ` Mathias Dahl
2006-05-22  7:02 ` Burton Samograd
2006-05-22  7:04 ` Ye Wenbin
2006-05-22  7:44 ` LUK

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