* Question about backup files
@ 2002-10-01 13:16 Ben Key
0 siblings, 0 replies; 4+ messages in thread
From: Ben Key @ 2002-10-01 13:16 UTC (permalink / raw)
The following is an excerpt from the GNU Emacs manual:
"You can also explicitly request making another backup
file from a buffer even though it has already been saved
at least once. If you save the buffer with `C-u C-x C-s',
the version thus saved will be made into a backup file
if you save the buffer again. `C-u C-u C-x C-s' saves the
buffer, but first makes the previous file contents into a new
backup file. `C-u C-u C-u C-x C-s' does both things: it
makes a backup from the previous contents, and arranges
to make another from the newly saved contents if you save
again."
My question is, is it possible to create a more simplified
keystroke assignment that implements the same behavior
as `C-u C-u C-u C-x C-s'. For example, I would like to assign
this behavior to 'ESC C-x C-s'.
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <mailman.1033479018.23093.help-gnu-emacs@gnu.org>]
* Re: Question about backup files
[not found] <mailman.1033479018.23093.help-gnu-emacs@gnu.org>
@ 2002-10-01 15:06 ` Reiner Steib
2002-10-01 15:55 ` Kevin Rodgers
1 sibling, 0 replies; 4+ messages in thread
From: Reiner Steib @ 2002-10-01 15:06 UTC (permalink / raw)
On Tue, Oct 01 2002, Ben Key wrote:
> My question is, is it possible to create a more simplified
> keystroke assignment that implements the same behavior
> as `C-u C-u C-u C-x C-s'. For example, I would like to assign
> this behavior to 'ESC C-x C-s'.
First you have to find out what function is called by `C-x C-s':
,----[ C-h k C-x C-s ]
| C-x C-s runs the command save-buffer
| which is an interactive compiled Lisp function in `files'.
| It is bound to <f2>, C-x C-s, <menu-bar> <files> <save-buffer>.
| (save-buffer &optional ARGS)
|
| Save current buffer in visited file if modified. Versions described below.
| By default, makes the previous version into a backup file
| if previously requested or if this is the first save.
| With 1 C-u, marks this version
| to become a backup when the next save is done.
| With 2 C-u's,
| unconditionally makes the previous version into a backup file.
| With 3 C-u's, marks this version
| to become a backup when the next save is done,
| and unconditionally makes the previous version into a backup file.
|
| With argument of 0, never make the previous version into a backup file.
`----
"ESC C-x (translated from <escape> C-x) runs the command eval-defun"
so you should use a different key, e.g.:
(define-key global-map [(shift f5)]
'(lambda ()
(interactive)
(save-buffer 4))) ;; C-u ==> 4
(define-key global-map [(ctrl f5)]
'(lambda ()
(interactive)
(save-buffer (* 4 4)))) ;; C-u C-u ==> 4*4
(define-key global-map [(shift ctrl f5)]
'(lambda ()
(interactive)
(save-buffer (* 4 4 4)))) ;; C-u C-u C-u ==> 4*4*4
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- PGP key available via WWW http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Question about backup files
[not found] <mailman.1033479018.23093.help-gnu-emacs@gnu.org>
2002-10-01 15:06 ` Reiner Steib
@ 2002-10-01 15:55 ` Kevin Rodgers
1 sibling, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2002-10-01 15:55 UTC (permalink / raw)
Ben Key wrote:
> My question is, is it possible to create a more simplified
> keystroke assignment that implements the same behavior
> as `C-u C-u C-u C-x C-s'. For example, I would like to assign
> this behavior to 'ESC C-x C-s'.
See the "Keyboard Macros" section of the manual.
--
<a href="mailto:<kevinr@ihs.com>">Kevin Rodgers</a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Question about backup files
@ 2002-10-01 17:07 Bingham, Jay
0 siblings, 0 replies; 4+ messages in thread
From: Bingham, Jay @ 2002-10-01 17:07 UTC (permalink / raw)
Ben,
The lisp reference manual will answer many questions of this type. If you do not have a copy installed on your system you can find a copy on the web.
The lisp reference manual for emacs 21.2 is at: http://www.gnu.org/manual/elisp-manual-21-2.8/html_mono/elisp.html
The lisp reference manual for emacs 20.3 is at: http://www.gnu.org/manual/elisp-manual-20-2.5/html_mono/elisp.html
The answer to your question can be found in the section on 'prefix command arguments'.
Briefly here is what it says: The default prefix argument is 1, each time that C-u is pressed the current prefix arg value is multiplied 4. Therefore for the first C-u the arg value is 4, for the next it becomes 16, for the next 64 and so on.
-_
J_)
C_)ingham
. HP - NonStop Austin Software & Services - Software Product Assurance
. Austin, TX
. Language is the apparel in which your thoughts parade in public.
. Never clothe them in vulgar and shoddy attire. -Dr. George W. Crane-
-----Original Message-----
From: Ben Key [mailto:BenK@FreedomScientific.com]
Sent: Tuesday, October 01, 2002 10:04 AM
To: Bingham, Jay
Subject: RE: Question about backup files
Thanks for your response. How can I figure out what arguments are passed to
save-buffer when multiple C-u are typed?
-----Original Message-----
From: Bingham, Jay [mailto:Jay.Bingham@hp.com]
Sent: Tuesday, October 01, 2002 10:27 AM
To: Ben Key
Subject: RE: Question about backup files
Ben,
In emacs, all (well most things) are possible depending on how much effort
you want to expend to make it happen.
What the C-u does is pass a numeric argument to the function. I am not
certain what gets passed when multiple C-u are typed. It is obvious that
it either causes a different numeric value or a different number of
arguments of the same value to be passed in each case. The best way to find
out is to go look at the lisp for the command save-buffer which is an
interactive compiled Lisp function in `files.el'. The argument list for
this command is (save-buffer &optional ARGS).
Once you know what to pass then you can write your own function that calls
save-buffer with the appropriate arguments and assign it to your key
sequence. You may have to replicate some of the code that gets the name of
the buffer to save.
Good luck
-_
J_)
C_)ingham
. HP - NonStop Austin Software & Services - Software Product Assurance
. Austin, TX
. Language is the apparel in which your thoughts parade in public.
. Never clothe them in vulgar and shoddy attire. -Dr. George W.
Crane-
-----Original Message-----
From: Ben Key [mailto:BenK@FreedomScientific.com]
Sent: Tuesday, October 01, 2002 8:16 AM
To: help-gnu-emacs@gnu.org
Subject: Question about backup files
The following is an excerpt from the GNU Emacs manual:
"You can also explicitly request making another backup
file from a buffer even though it has already been saved
at least once. If you save the buffer with `C-u C-x C-s',
the version thus saved will be made into a backup file
if you save the buffer again. `C-u C-u C-x C-s' saves the
buffer, but first makes the previous file contents into a new
backup file. `C-u C-u C-u C-x C-s' does both things: it
makes a backup from the previous contents, and arranges
to make another from the newly saved contents if you save
again."
My question is, is it possible to create a more simplified
keystroke assignment that implements the same behavior
as `C-u C-u C-u C-x C-s'. For example, I would like to assign
this behavior to 'ESC C-x C-s'.
_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-10-01 17:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-01 13:16 Question about backup files Ben Key
[not found] <mailman.1033479018.23093.help-gnu-emacs@gnu.org>
2002-10-01 15:06 ` Reiner Steib
2002-10-01 15:55 ` Kevin Rodgers
-- strict thread matches above, loose matches on Subject: below --
2002-10-01 17:07 Bingham, Jay
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).