unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* binding a key to a function with an argument
@ 2009-07-22 16:13 John Withers
  2009-07-23  5:54 ` Wang Lei
  2009-07-23 10:43 ` Bernardo
  0 siblings, 2 replies; 4+ messages in thread
From: John Withers @ 2009-07-22 16:13 UTC (permalink / raw)
  To: help-gnu-emacs

Folks,

I am trying to change C-x C-s save-buffer to save-some-buffers with the
non-nil argument so that it will save all without questions. 

I have no problem with the bind of the save-some-buffers:

(global-set-key (kbd "C-x C-s") 'save--some-buffers)

but I can't figure out how to pass the non-nil argument. I have tried a
few different ways and they all throw errors.

Any help would be appreciated.

-john





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

* Re: binding a key to a function with an argument
       [not found] <mailman.2993.1248320862.2239.help-gnu-emacs@gnu.org>
@ 2009-07-23  5:42 ` Teemu Likonen
  0 siblings, 0 replies; 4+ messages in thread
From: Teemu Likonen @ 2009-07-23  5:42 UTC (permalink / raw)
  To: help-gnu-emacs

On 2009-07-22 09:13 (-0700), John Withers wrote:

> (global-set-key (kbd "C-x C-s") 'save--some-buffers)
>
> but I can't figure out how to pass the non-nil argument. I have tried a
> few different ways and they all throw errors.

The second parameter for global-set-key must be a symbol of interactive
function and you can only pass interactive prefix arguments to that
function. But you can create a new function which calls
save-some-buffers with the arguments you like. I use anonymous function
(lambda) here:

    (global-set-key (kbd "C-x C-s")
                    (lambda () (interactive)
                      (save-some-buffers t)))


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

* Re: binding a key to a function with an argument
  2009-07-22 16:13 binding a key to a function with an argument John Withers
@ 2009-07-23  5:54 ` Wang Lei
  2009-07-23 10:43 ` Bernardo
  1 sibling, 0 replies; 4+ messages in thread
From: Wang Lei @ 2009-07-23  5:54 UTC (permalink / raw)
  To: grayarea; +Cc: help-gnu-emacs

how about use lambda ?

(global-set-key (kbd "C-x s") '(lambda()
				(interactive)
				(save-some-buffers t)))


On 7/23/09, John Withers <grayarea@reddagger.org> wrote:
> Folks,
>
> I am trying to change C-x C-s save-buffer to save-some-buffers with the
> non-nil argument so that it will save all without questions.
>
> I have no problem with the bind of the save-some-buffers:
>
> (global-set-key (kbd "C-x C-s") 'save--some-buffers)
>
> but I can't figure out how to pass the non-nil argument. I have tried a
> few different ways and they all throw errors.
>
> Any help would be appreciated.
>
> -john
>
>
>
>


-- 
Regards
Lei




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

* Re: binding a key to a function with an argument
  2009-07-22 16:13 binding a key to a function with an argument John Withers
  2009-07-23  5:54 ` Wang Lei
@ 2009-07-23 10:43 ` Bernardo
  1 sibling, 0 replies; 4+ messages in thread
From: Bernardo @ 2009-07-23 10:43 UTC (permalink / raw)
  To: help-gnu-emacs

> I am trying to change C-x C-s save-buffer to save-some-buffers with the
> non-nil argument so that it will save all without questions. 

an alternative way using keystrokes: C-x s !




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

end of thread, other threads:[~2009-07-23 10:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-22 16:13 binding a key to a function with an argument John Withers
2009-07-23  5:54 ` Wang Lei
2009-07-23 10:43 ` Bernardo
     [not found] <mailman.2993.1248320862.2239.help-gnu-emacs@gnu.org>
2009-07-23  5:42 ` Teemu Likonen

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