⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch32_04.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 32] 32.4 Backup and Auto-Save Files </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:46:35Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch32_01.htm"TITLE="32. GNU Emacs"><LINKREL="prev"HREF="ch32_03.htm"TITLE="32.3 Customizations and How to Avoid Them "><LINKREL="next"HREF="ch32_05.htm"TITLE="32.5 Putting Emacs in Overwrite Mode "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch32_03.htm"TITLE="32.3 Customizations and How to Avoid Them "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 32.3 Customizations and How to Avoid Them "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 32<BR>GNU Emacs</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch32_05.htm"TITLE="32.5 Putting Emacs in Overwrite Mode "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 32.5 Putting Emacs in Overwrite Mode "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-5549">32.4 Backup and Auto-Save Files </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-35899"></A><ACLASS="indexterm"NAME="AUTOID-35902"></A><ACLASS="indexterm"NAME="AUTOID-35905"></A>If you're like most people, you often spend a few hours editing afile, only to decide that you liked your original version better.Or you press some strange sequence of keys that makes Emacs do somethingextremely weird and that you can't &quot;undo.&quot;Emacs provides several ways to get out of these tight spots.</P><PCLASS="para">First, try the command <CODECLASS="literal">ESC</CODE>&nbsp;<CODECLASS="literal">x</CODE>&nbsp;<CODECLASS="literal">revert-buffer</CODE>. Emacs will ask oneof two questions: either &quot;Buffer has been auto-saved recently. Revert fromauto-save file? (y or n)&quot; or &quot;Revert buffer from file<EMCLASS="emphasis">your-filename</EM>? (yes or no)&quot;. </P><PCLASS="para">Before deciding what to do, it's important to understand thedifference between these two questions. Emacs creates an auto-save[1]file every 300 keystrokes you type. So, if you're reverting to theauto-save file, you'll at most lose your last 300 keystrokes. Maybethis is what you want&nbsp;- but maybe you made the mistake a long time ago.In that case, you don't want to use the auto-save file; type <CODECLASS="literal">n</CODE>,and you'll see the second question, asking if you want to revert tothe last copy of the file that you saved. Type <CODECLASS="literal">yes</CODE> to go backto your most recent saved version.</P><BLOCKQUOTECLASS="footnote"><PCLASS="para">[1] For reference, the name of the auto-save file is<CODECLASS="literal">#</CODE><CODECLASS="replaceable"><I>your-filename</I></CODE><CODECLASS="literal">#</CODE>; that is, it sticks a hash mark (<CODECLASS="literal">#</CODE>) before and after the file's &quot;regular&quot; name.</P></BLOCKQUOTE><PCLASS="para">It's possible that you'll only see the second question (&quot;Revert bufferfrom file...&quot;). This means that you have saved the file sometimewithin the last 300&nbsp;keystrokes. As soon as you save a file, Emacsdeletes the auto-save file. It will create a new one every 300 keystrokes.</P><PCLASS="para">It's worth noting that Emacs is <EMCLASS="emphasis">very</EM> picky about what you type.If it asks for a <CODECLASS="literal">y</CODE> or an <CODECLASS="literal">n</CODE>, you've got to type <CODECLASS="literal">y</CODE>or <CODECLASS="literal">n</CODE>. If it asks for <CODECLASS="literal">yes</CODE> or <CODECLASS="literal">no</CODE>, you've got totype <CODECLASS="literal">yes</CODE> or <CODECLASS="literal">no</CODE>. In situations like this, where the twostyles are mixed up, you've got to get it right.</P><PCLASS="para">If you're in real trouble, and you want to go back to your<EMCLASS="emphasis">original file</EM>&nbsp;- the way it was when you started editing&nbsp;- you needto recover Emacs' <EMCLASS="emphasis">backup file</EM>. If you're editing a file thatalready exists, Emacs will create a backup file as soon as it starts.If you're editing a new file, Emacs will create a backup the <EMCLASS="emphasis">second</EM>time you save the file. Once it's created, the backup file is nevertouched; it stays there until the next time you start Emacs, at whichpoint you'll get a new backup, reflecting the file's contents at thestart of your editing session.</P><PCLASS="para">Now that we're over the preliminaries, how do you recover the backupfile? Emacs doesn't have any specialcommand for doing this; you have to do it by hand. The backup file'sname is the same as your original filename, with a tilde (<CODECLASS="literal">~</CODE>)added to it. So quit Emacs (or start a shell), and type:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>mv</B></CODE> <CODECLASS="replaceable"><I>your-filename</I></CODE><CODECLASS="userinput"><B>~</B></CODE> <CODECLASS="replaceable"><I>your-filename</I></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">Note that Emacs has the ability to save &quot;numbered&quot; backup files, like theVAX/VMS operating system. We've never played with this feature anddon't particularly think it's a good idea. But it's there if you want it.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">ML</SPAN>, <SPANCLASS="authorinitials">DC</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch32_03.htm"TITLE="32.3 Customizations and How to Avoid Them "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 32.3 Customizations and How to Avoid Them "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch32_05.htm"TITLE="32.5 Putting Emacs in Overwrite Mode "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 32.5 Putting Emacs in Overwrite Mode "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">32.3 Customizations and How to Avoid Them </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">32.5 Putting Emacs in Overwrite Mode </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -