File: working-with-files.html

package info (click to toggle)
emacspeak 24-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 9,092 kB
  • ctags: 4,597
  • sloc: xml: 54,699; lisp: 42,103; tcl: 1,799; makefile: 810; cpp: 603; sh: 566; ansic: 153; perl: 124
file content (718 lines) | stat: -rw-r--r-- 12,133 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
<HTML
><HEAD
><TITLE
>Working with files</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.59"><LINK
REL="HOME"
TITLE="Emacspeak User's Guide"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="System Administration"
HREF="system-administration.html"><LINK
REL="NEXT"
TITLE="Working online"
HREF="working-online.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Emacspeak User's Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="system-administration.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="working-online.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="WORKING-WITH-FILES"
>5. Working with files</A
></H1
><P
>	In addition to performing common file manipulation tasks, such
	as moving, copying, and deleting, you'll also want to download
	files from the Internet, search for files in your directories,
	and FTP files. Some of these functions are built into Emacs,
	while some of these tasks require additional applications that
	can be downloaded.
	</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="DOWNLOADING-FILES"
>5.1. Downloading files</A
></H2
><P
>	Once you know the URL of the file to download, you can use the
	<B
CLASS="COMMAND"
>wget</B
> command from within the Emacs shell to
	retrieve the file.  If you do not know the URL of the file to
	download, use the <SPAN
CLASS="APPLICATION"
>W3</SPAN
> application to browse the web and find the URL of the file (refer
	to <A
HREF="working-online.html#BROWSING-THE-INTERNET"
>Section 6.1</A
> for
	information on using the <SPAN
CLASS="APPLICATION"
>W3</SPAN
> application). Then
	use the command <B
CLASS="COMMAND"
>wget</B
> to download it. For more
	information on the <B
CLASS="COMMAND"
>wget</B
> command, refer to the
	<B
CLASS="COMMAND"
>wget</B
> man page.
	</P
><P
>	To download a file:
	</P
><P
></P
><OL
TYPE="1"
><LI
><P
>			From inside Emacs, type <B
CLASS="COMMAND"
>M-x
			shell</B
> to start the shell.
			</P
></LI
><LI
><P
>			Since the <B
CLASS="COMMAND"
>wget</B
>
			command places
			the downloaded file into your current
			directory, change directories to the desired
			directory.
			</P
></LI
><LI
><P
>			When you are in the appropriate directory,
			type <B
CLASS="COMMAND"
>wget [url]</B
>, then press
			<SPAN
CLASS="KEYSYM"
>Enter</SPAN
>.  Remember that you can
			copy and paste the URL of the file to download
			from the <SPAN
CLASS="APPLICATION"
>W3</SPAN
> web
			browser application.
			</P
></LI
></OL
><P
>	As the file is being downloaded, one dot appears on the screen
	for each kilobyte of data
	received. The <B
CLASS="COMMAND"
>wget</B
> command lets you know when
	the download is complete. 
	</P
><P
>	Another option for downloading (or uploading) a file is via
	FTP. Refer to <A
HREF="working-with-files.html#FTPING-A-FILE"
>Section 5.3</A
> on FTPing a file for more information.
	</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="FIND-A-FILE"
>5.2. Finding a file</A
></H2
><P
>	There are several ways you can find a file. This section discusses two options.
	</P
><P
>	If you know the name of the file, or at least remember part of
	it, you can use the <B
CLASS="COMMAND"
>find-file</B
> command:
	</P
><P
></P
><OL
TYPE="1"
><LI
><P
>			In Emacs, type <B
CLASS="COMMAND"
>M-x find-file</B
>.
			</P
><P
>			Result: You will be prompted for the name of
			the file in the default working directory.
			</P
></LI
><LI
><P
>			Type the name of the file (or use wildcards) you wish to find.
			</P
></LI
></OL
><P
>	Alternatively, you may want to browse your directories to look
	for a file.  You can do this using the Emacs directory editor,
	<SPAN
CLASS="APPLICATION"
>dired</SPAN
>.  To
	start <SPAN
CLASS="APPLICATION"
>dired</SPAN
>: 
	</P
><P
></P
><OL
TYPE="1"
><LI
><P
>			In Emacs, type <B
CLASS="COMMAND"
>C-x d</B
> or
			<B
CLASS="COMMAND"
>M-x dired</B
>. You will be prompted for the name of
			the file.  You can type the name (or part of
			the name) of the file to find, using the Tab
			key to complete the file
			name. <SPAN
CLASS="APPLICATION"
>dired</SPAN
> will
			list any files that match the name you
			entered.  Alternatively, you can view a full
			listing of the directory by providing a
			directory name (or pressing Return to view the
			current directory) when prompted.
			</P
></LI
></OL
><P
>	For more information on using the directory editor, refer to
	<A
HREF="working-with-files.html#USING-THE-DIRECTORY-EDITOR"
>Section 5.4.2</A
>.  For a complete listing of
	<SPAN
CLASS="APPLICATION"
>dired's</SPAN
> features and capabilities,
	refer to <A
HREF="http://www.delorie.com/gnu/docs/emacs/emacs_360.html"
TARGET="_top"
>http://www.delorie.com/gnu/docs/emacs/emacs_360.html</A
>.
	</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="FTPING-A-FILE"
>5.3. FTPing a file</A
></H2
><P
>	Emacs contains a built-in file transfer protocol, or FTP,
	application. The FTP application can be used to upload and download files to
	and from other machines. In order to use FTP,
	you will need to know the hostname of the machine to contact.
	</P
><P
>	To invoke the FTP application:
	</P
><P
></P
><OL
TYPE="1"
><LI
><P
>			Within Emacs, type <B
CLASS="COMMAND"
>M-x ftp</B
>.
			</P
><P
>			Result: You will be prompted for an ftp hostname.
			</P
></LI
></OL
><P
>	Alternatively, you can start an Emacs shell using <B
CLASS="COMMAND"
>M-x
	shell</B
> and use FTP from the command line.  There is a
	short tutorial on using the command line FTP at <A
HREF="http://unix.about.com/library/weekly/aa121800a.htm?once=true&"
TARGET="_top"
>http://unix.about.com/library/weekly/aa121800a.htm?once=true&#38;</A
>.
	</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="FILE-MANIPULATION"
>5.4. Manipulating files</A
></H2
><P
>	This section contains information on moving, copying,
	and deleting files from within Emacs. In general, there are
	two ways you can go about these tasks.  One option is to use the
	command line from an Emacs shell, and the other is to use
	<SPAN
CLASS="APPLICATION"
> dired</SPAN
>. Both methods are discussed in this section.
	</P
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="USING-THE-COMMAND-LINE"
>5.4.1. Using the command line</A
></H3
><P
>	If you are familiar with Unix command-line arguments, you may
	prefer to use the command line to manipulate files. To use the
	command line, open an Emacs command shell using
	<B
CLASS="COMMAND"
>M-x shell</B
>. The following list shows some
	basic file manipulation commands and what they do:
	</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><B
CLASS="COMMAND"
>cp <TT
CLASS="FILENAME"
>file1
					file2</TT
></B
></DT
><DD
><P
>					Copies file1 to a new file
					named file2.
					</P
></DD
><DT
><B
CLASS="COMMAND"
>mv <TT
CLASS="FILENAME"
>source
					target</TT
></B
></DT
><DD
><P
>					Moves a file from the source
					directory to the target directory.
					</P
></DD
><DT
><B
CLASS="COMMAND"
>rm
					<TT
CLASS="FILENAME"
>file</TT
></B
></DT
><DD
><P
>					Deletes a file.
					</P
></DD
><DT
><B
CLASS="COMMAND"
>mkdir
			<TT
CLASS="FILENAME"
>directoryname</TT
></B
></DT
><DD
><P
>					Creates a directory with the
					name
					<TT
CLASS="FILENAME"
>directoryname</TT
>.
					</P
></DD
><DT
><B
CLASS="COMMAND"
>rmdir
					<TT
CLASS="FILENAME"
>directoryname</TT
></B
></DT
><DD
><P
>					Deletes the directory
					<TT
CLASS="FILENAME"
>directoryname</TT
>
					if it is empty.
					</P
></DD
><DT
><B
CLASS="COMMAND"
>ls</B
></DT
><DD
><P
>					Lists all the files in the
					current directory.
					</P
></DD
></DL
></DIV
><P
>	You can find more
	information on any of these commands (most can be run with
	various options that allow for more user control) by looking
	them up in the online man pages. Since the list presented here
	covers only the most basic commands, you may want to consult the
	Linux user's guide, available at <A
HREF="http://www.ibiblio.org/pub/Linux/docs/linux-doc-project/users-guide/"
TARGET="_top"
>http://www.ibiblio.org/pub/Linux/docs/linux-doc-project/users-guide/</A
>,
	for more information.
	</P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="USING-THE-DIRECTORY-EDITOR"
>5.4.2. Using the directory editor</A
></H3
><P
>	Although many Linux users use the command line to manipulate
	files, Emacs provides a powerful alternative, called
	<SPAN
CLASS="APPLICATION"
>dired</SPAN
>.  <SPAN
CLASS="APPLICATION"
>Dired</SPAN
> is the Emacs
	directory editor, and is great for manipulating files if you'd
	rather not use the command line or aren't familiar with it. To
	start <SPAN
CLASS="APPLICATION"
>dired</SPAN
>:
	</P
><P
></P
><OL
TYPE="1"
><LI
><P
>			In Emacs, type <B
CLASS="COMMAND"
>M-x
			dired</B
>. You will be prompted for the
			directory to open.
			</P
></LI
><LI
><P
>			Type in the directory to display, or press
			<SPAN
CLASS="KEYSYM"
>Return</SPAN
> to open the default
			directory.
			</P
></LI
></OL
><P
>	Once you've started <SPAN
CLASS="APPLICATION"
>dired</SPAN
>, you can move around in the Emacs
	buffer to have the file names, permissions, owners, sizes, and
	dates created/edited read aloud.
	</P
><P
>	In dired, some commands mark files for manipulation (for
	example, you can mark several files, then delete them all),
	and some commands (such as the copy command) are executed
	immediately. Note that, in dired, case does make a difference
	for many commands. Some of the more common
	<SPAN
CLASS="APPLICATION"
>dired</SPAN
> commands and what they do are
	listed below:
	</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>press the <B
CLASS="COMMAND"
>Return</B
>key</DT
><DD
><P
>					Pressing
					<B
CLASS="COMMAND"
>Return</B
> when
					the focus is on a particular
					file opens that file in the
					appropriate major mode.
					</P
></DD
><DT
><B
CLASS="COMMAND"
>d</B
></DT
><DD
><P
>					Marks a single file for
					deletion, but doesn't actually
					delete the file. You can mark
					multiple files for deletion,
					then delete them all simultaneously.
					</P
></DD
><DT
><B
CLASS="COMMAND"
>u</B
></DT
><DD
><P
>					If a file is
					marked for deletion, this
					option unmarks it.
					</P
></DD
><DT
><B
CLASS="COMMAND"
>x</B
></DT
><DD
><P
>					Deletes all files marked for
					deletion. You will be prompted to make
					sure you want to delete the
					files in question; type
					<B
CLASS="COMMAND"
>yes</B
> or
					<B
CLASS="COMMAND"
>no</B
> as
					appropriate.
					</P
></DD
><DT
><B
CLASS="COMMAND"
>C</B
></DT
><DD
><P
>					Copies a file.  You will be
					asked for the name of the new
					file to create when you copy the old file.
					</P
></DD
><DT
><B
CLASS="COMMAND"
>R</B
></DT
><DD
><P
>					Renames a file.  You will be
					prompted for the name of the new
					file to create when you rename
					the file.
					</P
></DD
></DL
></DIV
><P
>	Because <SPAN
CLASS="APPLICATION"
>dired</SPAN
> is so extensive,
	including the full documentation for it here is not feasible.
	However, complete instructions can be found in the GNU Emacs
	Manual at <A
HREF="http://www.delorie.com/gnu/docs/emacs/emacs_360.html"
TARGET="_top"
>http://www.delorie.com/gnu/docs/emacs/emacs_360.html</A
>.
	</P
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="system-administration.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="working-online.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>System Administration</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Working online</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>