Mercurial > emacs
comparison info/eintr-2 @ 73595:f93366072a0b
* eintr-2: updated `Introduction to Programming in Emacs Lisp'
author | Robert J. Chassell <bob@rattlesnake.com> |
---|---|
date | Tue, 31 Oct 2006 18:04:34 +0000 |
parents | b214bd8be620 |
children |
comparison
equal
deleted
inserted
replaced
73594:a9d44a0da97d | 73595:f93366072a0b |
---|---|
8 END-INFO-DIR-ENTRY | 8 END-INFO-DIR-ENTRY |
9 | 9 |
10 This is an `Introduction to Programming in Emacs Lisp', for people who | 10 This is an `Introduction to Programming in Emacs Lisp', for people who |
11 are not programmers. | 11 are not programmers. |
12 | 12 |
13 Edition 3.00, 2006 Oct 31 | 13 Edition 3.01, 2006 Oct 31 |
14 | 14 |
15 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1997, 2001, 2002, | 15 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1997, 2001, 2002, |
16 2003, 2004, 2005, 2006 Free Software Foundation, Inc. | 16 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
17 | 17 |
18 Published by the: | 18 Published by the: |
35 License". | 35 License". |
36 | 36 |
37 (a) The FSF's Back-Cover Text is: "You have freedom to copy and modify | 37 (a) The FSF's Back-Cover Text is: "You have freedom to copy and modify |
38 this GNU Manual, like GNU software. Copies published by the Free | 38 this GNU Manual, like GNU software. Copies published by the Free |
39 Software Foundation raise funds for GNU development." | 39 Software Foundation raise funds for GNU development." |
40 | |
41 | |
42 File: eintr, Node: See variable current value, Next: defvar and asterisk, Prev: defvar, Up: defvar | |
43 | |
44 Seeing the Current Value of a Variable | |
45 -------------------------------------- | |
46 | |
47 You can see the current value of a variable, any variable, by using the | |
48 `describe-variable' function, which is usually invoked by typing `C-h | |
49 v'. If you type `C-h v' and then `kill-ring' (followed by <RET>) when | |
50 prompted, you will see what is in your current kill ring--this may be | |
51 quite a lot! Conversely, if you have been doing nothing this Emacs | |
52 session except read this document, you may have nothing in it. Also, | |
53 you will see the documentation for `kill-ring': | |
54 | |
55 Documentation: | |
56 List of killed text sequences. | |
57 Since the kill ring is supposed to interact nicely with cut-and-paste | |
58 facilities offered by window systems, use of this variable should | |
59 interact nicely with `interprogram-cut-function' and | |
60 `interprogram-paste-function'. The functions `kill-new', | |
61 `kill-append', and `current-kill' are supposed to implement this | |
62 interaction; you may want to use them instead of manipulating the kill | |
63 ring directly. | |
64 | |
65 The kill ring is defined by a `defvar' in the following way: | |
66 | |
67 (defvar kill-ring nil | |
68 "List of killed text sequences. | |
69 ...") | |
70 | |
71 In this variable definition, the variable is given an initial value of | |
72 `nil', which makes sense, since if you have saved nothing, you want | |
73 nothing back if you give a `yank' command. The documentation string is | |
74 written just like the documentation string of a `defun'. As with the | |
75 documentation string of the `defun', the first line of the | |
76 documentation should be a complete sentence, since some commands, like | |
77 `apropos', print only the first line of documentation. Succeeding | |
78 lines should not be indented; otherwise they look odd when you use `C-h | |
79 v' (`describe-variable'). | |
40 | 80 |
41 | 81 |
42 File: eintr, Node: defvar and asterisk, Prev: See variable current value, Up: defvar | 82 File: eintr, Node: defvar and asterisk, Prev: See variable current value, Up: defvar |
43 | 83 |
44 8.5.1 `defvar' and an asterisk | 84 8.5.1 `defvar' and an asterisk |
6793 number of characters that will be displayed. When a name has fewer | 6833 number of characters that will be displayed. When a name has fewer |
6794 characters, whitespace is added to fill out to this number. (Buffer | 6834 characters, whitespace is added to fill out to this number. (Buffer |
6795 names can and often should be longer than 12 characters; this length | 6835 names can and often should be longer than 12 characters; this length |
6796 works well in a typical 80 column wide window.) | 6836 works well in a typical 80 column wide window.) |
6797 | 6837 |
6798 `:eval' was a new feature in GNU Emacs version 21. It says to evaluate | 6838 `:eval' says to evaluate the following form and use the result as a |
6799 the following form and use the result as a string to display. In this | 6839 string to display. In this case, the expression displays the first |
6800 case, the expression displays the first component of the full system | 6840 component of the full system name. The end of the first component is a |
6801 name. The end of the first component is a `.' (`period'), so I use the | 6841 `.' (`period'), so I use the `string-match' function to tell me the |
6802 `string-match' function to tell me the length of the first component. | 6842 length of the first component. The substring from the zeroth character |
6803 The substring from the zeroth character to that length is the name of | 6843 to that length is the name of the machine. |
6804 the machine. | |
6805 | 6844 |
6806 This is the expression: | 6845 This is the expression: |
6807 | 6846 |
6808 (:eval (substring | 6847 (:eval (substring |
6809 (system-name) 0 (string-match "\\..+" (system-name)))) | 6848 (system-name) 0 (string-match "\\..+" (system-name)))) |
7443 * current-kill:: | 7482 * current-kill:: |
7444 * yank:: | 7483 * yank:: |
7445 * yank-pop:: | 7484 * yank-pop:: |
7446 * ring file:: | 7485 * ring file:: |
7447 | 7486 |
7448 | |
7449 File: eintr, Node: current-kill, Next: yank, Prev: Kill Ring, Up: Kill Ring | |
7450 | |
7451 B.1 The `current-kill' Function | |
7452 =============================== | |
7453 | |
7454 The `current-kill' function changes the element in the kill ring to | |
7455 which `kill-ring-yank-pointer' points. (Also, the `kill-new' function | |
7456 sets `kill-ring-yank-pointer' to point to the latest element of the the | |
7457 kill ring.) | |
7458 | |
7459 The `current-kill' function is used by `yank' and by `yank-pop'. Here | |
7460 is the code for `current-kill': | |
7461 | |
7462 (defun current-kill (n &optional do-not-move) | |
7463 "Rotate the yanking point by N places, and then return that kill. | |
7464 If N is zero, `interprogram-paste-function' is set, and calling it | |
7465 returns a string, then that string is added to the front of the | |
7466 kill ring and returned as the latest kill. | |
7467 If optional arg DO-NOT-MOVE is non-nil, then don't actually move the | |
7468 yanking point; just return the Nth kill forward." | |
7469 (let ((interprogram-paste (and (= n 0) | |
7470 interprogram-paste-function | |
7471 (funcall interprogram-paste-function)))) | |
7472 (if interprogram-paste | |
7473 (progn | |
7474 ;; Disable the interprogram cut function when we add the new | |
7475 ;; text to the kill ring, so Emacs doesn't try to own the | |
7476 ;; selection, with identical text. | |
7477 (let ((interprogram-cut-function nil)) | |
7478 (kill-new interprogram-paste)) | |
7479 interprogram-paste) | |
7480 (or kill-ring (error "Kill ring is empty")) | |
7481 (let ((ARGth-kill-element | |
7482 (nthcdr (mod (- n (length kill-ring-yank-pointer)) | |
7483 (length kill-ring)) | |
7484 kill-ring))) | |
7485 (or do-not-move | |
7486 (setq kill-ring-yank-pointer ARGth-kill-element)) | |
7487 (car ARGth-kill-element))))) | |
7488 | |
7489 In addition, the `kill-new' function sets `kill-ring-yank-pointer' to | |
7490 the latest element of the the kill ring. And indirectly so does | |
7491 `kill-append', since it calls `kill-new'. In addition, `kill-region' | |
7492 and `kill-line' call the `kill-new' function. | |
7493 | |
7494 Here is the line in `kill-new', which is explained in *Note The | |
7495 `kill-new' function: kill-new function. | |
7496 | |
7497 (setq kill-ring-yank-pointer kill-ring) | |
7498 | |
7499 * Menu: | |
7500 | |
7501 * Understanding current-kill:: | |
7502 |