diff options
| author | Robert J. Chassell | 2006-11-04 19:09:13 +0000 |
|---|---|---|
| committer | Robert J. Chassell | 2006-11-04 19:09:13 +0000 |
| commit | cddf673f8018134aa9b23cdf66658c7b8d6c9542 (patch) | |
| tree | 6a6d297c0a7447af3f8b0f35d9aa61be631d1dfb | |
| parent | d3e1986ff9d5bfa4f92c4cd16352c54fdef8dcc0 (diff) | |
| download | emacs-cddf673f8018134aa9b23cdf66658c7b8d6c9542.tar.gz emacs-cddf673f8018134aa9b23cdf66658c7b8d6c9542.zip | |
Minor fixes.
Replace all tabs with eight spaces each so printed text looks correct.
Remove extraneous comma in a printed node name produced by `ref'.
(insert-buffer): Add a missing beginning parenthesis.
(beginning-of-buffer): Add `beginning of' to note about accessible portion.
(narrow Exercise): Write closing parenthesis at end of correct paragraph.
(zap-to-char): Remove extraneous `a' from first sentence.
(Complete zap-to-char): Remove two extraneous sentences.
(zap-to-char body): Move sentences on documentation two nodes earlier.
(Lisp macro): Add definition of `unless' macro.
(last-command & this-command): Remove comment that `we have not yet
seen' the @code{eq} function.
(kill-append function): Reformat `kill-append' function definition so
it prints well.
(kill-new function): Indent the sentence beginning `notice'. Replace
`the same as' with `similar to'. Repair typo. Remove obsolete
references to `yank' and `yank-pop. End section with a note that `we
will digress into C.'
| -rw-r--r-- | lispintro/ChangeLog | 23 | ||||
| -rw-r--r-- | lispintro/emacs-lisp-intro.texi | 634 |
2 files changed, 343 insertions, 314 deletions
diff --git a/lispintro/ChangeLog b/lispintro/ChangeLog index e44fbc27a32..84d6cee96da 100644 --- a/lispintro/ChangeLog +++ b/lispintro/ChangeLog | |||
| @@ -1,10 +1,31 @@ | |||
| 1 | 2006-11-04 Robert J. Chassell <bob@rattlesnake.com> | 1 | 2006-11-04 Robert J. Chassell <bob@rattlesnake.com> |
| 2 | 2 | ||
| 3 | * emacs-lisp-intro.texi: Replace 22.0.100 with 22.1.100. | 3 | * emacs-lisp-intro.texi: Replace 22.0.100 with 22.1.100. |
| 4 | (defcustom): Note that the value set by defconst is a variable. | 4 | (defcustom): Note that the value set by defconst is a variable. |
| 5 | (Buffer Size & Locations): Parenthetical remark about evaluation. | 5 | (Buffer Size & Locations): Parenthetical remark about evaluation. |
| 6 | (Finding More): Change text to include C sources by inference. | 6 | (Finding More): Change text to include C sources by inference. |
| 7 | 7 | ||
| 8 | * emacs-lisp-intro.texi: Minor fixes. | ||
| 9 | Replace all tabs with eight spaces each so printed text looks correct. | ||
| 10 | Remove extraneous comma in a printed node name produced by `ref'. | ||
| 11 | (insert-buffer): Add a missing beginning parenthesis. | ||
| 12 | (beginning-of-buffer): Add `beginning of' to note about accessible | ||
| 13 | portion. | ||
| 14 | (narrow Exercise): Write closing parenthesis at end of correct | ||
| 15 | paragraph. | ||
| 16 | (zap-to-char): Remove extraneous `a' from first sentence. | ||
| 17 | (Complete zap-to-char): Remove two extraneous sentences. | ||
| 18 | (zap-to-char body): Move sentences on documentation two nodes earlier. | ||
| 19 | (Lisp macro): Add definition of `unless' macro. | ||
| 20 | (last-command & this-command): Remove comment that `we have not yet | ||
| 21 | seen' the @code{eq} function. | ||
| 22 | (kill-append function): Reformat `kill-append' function definition so | ||
| 23 | it prints well. | ||
| 24 | (kill-new function): Indent the sentence beginning `notice'. Replace | ||
| 25 | `the same as' with `similar to'. Repair typo. Remove obsolete | ||
| 26 | references to `yank' and `yank-pop. End section with a note that `we | ||
| 27 | will digress into C.' | ||
| 28 | |||
| 8 | 2006-11-02 Robert J. Chassell <bob@rattlesnake.com> | 29 | 2006-11-02 Robert J. Chassell <bob@rattlesnake.com> |
| 9 | 30 | ||
| 10 | * emacs-lisp-intro.texi (kill-ring-yank-pointer): Revert addition | 31 | * emacs-lisp-intro.texi (kill-ring-yank-pointer): Revert addition |
diff --git a/lispintro/emacs-lisp-intro.texi b/lispintro/emacs-lisp-intro.texi index 1cf5a9fd977..3d954f6f942 100644 --- a/lispintro/emacs-lisp-intro.texi +++ b/lispintro/emacs-lisp-intro.texi | |||
| @@ -183,7 +183,11 @@ | |||
| 183 | @c in the Texinfo version 4.6 of the 2003 Jun 13 distribution. | 183 | @c in the Texinfo version 4.6 of the 2003 Jun 13 distribution. |
| 184 | 184 | ||
| 185 | @tex | 185 | @tex |
| 186 | \global\def\xrefprintnodename#1{\unskip, ``#1''} | 186 | \if \xrefprintnodename |
| 187 | \global\def\xrefprintnodename#1{\unskip, ``#1''} | ||
| 188 | \else | ||
| 189 | \global\def\xrefprintnodename#1{ ``#1''} | ||
| 190 | \fi | ||
| 187 | % \global\def\xrefprintnodename#1{, ``#1''} | 191 | % \global\def\xrefprintnodename#1{, ``#1''} |
| 188 | @end tex | 192 | @end tex |
| 189 | 193 | ||
| @@ -192,7 +196,7 @@ | |||
| 192 | @dircategory Emacs | 196 | @dircategory Emacs |
| 193 | @direntry | 197 | @direntry |
| 194 | * Emacs Lisp Intro: (eintr). | 198 | * Emacs Lisp Intro: (eintr). |
| 195 | A simple introduction to Emacs Lisp programming. | 199 | A simple introduction to Emacs Lisp programming. |
| 196 | @end direntry | 200 | @end direntry |
| 197 | 201 | ||
| 198 | @copying | 202 | @copying |
| @@ -5067,21 +5071,21 @@ START and END specify the portion of the current buffer to be copied." | |||
| 5067 | (interactive | 5071 | (interactive |
| 5068 | (list (read-buffer "Append to buffer: " (other-buffer | 5072 | (list (read-buffer "Append to buffer: " (other-buffer |
| 5069 | (current-buffer) t)) | 5073 | (current-buffer) t)) |
| 5070 | (region-beginning) (region-end))) | 5074 | (region-beginning) (region-end))) |
| 5071 | @end group | 5075 | @end group |
| 5072 | @group | 5076 | @group |
| 5073 | (let ((oldbuf (current-buffer))) | 5077 | (let ((oldbuf (current-buffer))) |
| 5074 | (save-excursion | 5078 | (save-excursion |
| 5075 | (let* ((append-to (get-buffer-create buffer)) | 5079 | (let* ((append-to (get-buffer-create buffer)) |
| 5076 | (windows (get-buffer-window-list append-to t t)) | 5080 | (windows (get-buffer-window-list append-to t t)) |
| 5077 | point) | 5081 | point) |
| 5078 | (set-buffer append-to) | 5082 | (set-buffer append-to) |
| 5079 | (setq point (point)) | 5083 | (setq point (point)) |
| 5080 | (barf-if-buffer-read-only) | 5084 | (barf-if-buffer-read-only) |
| 5081 | (insert-buffer-substring oldbuf start end) | 5085 | (insert-buffer-substring oldbuf start end) |
| 5082 | (dolist (window windows) | 5086 | (dolist (window windows) |
| 5083 | (when (= (window-point window) point) | 5087 | (when (= (window-point window) point) |
| 5084 | (set-window-point window (point)))))))) | 5088 | (set-window-point window (point)))))))) |
| 5085 | @end group | 5089 | @end group |
| 5086 | @end smallexample | 5090 | @end smallexample |
| 5087 | 5091 | ||
| @@ -5123,12 +5127,14 @@ review of @code{interactive}, see @ref{Interactive, , Making a | |||
| 5123 | Function Interactive}.) The expression reads as follows: | 5127 | Function Interactive}.) The expression reads as follows: |
| 5124 | 5128 | ||
| 5125 | @smallexample | 5129 | @smallexample |
| 5130 | @group | ||
| 5126 | (interactive | 5131 | (interactive |
| 5127 | (list (read-buffer | 5132 | (list (read-buffer |
| 5128 | "Append to buffer: " | 5133 | "Append to buffer: " |
| 5129 | (other-buffer (current-buffer) t)) | 5134 | (other-buffer (current-buffer) t)) |
| 5130 | (region-beginning) | 5135 | (region-beginning) |
| 5131 | (region-end))) | 5136 | (region-end))) |
| 5137 | @end group | ||
| 5132 | @end smallexample | 5138 | @end smallexample |
| 5133 | 5139 | ||
| 5134 | @noindent | 5140 | @noindent |
| @@ -5196,19 +5202,19 @@ BUFFER (or buffer name), START and END. | |||
| 5196 | START and END specify the portion of the current buffer to be copied." | 5202 | START and END specify the portion of the current buffer to be copied." |
| 5197 | (interactive | 5203 | (interactive |
| 5198 | (list (read-buffer "Append to buffer: " (other-buffer (current-buffer) t)) | 5204 | (list (read-buffer "Append to buffer: " (other-buffer (current-buffer) t)) |
| 5199 | (region-beginning) (region-end))) | 5205 | (region-beginning) (region-end))) |
| 5200 | (let ((oldbuf (current-buffer))) | 5206 | (let ((oldbuf (current-buffer))) |
| 5201 | (save-excursion | 5207 | (save-excursion |
| 5202 | (let* ((append-to (get-buffer-create buffer)) | 5208 | (let* ((append-to (get-buffer-create buffer)) |
| 5203 | (windows (get-buffer-window-list append-to t t)) | 5209 | (windows (get-buffer-window-list append-to t t)) |
| 5204 | point) | 5210 | point) |
| 5205 | (set-buffer append-to) | 5211 | (set-buffer append-to) |
| 5206 | (setq point (point)) | 5212 | (setq point (point)) |
| 5207 | (barf-if-buffer-read-only) | 5213 | (barf-if-buffer-read-only) |
| 5208 | (insert-buffer-substring oldbuf start end) | 5214 | (insert-buffer-substring oldbuf start end) |
| 5209 | (dolist (window windows) | 5215 | (dolist (window windows) |
| 5210 | (when (= (window-point window) point) | 5216 | (when (= (window-point window) point) |
| 5211 | (set-window-point window (point)))))))) | 5217 | (set-window-point window (point)))))))) |
| 5212 | @end ignore | 5218 | @end ignore |
| 5213 | 5219 | ||
| 5214 | The body of the @code{append-to-buffer} function begins with @code{let}. | 5220 | The body of the @code{append-to-buffer} function begins with @code{let}. |
| @@ -5391,15 +5397,15 @@ in GNU Emacs 22 | |||
| 5391 | (let ((oldbuf (current-buffer))) | 5397 | (let ((oldbuf (current-buffer))) |
| 5392 | (save-excursion | 5398 | (save-excursion |
| 5393 | (let* ((append-to (get-buffer-create buffer)) | 5399 | (let* ((append-to (get-buffer-create buffer)) |
| 5394 | (windows (get-buffer-window-list append-to t t)) | 5400 | (windows (get-buffer-window-list append-to t t)) |
| 5395 | point) | 5401 | point) |
| 5396 | (set-buffer append-to) | 5402 | (set-buffer append-to) |
| 5397 | (setq point (point)) | 5403 | (setq point (point)) |
| 5398 | (barf-if-buffer-read-only) | 5404 | (barf-if-buffer-read-only) |
| 5399 | (insert-buffer-substring oldbuf start end) | 5405 | (insert-buffer-substring oldbuf start end) |
| 5400 | (dolist (window windows) | 5406 | (dolist (window windows) |
| 5401 | (when (= (window-point window) point) | 5407 | (when (= (window-point window) point) |
| 5402 | (set-window-point window (point)))))))) | 5408 | (set-window-point window (point)))))))) |
| 5403 | @end ignore | 5409 | @end ignore |
| 5404 | 5410 | ||
| 5405 | The @code{append-to-buffer} function definition inserts text from the | 5411 | The @code{append-to-buffer} function definition inserts text from the |
| @@ -5640,7 +5646,7 @@ copy a region of text @emph{from} the current buffer to another buffer. | |||
| 5640 | Here is a discussion based on the original code. The code was | 5646 | Here is a discussion based on the original code. The code was |
| 5641 | simplified in 2003 and is harder to understand. | 5647 | simplified in 2003 and is harder to understand. |
| 5642 | 5648 | ||
| 5643 | @xref{New insert-buffer, , New Body for @code{insert-buffer}}, to see | 5649 | (@xref{New insert-buffer, , New Body for @code{insert-buffer}}, to see |
| 5644 | a discussion of the new body.) | 5650 | a discussion of the new body.) |
| 5645 | 5651 | ||
| 5646 | In addition, this code illustrates the use of @code{interactive} with a | 5652 | In addition, this code illustrates the use of @code{interactive} with a |
| @@ -6078,17 +6084,17 @@ This section describes the complex part of the definition. | |||
| 6078 | 6084 | ||
| 6079 | As previously described, when invoked without an argument, | 6085 | As previously described, when invoked without an argument, |
| 6080 | @code{beginning-of-buffer} moves the cursor to the beginning of the | 6086 | @code{beginning-of-buffer} moves the cursor to the beginning of the |
| 6081 | buffer (in truth, the accessible portion of the buffer), leaving the | 6087 | buffer (in truth, the beginning of the accessible portion of the |
| 6082 | mark at the previous position. However, when the command is invoked | 6088 | buffer), leaving the mark at the previous position. However, when the |
| 6083 | with a number between one and ten, the function considers that number | 6089 | command is invoked with a number between one and ten, the function |
| 6084 | to be a fraction of the length of the buffer, measured in tenths, and | 6090 | considers that number to be a fraction of the length of the buffer, |
| 6085 | Emacs moves the cursor that fraction of the way from the beginning of | 6091 | measured in tenths, and Emacs moves the cursor that fraction of the |
| 6086 | the buffer. Thus, you can either call this function with the key | 6092 | way from the beginning of the buffer. Thus, you can either call this |
| 6087 | command @kbd{M-<}, which will move the cursor to the beginning of the | 6093 | function with the key command @kbd{M-<}, which will move the cursor to |
| 6088 | buffer, or with a key command such as @kbd{C-u 7 M-<} which will move | 6094 | the beginning of the buffer, or with a key command such as @kbd{C-u 7 |
| 6089 | the cursor to a point 70% of the way through the buffer. If a number | 6095 | M-<} which will move the cursor to a point 70% of the way through the |
| 6090 | bigger than ten is used for the argument, it moves to the end of the | 6096 | buffer. If a number bigger than ten is used for the argument, it |
| 6091 | buffer. | 6097 | moves to the end of the buffer. |
| 6092 | 6098 | ||
| 6093 | The @code{beginning-of-buffer} function can be called with or without an | 6099 | The @code{beginning-of-buffer} function can be called with or without an |
| 6094 | argument. The use of the argument is optional. | 6100 | argument. The use of the argument is optional. |
| @@ -6195,8 +6201,8 @@ like this: | |||
| 6195 | @group | 6201 | @group |
| 6196 | (if (> (buffer-size) 10000) | 6202 | (if (> (buffer-size) 10000) |
| 6197 | ;; @r{Avoid overflow for large buffer sizes!} | 6203 | ;; @r{Avoid overflow for large buffer sizes!} |
| 6198 | (* (prefix-numeric-value arg) | 6204 | (* (prefix-numeric-value arg) |
| 6199 | (/ size 10)) | 6205 | (/ size 10)) |
| 6200 | (/ | 6206 | (/ |
| 6201 | (+ 10 | 6207 | (+ 10 |
| 6202 | (* | 6208 | (* |
| @@ -6418,13 +6424,13 @@ and avoids clobbering the mark." | |||
| 6418 | @group | 6424 | @group |
| 6419 | (let ((size (- (point-max) (point-min)))) | 6425 | (let ((size (- (point-max) (point-min)))) |
| 6420 | (goto-char (if (and arg (not (consp arg))) | 6426 | (goto-char (if (and arg (not (consp arg))) |
| 6421 | (+ (point-min) | 6427 | (+ (point-min) |
| 6422 | (if (> size 10000) | 6428 | (if (> size 10000) |
| 6423 | ;; Avoid overflow for large buffer sizes! | 6429 | ;; Avoid overflow for large buffer sizes! |
| 6424 | (* (prefix-numeric-value arg) | 6430 | (* (prefix-numeric-value arg) |
| 6425 | (/ size 10)) | 6431 | (/ size 10)) |
| 6426 | (/ (+ 10 (* size (prefix-numeric-value arg))) 10))) | 6432 | (/ (+ 10 (* size (prefix-numeric-value arg))) 10))) |
| 6427 | (point-min)))) | 6433 | (point-min)))) |
| 6428 | (if arg (forward-line 1))) | 6434 | (if arg (forward-line 1))) |
| 6429 | @end group | 6435 | @end group |
| 6430 | @end smallexample | 6436 | @end smallexample |
| @@ -6689,14 +6695,14 @@ Emacs 22 | |||
| 6689 | "Print the current buffer line number and narrowed line number of point." | 6695 | "Print the current buffer line number and narrowed line number of point." |
| 6690 | (interactive) | 6696 | (interactive) |
| 6691 | (let ((start (point-min)) | 6697 | (let ((start (point-min)) |
| 6692 | (n (line-number-at-pos))) | 6698 | (n (line-number-at-pos))) |
| 6693 | (if (= start 1) | 6699 | (if (= start 1) |
| 6694 | (message "Line %d" n) | 6700 | (message "Line %d" n) |
| 6695 | (save-excursion | 6701 | (save-excursion |
| 6696 | (save-restriction | 6702 | (save-restriction |
| 6697 | (widen) | 6703 | (widen) |
| 6698 | (message "line %d (narrowed line %d)" | 6704 | (message "line %d (narrowed line %d)" |
| 6699 | (+ n (line-number-at-pos start) -1) n)))))) | 6705 | (+ n (line-number-at-pos start) -1) n)))))) |
| 6700 | 6706 | ||
| 6701 | (defun line-number-at-pos (&optional pos) | 6707 | (defun line-number-at-pos (&optional pos) |
| 6702 | "Return (narrowed) buffer line number at position POS. | 6708 | "Return (narrowed) buffer line number at position POS. |
| @@ -6721,18 +6727,18 @@ and the greater of them is not at the start of a line." | |||
| 6721 | (narrow-to-region start end) | 6727 | (narrow-to-region start end) |
| 6722 | (goto-char (point-min)) | 6728 | (goto-char (point-min)) |
| 6723 | (if (eq selective-display t) | 6729 | (if (eq selective-display t) |
| 6724 | (save-match-data | 6730 | (save-match-data |
| 6725 | (let ((done 0)) | 6731 | (let ((done 0)) |
| 6726 | (while (re-search-forward "[\n\C-m]" nil t 40) | 6732 | (while (re-search-forward "[\n\C-m]" nil t 40) |
| 6727 | (setq done (+ 40 done))) | 6733 | (setq done (+ 40 done))) |
| 6728 | (while (re-search-forward "[\n\C-m]" nil t 1) | 6734 | (while (re-search-forward "[\n\C-m]" nil t 1) |
| 6729 | (setq done (+ 1 done))) | 6735 | (setq done (+ 1 done))) |
| 6730 | (goto-char (point-max)) | 6736 | (goto-char (point-max)) |
| 6731 | (if (and (/= start end) | 6737 | (if (and (/= start end) |
| 6732 | (not (bolp))) | 6738 | (not (bolp))) |
| 6733 | (1+ done) | 6739 | (1+ done) |
| 6734 | done))) | 6740 | done))) |
| 6735 | (- (buffer-size) (forward-line (buffer-size))))))) | 6741 | (- (buffer-size) (forward-line (buffer-size))))))) |
| 6736 | @end ignore | 6742 | @end ignore |
| 6737 | 6743 | ||
| 6738 | @node what-line, narrow Exercise, save-restriction, Narrowing & Widening | 6744 | @node what-line, narrow Exercise, save-restriction, Narrowing & Widening |
| @@ -6842,18 +6848,18 @@ and the greater of them is not at the start of a line." | |||
| 6842 | (narrow-to-region start end) | 6848 | (narrow-to-region start end) |
| 6843 | (goto-char (point-min)) | 6849 | (goto-char (point-min)) |
| 6844 | (if (eq selective-display t) | 6850 | (if (eq selective-display t) |
| 6845 | (save-match-data | 6851 | (save-match-data |
| 6846 | (let ((done 0)) | 6852 | (let ((done 0)) |
| 6847 | (while (re-search-forward "[\n\C-m]" nil t 40) | 6853 | (while (re-search-forward "[\n\C-m]" nil t 40) |
| 6848 | (setq done (+ 40 done))) | 6854 | (setq done (+ 40 done))) |
| 6849 | (while (re-search-forward "[\n\C-m]" nil t 1) | 6855 | (while (re-search-forward "[\n\C-m]" nil t 1) |
| 6850 | (setq done (+ 1 done))) | 6856 | (setq done (+ 1 done))) |
| 6851 | (goto-char (point-max)) | 6857 | (goto-char (point-max)) |
| 6852 | (if (and (/= start end) | 6858 | (if (and (/= start end) |
| 6853 | (not (bolp))) | 6859 | (not (bolp))) |
| 6854 | (1+ done) | 6860 | (1+ done) |
| 6855 | done))) | 6861 | done))) |
| 6856 | (- (buffer-size) (forward-line (buffer-size))))))) | 6862 | (- (buffer-size) (forward-line (buffer-size))))))) |
| 6857 | @end ignore | 6863 | @end ignore |
| 6858 | 6864 | ||
| 6859 | @noindent | 6865 | @noindent |
| @@ -6887,10 +6893,10 @@ have to investigate yourself; or perhaps you will have to use | |||
| 6887 | @code{filter-buffer-substring} @dots{}, yet other functions. Text | 6893 | @code{filter-buffer-substring} @dots{}, yet other functions. Text |
| 6888 | properties are a feature otherwise not discussed here. @xref{Text | 6894 | properties are a feature otherwise not discussed here. @xref{Text |
| 6889 | Properties, , Text Properties, elisp, The GNU Emacs Lisp Reference | 6895 | Properties, , Text Properties, elisp, The GNU Emacs Lisp Reference |
| 6890 | Manual}. | 6896 | Manual}.) |
| 6891 | 6897 | ||
| 6892 | Additionally, do you really need @code{goto-char} or @code{point-min}? | 6898 | Additionally, do you really need @code{goto-char} or @code{point-min}? |
| 6893 | Or can you write the function without them?) | 6899 | Or can you write the function without them? |
| 6894 | 6900 | ||
| 6895 | @node car cdr & cons, Cutting & Storing Text, Narrowing & Widening, Top | 6901 | @node car cdr & cons, Cutting & Storing Text, Narrowing & Widening, Top |
| 6896 | @comment node-name, next, previous, up | 6902 | @comment node-name, next, previous, up |
| @@ -7658,7 +7664,7 @@ retrieved. @xref{Yanking, , Yanking Text Back}. | |||
| 7658 | @section @code{zap-to-char} | 7664 | @section @code{zap-to-char} |
| 7659 | @findex zap-to-char | 7665 | @findex zap-to-char |
| 7660 | 7666 | ||
| 7661 | The @code{zap-to-char} function changed a little between GNU Emacs | 7667 | The @code{zap-to-char} function changed little between GNU Emacs |
| 7662 | version 19 and GNU Emacs version 22. However, @code{zap-to-char} | 7668 | version 19 and GNU Emacs version 22. However, @code{zap-to-char} |
| 7663 | calls another function, @code{kill-region}, which enjoyed a major | 7669 | calls another function, @code{kill-region}, which enjoyed a major |
| 7664 | rewrite. | 7670 | rewrite. |
| @@ -7686,18 +7692,16 @@ But first, let us look at the interactive @code{zap-to-char} function. | |||
| 7686 | @unnumberedsubsec The Complete @code{zap-to-char} Implementation | 7692 | @unnumberedsubsec The Complete @code{zap-to-char} Implementation |
| 7687 | @end ifnottex | 7693 | @end ifnottex |
| 7688 | 7694 | ||
| 7689 | The GNU Emacs version 19 and version 21 implementations of the | 7695 | The @code{zap-to-char} function removes the text in the region between |
| 7690 | @code{zap-to-char} function are nearly identical in form, and they | 7696 | the location of the cursor (i.e., of point) up to and including the |
| 7691 | work alike. The function removes the text in the region between the | 7697 | next occurrence of a specified character. The text that |
| 7692 | location of the cursor (i.e., of point) up to and including the next | 7698 | @code{zap-to-char} removes is put in the kill ring; and it can be |
| 7693 | occurrence of a specified character. The text that @code{zap-to-char} | 7699 | retrieved from the kill ring by typing @kbd{C-y} (@code{yank}). If |
| 7694 | removes is put in the kill ring; and it can be retrieved from the kill | 7700 | the command is given an argument, it removes text through that number |
| 7695 | ring by typing @kbd{C-y} (@code{yank}). If the command is given an | 7701 | of occurrences. Thus, if the cursor were at the beginning of this |
| 7696 | argument, it removes text through that number of occurrences. Thus, | 7702 | sentence and the character were @samp{s}, @samp{Thus} would be |
| 7697 | if the cursor were at the beginning of this sentence and the character | 7703 | removed. If the argument were two, @samp{Thus, if the curs} would be |
| 7698 | were @samp{s}, @samp{Thus} would be removed. If the argument were | 7704 | removed, up to and including the @samp{s} in @samp{cursor}. |
| 7699 | two, @samp{Thus, if the curs} would be removed, up to and including | ||
| 7700 | the @samp{s} in @samp{cursor}. | ||
| 7701 | 7705 | ||
| 7702 | If the specified character is not found, @code{zap-to-char} will say | 7706 | If the specified character is not found, @code{zap-to-char} will say |
| 7703 | ``Search failed'', tell you the character you typed, and not remove | 7707 | ``Search failed'', tell you the character you typed, and not remove |
| @@ -7735,11 +7739,14 @@ Goes backward if ARG is negative; error if CHAR not found." | |||
| 7735 | (if (char-table-p translation-table-for-input) | 7739 | (if (char-table-p translation-table-for-input) |
| 7736 | (setq char (or (aref translation-table-for-input char) char))) | 7740 | (setq char (or (aref translation-table-for-input char) char))) |
| 7737 | (kill-region (point) (progn | 7741 | (kill-region (point) (progn |
| 7738 | (search-forward (char-to-string char) nil nil arg) | 7742 | (search-forward (char-to-string char) nil nil arg) |
| 7739 | (point)))) | 7743 | (point)))) |
| 7740 | @end group | 7744 | @end group |
| 7741 | @end smallexample | 7745 | @end smallexample |
| 7742 | 7746 | ||
| 7747 | The documentation is thorough. You do need to know the jargon meaning | ||
| 7748 | of the word `kill'. | ||
| 7749 | |||
| 7743 | @node zap-to-char interactive, zap-to-char body, Complete zap-to-char, zap-to-char | 7750 | @node zap-to-char interactive, zap-to-char body, Complete zap-to-char, zap-to-char |
| 7744 | @comment node-name, next, previous, up | 7751 | @comment node-name, next, previous, up |
| 7745 | @subsection The @code{interactive} Expression | 7752 | @subsection The @code{interactive} Expression |
| @@ -7776,8 +7783,6 @@ to the kill ring, but does not remove it. The echo area displays a | |||
| 7776 | message saying that the buffer is read-only. Also, the terminal may | 7783 | message saying that the buffer is read-only. Also, the terminal may |
| 7777 | beep or blink at you. | 7784 | beep or blink at you. |
| 7778 | 7785 | ||
| 7779 | Let us continue with the interactive specification. | ||
| 7780 | |||
| 7781 | @node zap-to-char body, search-forward, zap-to-char interactive, zap-to-char | 7786 | @node zap-to-char body, search-forward, zap-to-char interactive, zap-to-char |
| 7782 | @comment node-name, next, previous, up | 7787 | @comment node-name, next, previous, up |
| 7783 | @subsection The Body of @code{zap-to-char} | 7788 | @subsection The Body of @code{zap-to-char} |
| @@ -7786,9 +7791,6 @@ The body of the @code{zap-to-char} function contains the code that | |||
| 7786 | kills (that is, removes) the text in the region from the current | 7791 | kills (that is, removes) the text in the region from the current |
| 7787 | position of the cursor up to and including the specified character. | 7792 | position of the cursor up to and including the specified character. |
| 7788 | 7793 | ||
| 7789 | The documentation is thorough. You do need to know the jargon meaning | ||
| 7790 | of the word `kill'. | ||
| 7791 | |||
| 7792 | The first part of the code looks like this: | 7794 | The first part of the code looks like this: |
| 7793 | 7795 | ||
| 7794 | @smallexample | 7796 | @smallexample |
| @@ -8002,14 +8004,14 @@ text. See `insert-for-yank'." | |||
| 8002 | (error "The mark is not set now, so there is no region")) | 8004 | (error "The mark is not set now, so there is no region")) |
| 8003 | (condition-case nil | 8005 | (condition-case nil |
| 8004 | (let ((string (filter-buffer-substring beg end t))) | 8006 | (let ((string (filter-buffer-substring beg end t))) |
| 8005 | (when string ;STRING is nil if BEG = END | 8007 | (when string ;STRING is nil if BEG = END |
| 8006 | ;; Add that string to the kill ring, one way or another. | 8008 | ;; Add that string to the kill ring, one way or another. |
| 8007 | (if (eq last-command 'kill-region) | 8009 | (if (eq last-command 'kill-region) |
| 8008 | (kill-append string (< end beg) yank-handler) | 8010 | (kill-append string (< end beg) yank-handler) |
| 8009 | (kill-new string nil yank-handler))) | 8011 | (kill-new string nil yank-handler))) |
| 8010 | (when (or string (eq last-command 'kill-region)) | 8012 | (when (or string (eq last-command 'kill-region)) |
| 8011 | (setq this-command 'kill-region)) | 8013 | (setq this-command 'kill-region)) |
| 8012 | nil) | 8014 | nil) |
| 8013 | ((buffer-read-only text-read-only) | 8015 | ((buffer-read-only text-read-only) |
| 8014 | ;; The code above failed because the buffer, or some of the characters | 8016 | ;; The code above failed because the buffer, or some of the characters |
| 8015 | ;; in the region, are read-only. | 8017 | ;; in the region, are read-only. |
| @@ -8021,7 +8023,7 @@ text. See `insert-for-yank'." | |||
| 8021 | (setq this-command 'kill-region) | 8023 | (setq this-command 'kill-region) |
| 8022 | ;; This should barf, if appropriate, and give us the correct error. | 8024 | ;; This should barf, if appropriate, and give us the correct error. |
| 8023 | (if kill-read-only-ok | 8025 | (if kill-read-only-ok |
| 8024 | (progn (message "Read only text copied to kill ring") nil) | 8026 | (progn (message "Read only text copied to kill ring") nil) |
| 8025 | ;; Signal an error if the buffer is read-only. | 8027 | ;; Signal an error if the buffer is read-only. |
| 8026 | (barf-if-buffer-read-only) | 8028 | (barf-if-buffer-read-only) |
| 8027 | ;; If the buffer isn't read-only, the text is. | 8029 | ;; If the buffer isn't read-only, the text is. |
| @@ -8067,6 +8069,7 @@ The command \\[yank] can retrieve it from there. @dots{} " | |||
| 8067 | ;; @bullet{} Since order matters, pass point first. | 8069 | ;; @bullet{} Since order matters, pass point first. |
| 8068 | (interactive (list (point) (mark))) | 8070 | (interactive (list (point) (mark))) |
| 8069 | ;; @bullet{} And tell us if we cannot cut the text. | 8071 | ;; @bullet{} And tell us if we cannot cut the text. |
| 8072 | ;; `unless' is an `if' without a then-part. | ||
| 8070 | (unless (and beg end) | 8073 | (unless (and beg end) |
| 8071 | (error "The mark is not set now, so there is no region")) | 8074 | (error "The mark is not set now, so there is no region")) |
| 8072 | @end group | 8075 | @end group |
| @@ -8110,7 +8113,7 @@ The command \\[yank] can retrieve it from there. @dots{} " | |||
| 8110 | @end group | 8113 | @end group |
| 8111 | @group | 8114 | @group |
| 8112 | (let ((string (filter-buffer-substring beg end t))) | 8115 | (let ((string (filter-buffer-substring beg end t))) |
| 8113 | (when string ;STRING is nil if BEG = END | 8116 | (when string ;STRING is nil if BEG = END |
| 8114 | ;; Add that string to the kill ring, one way or another. | 8117 | ;; Add that string to the kill ring, one way or another. |
| 8115 | (if (eq last-command 'kill-region) | 8118 | (if (eq last-command 'kill-region) |
| 8116 | @end group | 8119 | @end group |
| @@ -8120,10 +8123,10 @@ The command \\[yank] can retrieve it from there. @dots{} " | |||
| 8120 | ;; `kill-new' functions how deal with properties | 8123 | ;; `kill-new' functions how deal with properties |
| 8121 | ;; added to the text, such as `bold' or `italics'. | 8124 | ;; added to the text, such as `bold' or `italics'. |
| 8122 | (kill-append string (< end beg) yank-handler) | 8125 | (kill-append string (< end beg) yank-handler) |
| 8123 | (kill-new string nil yank-handler))) | 8126 | (kill-new string nil yank-handler))) |
| 8124 | (when (or string (eq last-command 'kill-region)) | 8127 | (when (or string (eq last-command 'kill-region)) |
| 8125 | (setq this-command 'kill-region)) | 8128 | (setq this-command 'kill-region)) |
| 8126 | nil) | 8129 | nil) |
| 8127 | @end group | 8130 | @end group |
| 8128 | 8131 | ||
| 8129 | @group | 8132 | @group |
| @@ -8338,10 +8341,15 @@ Technically speaking, @code{when} is a Lisp macro. A Lisp @dfn{macro} | |||
| 8338 | enables you to define new control constructs and other language | 8341 | enables you to define new control constructs and other language |
| 8339 | features. It tells the interpreter how to compute another Lisp | 8342 | features. It tells the interpreter how to compute another Lisp |
| 8340 | expression which will in turn compute the value. In this case, the | 8343 | expression which will in turn compute the value. In this case, the |
| 8341 | `other expression' is an @code{if} expression. For more about Lisp | 8344 | `other expression' is an @code{if} expression. |
| 8342 | macros, see @ref{Macros, , Macros, elisp, The GNU Emacs Lisp Reference | 8345 | |
| 8343 | Manual}. The C programming language also provides macros. These are | 8346 | The @code{kill-region} function definition also has an @code{unless} |
| 8344 | different, but also useful. | 8347 | macro; it is the converse of @code{when}. The @code{unless} macro is |
| 8348 | an @code{if} without a then clause | ||
| 8349 | |||
| 8350 | For more about Lisp macros, see @ref{Macros, , Macros, elisp, The GNU | ||
| 8351 | Emacs Lisp Reference Manual}. The C programming language also | ||
| 8352 | provides macros. These are different, but also useful. | ||
| 8345 | 8353 | ||
| 8346 | @ignore | 8354 | @ignore |
| 8347 | We will briefly look at C macros in | 8355 | We will briefly look at C macros in |
| @@ -8349,8 +8357,10 @@ We will briefly look at C macros in | |||
| 8349 | @end ignore | 8357 | @end ignore |
| 8350 | 8358 | ||
| 8351 | @need 1200 | 8359 | @need 1200 |
| 8352 | If the string has content, then another conditional expression is | 8360 | Regarding the @code{when} macro, in the @code{condition-case} |
| 8353 | executed. This is an @code{if} with both a then-part and an else-part. | 8361 | expression, when the string has content, then another conditional |
| 8362 | expression is executed. This is an @code{if} with both a then-part | ||
| 8363 | and an else-part. | ||
| 8354 | 8364 | ||
| 8355 | @smallexample | 8365 | @smallexample |
| 8356 | @group | 8366 | @group |
| @@ -8531,8 +8541,7 @@ attaches a new element to the kill ring using the @code{kill-new} | |||
| 8531 | function. | 8541 | function. |
| 8532 | 8542 | ||
| 8533 | @need 1250 | 8543 | @need 1250 |
| 8534 | The @code{if} expression reads as follows; it uses @code{eq}, which is | 8544 | The @code{if} expression reads as follows; it uses @code{eq}: |
| 8535 | a function we have not yet seen: | ||
| 8536 | 8545 | ||
| 8537 | @smallexample | 8546 | @smallexample |
| 8538 | @group | 8547 | @group |
| @@ -8581,9 +8590,10 @@ If BEFORE-P is non-nil, prepend STRING to the kill. | |||
| 8581 | @dots{} " | 8590 | @dots{} " |
| 8582 | (let* ((cur (car kill-ring))) | 8591 | (let* ((cur (car kill-ring))) |
| 8583 | (kill-new (if before-p (concat string cur) (concat cur string)) | 8592 | (kill-new (if before-p (concat string cur) (concat cur string)) |
| 8584 | (or (= (length cur) 0) | 8593 | (or (= (length cur) 0) |
| 8585 | (equal yank-handler (get-text-property 0 'yank-handler cur))) | 8594 | (equal yank-handler |
| 8586 | yank-handler))) | 8595 | (get-text-property 0 'yank-handler cur))) |
| 8596 | yank-handler))) | ||
| 8587 | @end group | 8597 | @end group |
| 8588 | @end smallexample | 8598 | @end smallexample |
| 8589 | 8599 | ||
| @@ -8729,11 +8739,11 @@ the front of the kill ring, rather than being added to the list. | |||
| 8729 | @group | 8739 | @group |
| 8730 | (if (> (length string) 0) | 8740 | (if (> (length string) 0) |
| 8731 | (if yank-handler | 8741 | (if yank-handler |
| 8732 | (put-text-property 0 (length string) | 8742 | (put-text-property 0 (length string) |
| 8733 | 'yank-handler yank-handler string)) | 8743 | 'yank-handler yank-handler string)) |
| 8734 | (if yank-handler | 8744 | (if yank-handler |
| 8735 | (signal 'args-out-of-range | 8745 | (signal 'args-out-of-range |
| 8736 | (list string "yank-handler specified for empty string")))) | 8746 | (list string "yank-handler specified for empty string")))) |
| 8737 | @end group | 8747 | @end group |
| 8738 | @group | 8748 | @group |
| 8739 | (if (fboundp 'menu-bar-update-yank-menu) | 8749 | (if (fboundp 'menu-bar-update-yank-menu) |
| @@ -8744,7 +8754,7 @@ the front of the kill ring, rather than being added to the list. | |||
| 8744 | (setcar kill-ring string) | 8754 | (setcar kill-ring string) |
| 8745 | (push string kill-ring) | 8755 | (push string kill-ring) |
| 8746 | (if (> (length kill-ring) kill-ring-max) | 8756 | (if (> (length kill-ring) kill-ring-max) |
| 8747 | (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))) | 8757 | (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))) |
| 8748 | @end group | 8758 | @end group |
| 8749 | @group | 8759 | @group |
| 8750 | (setq kill-ring-yank-pointer kill-ring) | 8760 | (setq kill-ring-yank-pointer kill-ring) |
| @@ -8772,7 +8782,6 @@ the front of the kill ring, rather than being added to the list." | |||
| 8772 | (funcall interprogram-cut-function string (not replace)))) | 8782 | (funcall interprogram-cut-function string (not replace)))) |
| 8773 | @end ignore | 8783 | @end ignore |
| 8774 | 8784 | ||
| 8775 | @noindent | ||
| 8776 | (Notice that the function is not interactive.) | 8785 | (Notice that the function is not interactive.) |
| 8777 | 8786 | ||
| 8778 | As usual, we can look at this function in parts. | 8787 | As usual, we can look at this function in parts. |
| @@ -8848,8 +8857,8 @@ else-part of the condition is executed: | |||
| 8848 | 8857 | ||
| 8849 | @noindent | 8858 | @noindent |
| 8850 | @need 1250 | 8859 | @need 1250 |
| 8851 | @code{push} puts its first argument onto the second. It is the same | 8860 | @code{push} puts its first argument onto the second. It is similar to |
| 8852 | as the older | 8861 | the older |
| 8853 | 8862 | ||
| 8854 | @smallexample | 8863 | @smallexample |
| 8855 | (setq kill-ring (cons string kill-ring)) | 8864 | (setq kill-ring (cons string kill-ring)) |
| @@ -8957,7 +8966,7 @@ list---it takes the @sc{cdr} of the @sc{cdr} of the @sc{cdr} | |||
| 8957 | @findex setcdr, @r{example} | 8966 | @findex setcdr, @r{example} |
| 8958 | Thus, if we had a four element list that was supposed to be three | 8967 | Thus, if we had a four element list that was supposed to be three |
| 8959 | elements long, we could set the @sc{cdr} of the next to last element | 8968 | elements long, we could set the @sc{cdr} of the next to last element |
| 8960 | to @code{nil}, and thereby shorten the list. (If you sent the last | 8969 | to @code{nil}, and thereby shorten the list. (If you set the last |
| 8961 | element to some other value than @code{nil}, which you could do, then | 8970 | element to some other value than @code{nil}, which you could do, then |
| 8962 | you would not have shortened the list. @xref{setcdr, , | 8971 | you would not have shortened the list. @xref{setcdr, , |
| 8963 | @code{setcdr}}.) | 8972 | @code{setcdr}}.) |
| @@ -9005,8 +9014,6 @@ the @code{kill-ring}. | |||
| 9005 | Even though the @code{kill-ring-yank-pointer} is called a | 9014 | Even though the @code{kill-ring-yank-pointer} is called a |
| 9006 | @samp{pointer}, it is a variable just like the kill ring. However, the | 9015 | @samp{pointer}, it is a variable just like the kill ring. However, the |
| 9007 | name has been chosen to help humans understand how the variable is used. | 9016 | name has been chosen to help humans understand how the variable is used. |
| 9008 | The variable is used in functions such as @code{yank} and | ||
| 9009 | @code{yank-pop} (@pxref{Yanking, , Yanking Text Back}). | ||
| 9010 | 9017 | ||
| 9011 | @need 1200 | 9018 | @need 1200 |
| 9012 | Now, to return to an early expression in the body of the function: | 9019 | Now, to return to an early expression in the body of the function: |
| @@ -9087,7 +9094,8 @@ an existing element or as a new element, leads us to the code for | |||
| 9087 | bringing back text that has been cut out of the buffer---the yank | 9094 | bringing back text that has been cut out of the buffer---the yank |
| 9088 | commands. However, before discussing the yank commands, it is better | 9095 | commands. However, before discussing the yank commands, it is better |
| 9089 | to learn how lists are implemented in a computer. This will make | 9096 | to learn how lists are implemented in a computer. This will make |
| 9090 | clear such mysteries as the use of the term `pointer'. | 9097 | clear such mysteries as the use of the term `pointer'. But before |
| 9098 | that, we will digress into C. | ||
| 9091 | 9099 | ||
| 9092 | @ignore | 9100 | @ignore |
| 9093 | @c is this true in Emacs 22? Does not seems to be | 9101 | @c is this true in Emacs 22? Does not seems to be |
| @@ -10270,24 +10278,24 @@ kill ring and returned as the latest kill. | |||
| 10270 | If optional arg DO-NOT-MOVE is non-nil, then don't actually move the | 10278 | If optional arg DO-NOT-MOVE is non-nil, then don't actually move the |
| 10271 | yanking point; just return the Nth kill forward." | 10279 | yanking point; just return the Nth kill forward." |
| 10272 | (let ((interprogram-paste (and (= n 0) | 10280 | (let ((interprogram-paste (and (= n 0) |
| 10273 | interprogram-paste-function | 10281 | interprogram-paste-function |
| 10274 | (funcall interprogram-paste-function)))) | 10282 | (funcall interprogram-paste-function)))) |
| 10275 | (if interprogram-paste | 10283 | (if interprogram-paste |
| 10276 | (progn | 10284 | (progn |
| 10277 | ;; Disable the interprogram cut function when we add the new | 10285 | ;; Disable the interprogram cut function when we add the new |
| 10278 | ;; text to the kill ring, so Emacs doesn't try to own the | 10286 | ;; text to the kill ring, so Emacs doesn't try to own the |
| 10279 | ;; selection, with identical text. | 10287 | ;; selection, with identical text. |
| 10280 | (let ((interprogram-cut-function nil)) | 10288 | (let ((interprogram-cut-function nil)) |
| 10281 | (kill-new interprogram-paste)) | 10289 | (kill-new interprogram-paste)) |
| 10282 | interprogram-paste) | 10290 | interprogram-paste) |
| 10283 | (or kill-ring (error "Kill ring is empty")) | 10291 | (or kill-ring (error "Kill ring is empty")) |
| 10284 | (let ((ARGth-kill-element | 10292 | (let ((ARGth-kill-element |
| 10285 | (nthcdr (mod (- n (length kill-ring-yank-pointer)) | 10293 | (nthcdr (mod (- n (length kill-ring-yank-pointer)) |
| 10286 | (length kill-ring)) | 10294 | (length kill-ring)) |
| 10287 | kill-ring))) | 10295 | kill-ring))) |
| 10288 | (or do-not-move | 10296 | (or do-not-move |
| 10289 | (setq kill-ring-yank-pointer ARGth-kill-element)) | 10297 | (setq kill-ring-yank-pointer ARGth-kill-element)) |
| 10290 | (car ARGth-kill-element))))) | 10298 | (car ARGth-kill-element))))) |
| 10291 | 10299 | ||
| 10292 | @end ignore | 10300 | @end ignore |
| 10293 | 10301 | ||
| @@ -12630,20 +12638,20 @@ sentences. Also, every paragraph boundary terminates sentences as well." | |||
| 12630 | (sentence-end (sentence-end))) | 12638 | (sentence-end (sentence-end))) |
| 12631 | (while (< arg 0) | 12639 | (while (< arg 0) |
| 12632 | (let ((pos (point)) | 12640 | (let ((pos (point)) |
| 12633 | (par-beg (save-excursion (start-of-paragraph-text) (point)))) | 12641 | (par-beg (save-excursion (start-of-paragraph-text) (point)))) |
| 12634 | (if (and (re-search-backward sentence-end par-beg t) | 12642 | (if (and (re-search-backward sentence-end par-beg t) |
| 12635 | (or (< (match-end 0) pos) | 12643 | (or (< (match-end 0) pos) |
| 12636 | (re-search-backward sentence-end par-beg t))) | 12644 | (re-search-backward sentence-end par-beg t))) |
| 12637 | (goto-char (match-end 0)) | 12645 | (goto-char (match-end 0)) |
| 12638 | (goto-char par-beg))) | 12646 | (goto-char par-beg))) |
| 12639 | (setq arg (1+ arg))) | 12647 | (setq arg (1+ arg))) |
| 12640 | @end group | 12648 | @end group |
| 12641 | @group | 12649 | @group |
| 12642 | (while (> arg 0) | 12650 | (while (> arg 0) |
| 12643 | (let ((par-end (save-excursion (end-of-paragraph-text) (point)))) | 12651 | (let ((par-end (save-excursion (end-of-paragraph-text) (point)))) |
| 12644 | (if (re-search-forward sentence-end par-end t) | 12652 | (if (re-search-forward sentence-end par-end t) |
| 12645 | (skip-chars-backward " \t\n") | 12653 | (skip-chars-backward " \t\n") |
| 12646 | (goto-char par-end))) | 12654 | (goto-char par-end))) |
| 12647 | (setq arg (1- arg))) | 12655 | (setq arg (1- arg))) |
| 12648 | (constrain-to-field nil opoint t))) | 12656 | (constrain-to-field nil opoint t))) |
| 12649 | @end group | 12657 | @end group |
| @@ -12695,7 +12703,7 @@ look at the expressions that start in the left-most columns: | |||
| 12695 | (let ((opoint (point)) (sentence-end (sentence-end))) | 12703 | (let ((opoint (point)) (sentence-end (sentence-end))) |
| 12696 | (while (< arg 0) | 12704 | (while (< arg 0) |
| 12697 | (let ((pos (point)) | 12705 | (let ((pos (point)) |
| 12698 | (par-beg (save-excursion (start-of-paragraph-text) (point)))) | 12706 | (par-beg (save-excursion (start-of-paragraph-text) (point)))) |
| 12699 | @var{rest-of-body-of-while-loop-when-going-backwards} | 12707 | @var{rest-of-body-of-while-loop-when-going-backwards} |
| 12700 | (while (> arg 0) | 12708 | (while (> arg 0) |
| 12701 | (let ((par-end (save-excursion (end-of-paragraph-text) (point)))) | 12709 | (let ((par-end (save-excursion (end-of-paragraph-text) (point)))) |
| @@ -12901,131 +12909,131 @@ Returns the count of paragraphs left to move." | |||
| 12901 | (interactive "p") | 12909 | (interactive "p") |
| 12902 | (or arg (setq arg 1)) | 12910 | (or arg (setq arg 1)) |
| 12903 | (let* ((opoint (point)) | 12911 | (let* ((opoint (point)) |
| 12904 | (fill-prefix-regexp | 12912 | (fill-prefix-regexp |
| 12905 | (and fill-prefix (not (equal fill-prefix "")) | 12913 | (and fill-prefix (not (equal fill-prefix "")) |
| 12906 | (not paragraph-ignore-fill-prefix) | 12914 | (not paragraph-ignore-fill-prefix) |
| 12907 | (regexp-quote fill-prefix))) | 12915 | (regexp-quote fill-prefix))) |
| 12908 | ;; Remove ^ from paragraph-start and paragraph-sep if they are there. | 12916 | ;; Remove ^ from paragraph-start and paragraph-sep if they are there. |
| 12909 | ;; These regexps shouldn't be anchored, because we look for them | 12917 | ;; These regexps shouldn't be anchored, because we look for them |
| 12910 | ;; starting at the left-margin. This allows paragraph commands to | 12918 | ;; starting at the left-margin. This allows paragraph commands to |
| 12911 | ;; work normally with indented text. | 12919 | ;; work normally with indented text. |
| 12912 | ;; This hack will not find problem cases like "whatever\\|^something". | 12920 | ;; This hack will not find problem cases like "whatever\\|^something". |
| 12913 | (parstart (if (and (not (equal "" paragraph-start)) | 12921 | (parstart (if (and (not (equal "" paragraph-start)) |
| 12914 | (equal ?^ (aref paragraph-start 0))) | 12922 | (equal ?^ (aref paragraph-start 0))) |
| 12915 | (substring paragraph-start 1) | 12923 | (substring paragraph-start 1) |
| 12916 | paragraph-start)) | 12924 | paragraph-start)) |
| 12917 | (parsep (if (and (not (equal "" paragraph-separate)) | 12925 | (parsep (if (and (not (equal "" paragraph-separate)) |
| 12918 | (equal ?^ (aref paragraph-separate 0))) | 12926 | (equal ?^ (aref paragraph-separate 0))) |
| 12919 | (substring paragraph-separate 1) | 12927 | (substring paragraph-separate 1) |
| 12920 | paragraph-separate)) | 12928 | paragraph-separate)) |
| 12921 | (parsep | 12929 | (parsep |
| 12922 | (if fill-prefix-regexp | 12930 | (if fill-prefix-regexp |
| 12923 | (concat parsep "\\|" | 12931 | (concat parsep "\\|" |
| 12924 | fill-prefix-regexp "[ \t]*$") | 12932 | fill-prefix-regexp "[ \t]*$") |
| 12925 | parsep)) | 12933 | parsep)) |
| 12926 | ;; This is used for searching. | 12934 | ;; This is used for searching. |
| 12927 | (sp-parstart (concat "^[ \t]*\\(?:" parstart "\\|" parsep "\\)")) | 12935 | (sp-parstart (concat "^[ \t]*\\(?:" parstart "\\|" parsep "\\)")) |
| 12928 | start found-start) | 12936 | start found-start) |
| 12929 | (while (and (< arg 0) (not (bobp))) | 12937 | (while (and (< arg 0) (not (bobp))) |
| 12930 | (if (and (not (looking-at parsep)) | 12938 | (if (and (not (looking-at parsep)) |
| 12931 | (re-search-backward "^\n" (max (1- (point)) (point-min)) t) | 12939 | (re-search-backward "^\n" (max (1- (point)) (point-min)) t) |
| 12932 | (looking-at parsep)) | 12940 | (looking-at parsep)) |
| 12933 | (setq arg (1+ arg)) | 12941 | (setq arg (1+ arg)) |
| 12934 | (setq start (point)) | 12942 | (setq start (point)) |
| 12935 | ;; Move back over paragraph-separating lines. | 12943 | ;; Move back over paragraph-separating lines. |
| 12936 | (forward-char -1) (beginning-of-line) | 12944 | (forward-char -1) (beginning-of-line) |
| 12937 | (while (and (not (bobp)) | 12945 | (while (and (not (bobp)) |
| 12938 | (progn (move-to-left-margin) | 12946 | (progn (move-to-left-margin) |
| 12939 | (looking-at parsep))) | 12947 | (looking-at parsep))) |
| 12940 | (forward-line -1)) | 12948 | (forward-line -1)) |
| 12941 | (if (bobp) | 12949 | (if (bobp) |
| 12942 | nil | 12950 | nil |
| 12943 | (setq arg (1+ arg)) | 12951 | (setq arg (1+ arg)) |
| 12944 | ;; Go to end of the previous (non-separating) line. | 12952 | ;; Go to end of the previous (non-separating) line. |
| 12945 | (end-of-line) | 12953 | (end-of-line) |
| 12946 | ;; Search back for line that starts or separates paragraphs. | 12954 | ;; Search back for line that starts or separates paragraphs. |
| 12947 | (if (if fill-prefix-regexp | 12955 | (if (if fill-prefix-regexp |
| 12948 | ;; There is a fill prefix; it overrides parstart. | 12956 | ;; There is a fill prefix; it overrides parstart. |
| 12949 | (let (multiple-lines) | 12957 | (let (multiple-lines) |
| 12950 | (while (and (progn (beginning-of-line) (not (bobp))) | 12958 | (while (and (progn (beginning-of-line) (not (bobp))) |
| 12951 | (progn (move-to-left-margin) | 12959 | (progn (move-to-left-margin) |
| 12952 | (not (looking-at parsep))) | 12960 | (not (looking-at parsep))) |
| 12953 | (looking-at fill-prefix-regexp)) | 12961 | (looking-at fill-prefix-regexp)) |
| 12954 | (unless (= (point) start) | 12962 | (unless (= (point) start) |
| 12955 | (setq multiple-lines t)) | 12963 | (setq multiple-lines t)) |
| 12956 | (forward-line -1)) | 12964 | (forward-line -1)) |
| 12957 | (move-to-left-margin) | 12965 | (move-to-left-margin) |
| 12958 | ;; This deleted code caused a long hanging-indent line | 12966 | ;; This deleted code caused a long hanging-indent line |
| 12959 | ;; not to be filled together with the following lines. | 12967 | ;; not to be filled together with the following lines. |
| 12960 | ;; ;; Don't move back over a line before the paragraph | 12968 | ;; ;; Don't move back over a line before the paragraph |
| 12961 | ;; ;; which doesn't start with fill-prefix | 12969 | ;; ;; which doesn't start with fill-prefix |
| 12962 | ;; ;; unless that is the only line we've moved over. | 12970 | ;; ;; unless that is the only line we've moved over. |
| 12963 | ;; (and (not (looking-at fill-prefix-regexp)) | 12971 | ;; (and (not (looking-at fill-prefix-regexp)) |
| 12964 | ;; multiple-lines | 12972 | ;; multiple-lines |
| 12965 | ;; (forward-line 1)) | 12973 | ;; (forward-line 1)) |
| 12966 | (not (bobp))) | 12974 | (not (bobp))) |
| 12967 | (while (and (re-search-backward sp-parstart nil 1) | 12975 | (while (and (re-search-backward sp-parstart nil 1) |
| 12968 | (setq found-start t) | 12976 | (setq found-start t) |
| 12969 | ;; Found a candidate, but need to check if it is a | 12977 | ;; Found a candidate, but need to check if it is a |
| 12970 | ;; REAL parstart. | 12978 | ;; REAL parstart. |
| 12971 | (progn (setq start (point)) | 12979 | (progn (setq start (point)) |
| 12972 | (move-to-left-margin) | 12980 | (move-to-left-margin) |
| 12973 | (not (looking-at parsep))) | 12981 | (not (looking-at parsep))) |
| 12974 | (not (and (looking-at parstart) | 12982 | (not (and (looking-at parstart) |
| 12975 | (or (not use-hard-newlines) | 12983 | (or (not use-hard-newlines) |
| 12976 | (bobp) | 12984 | (bobp) |
| 12977 | (get-text-property | 12985 | (get-text-property |
| 12978 | (1- start) 'hard))))) | 12986 | (1- start) 'hard))))) |
| 12979 | (setq found-start nil) | 12987 | (setq found-start nil) |
| 12980 | (goto-char start)) | 12988 | (goto-char start)) |
| 12981 | found-start) | 12989 | found-start) |
| 12982 | ;; Found one. | 12990 | ;; Found one. |
| 12983 | (progn | 12991 | (progn |
| 12984 | ;; Move forward over paragraph separators. | 12992 | ;; Move forward over paragraph separators. |
| 12985 | ;; We know this cannot reach the place we started | 12993 | ;; We know this cannot reach the place we started |
| 12986 | ;; because we know we moved back over a non-separator. | 12994 | ;; because we know we moved back over a non-separator. |
| 12987 | (while (and (not (eobp)) | 12995 | (while (and (not (eobp)) |
| 12988 | (progn (move-to-left-margin) | 12996 | (progn (move-to-left-margin) |
| 12989 | (looking-at parsep))) | 12997 | (looking-at parsep))) |
| 12990 | (forward-line 1)) | 12998 | (forward-line 1)) |
| 12991 | ;; If line before paragraph is just margin, back up to there. | 12999 | ;; If line before paragraph is just margin, back up to there. |
| 12992 | (end-of-line 0) | 13000 | (end-of-line 0) |
| 12993 | (if (> (current-column) (current-left-margin)) | 13001 | (if (> (current-column) (current-left-margin)) |
| 12994 | (forward-char 1) | 13002 | (forward-char 1) |
| 12995 | (skip-chars-backward " \t") | 13003 | (skip-chars-backward " \t") |
| 12996 | (if (not (bolp)) | 13004 | (if (not (bolp)) |
| 12997 | (forward-line 1)))) | 13005 | (forward-line 1)))) |
| 12998 | ;; No starter or separator line => use buffer beg. | 13006 | ;; No starter or separator line => use buffer beg. |
| 12999 | (goto-char (point-min)))))) | 13007 | (goto-char (point-min)))))) |
| 13000 | 13008 | ||
| 13001 | (while (and (> arg 0) (not (eobp))) | 13009 | (while (and (> arg 0) (not (eobp))) |
| 13002 | ;; Move forward over separator lines... | 13010 | ;; Move forward over separator lines... |
| 13003 | (while (and (not (eobp)) | 13011 | (while (and (not (eobp)) |
| 13004 | (progn (move-to-left-margin) (not (eobp))) | 13012 | (progn (move-to-left-margin) (not (eobp))) |
| 13005 | (looking-at parsep)) | 13013 | (looking-at parsep)) |
| 13006 | (forward-line 1)) | 13014 | (forward-line 1)) |
| 13007 | (unless (eobp) (setq arg (1- arg))) | 13015 | (unless (eobp) (setq arg (1- arg))) |
| 13008 | ;; ... and one more line. | 13016 | ;; ... and one more line. |
| 13009 | (forward-line 1) | 13017 | (forward-line 1) |
| 13010 | (if fill-prefix-regexp | 13018 | (if fill-prefix-regexp |
| 13011 | ;; There is a fill prefix; it overrides parstart. | 13019 | ;; There is a fill prefix; it overrides parstart. |
| 13012 | (while (and (not (eobp)) | 13020 | (while (and (not (eobp)) |
| 13013 | (progn (move-to-left-margin) (not (eobp))) | 13021 | (progn (move-to-left-margin) (not (eobp))) |
| 13014 | (not (looking-at parsep)) | 13022 | (not (looking-at parsep)) |
| 13015 | (looking-at fill-prefix-regexp)) | 13023 | (looking-at fill-prefix-regexp)) |
| 13016 | (forward-line 1)) | 13024 | (forward-line 1)) |
| 13017 | (while (and (re-search-forward sp-parstart nil 1) | 13025 | (while (and (re-search-forward sp-parstart nil 1) |
| 13018 | (progn (setq start (match-beginning 0)) | 13026 | (progn (setq start (match-beginning 0)) |
| 13019 | (goto-char start) | 13027 | (goto-char start) |
| 13020 | (not (eobp))) | 13028 | (not (eobp))) |
| 13021 | (progn (move-to-left-margin) | 13029 | (progn (move-to-left-margin) |
| 13022 | (not (looking-at parsep))) | 13030 | (not (looking-at parsep))) |
| 13023 | (or (not (looking-at parstart)) | 13031 | (or (not (looking-at parstart)) |
| 13024 | (and use-hard-newlines | 13032 | (and use-hard-newlines |
| 13025 | (not (get-text-property (1- start) 'hard))))) | 13033 | (not (get-text-property (1- start) 'hard))))) |
| 13026 | (forward-char 1)) | 13034 | (forward-char 1)) |
| 13027 | (if (< (point) (point-max)) | 13035 | (if (< (point) (point-max)) |
| 13028 | (goto-char start)))) | 13036 | (goto-char start)))) |
| 13029 | (constrain-to-field nil opoint t) | 13037 | (constrain-to-field nil opoint t) |
| 13030 | ;; Return the number of steps that could not be done. | 13038 | ;; Return the number of steps that could not be done. |
| 13031 | arg)) | 13039 | arg)) |
| @@ -15131,7 +15139,7 @@ automatically choosing a major mode, use \\[find-file-literally]." | |||
| 15131 | (interactive (find-file-read-args "Find file: " nil)) | 15139 | (interactive (find-file-read-args "Find file: " nil)) |
| 15132 | (let ((value (find-file-noselect filename nil nil wildcards))) | 15140 | (let ((value (find-file-noselect filename nil nil wildcards))) |
| 15133 | (if (listp value) | 15141 | (if (listp value) |
| 15134 | (mapcar 'switch-to-buffer (nreverse value)) | 15142 | (mapcar 'switch-to-buffer (nreverse value)) |
| 15135 | (switch-to-buffer value)))) | 15143 | (switch-to-buffer value)))) |
| 15136 | @end ignore | 15144 | @end ignore |
| 15137 | 15145 | ||
| @@ -17711,8 +17719,8 @@ Incidentally, @code{load-library} is an interactive interface to the | |||
| 17711 | This is an interface to the function `load'." | 17719 | This is an interface to the function `load'." |
| 17712 | (interactive | 17720 | (interactive |
| 17713 | (list (completing-read "Load library: " | 17721 | (list (completing-read "Load library: " |
| 17714 | 'locate-file-completion | 17722 | 'locate-file-completion |
| 17715 | (cons load-path (get-load-suffixes))))) | 17723 | (cons load-path (get-load-suffixes))))) |
| 17716 | (load library)) | 17724 | (load library)) |
| 17717 | @end group | 17725 | @end group |
| 17718 | @end smallexample | 17726 | @end smallexample |
| @@ -19194,28 +19202,28 @@ kill ring and returned as the latest kill. | |||
| 19194 | If optional arg DO-NOT-MOVE is non-nil, then don't actually move the | 19202 | If optional arg DO-NOT-MOVE is non-nil, then don't actually move the |
| 19195 | yanking point; just return the Nth kill forward." | 19203 | yanking point; just return the Nth kill forward." |
| 19196 | (let ((interprogram-paste (and (= n 0) | 19204 | (let ((interprogram-paste (and (= n 0) |
| 19197 | interprogram-paste-function | 19205 | interprogram-paste-function |
| 19198 | (funcall interprogram-paste-function)))) | 19206 | (funcall interprogram-paste-function)))) |
| 19199 | @end group | 19207 | @end group |
| 19200 | @group | 19208 | @group |
| 19201 | (if interprogram-paste | 19209 | (if interprogram-paste |
| 19202 | (progn | 19210 | (progn |
| 19203 | ;; Disable the interprogram cut function when we add the new | 19211 | ;; Disable the interprogram cut function when we add the new |
| 19204 | ;; text to the kill ring, so Emacs doesn't try to own the | 19212 | ;; text to the kill ring, so Emacs doesn't try to own the |
| 19205 | ;; selection, with identical text. | 19213 | ;; selection, with identical text. |
| 19206 | (let ((interprogram-cut-function nil)) | 19214 | (let ((interprogram-cut-function nil)) |
| 19207 | (kill-new interprogram-paste)) | 19215 | (kill-new interprogram-paste)) |
| 19208 | interprogram-paste) | 19216 | interprogram-paste) |
| 19209 | @end group | 19217 | @end group |
| 19210 | @group | 19218 | @group |
| 19211 | (or kill-ring (error "Kill ring is empty")) | 19219 | (or kill-ring (error "Kill ring is empty")) |
| 19212 | (let ((ARGth-kill-element | 19220 | (let ((ARGth-kill-element |
| 19213 | (nthcdr (mod (- n (length kill-ring-yank-pointer)) | 19221 | (nthcdr (mod (- n (length kill-ring-yank-pointer)) |
| 19214 | (length kill-ring)) | 19222 | (length kill-ring)) |
| 19215 | kill-ring))) | 19223 | kill-ring))) |
| 19216 | (or do-not-move | 19224 | (or do-not-move |
| 19217 | (setq kill-ring-yank-pointer ARGth-kill-element)) | 19225 | (setq kill-ring-yank-pointer ARGth-kill-element)) |
| 19218 | (car ARGth-kill-element))))) | 19226 | (car ARGth-kill-element))))) |
| 19219 | @end group | 19227 | @end group |
| 19220 | @end smallexample | 19228 | @end smallexample |
| 19221 | 19229 | ||
| @@ -19538,16 +19546,16 @@ See also the command \\[yank-pop]." | |||
| 19538 | @end group | 19546 | @end group |
| 19539 | @group | 19547 | @group |
| 19540 | (insert-for-yank (current-kill (cond | 19548 | (insert-for-yank (current-kill (cond |
| 19541 | ((listp arg) 0) | 19549 | ((listp arg) 0) |
| 19542 | ((eq arg '-) -2) | 19550 | ((eq arg '-) -2) |
| 19543 | (t (1- arg))))) | 19551 | (t (1- arg))))) |
| 19544 | (if (consp arg) | 19552 | (if (consp arg) |
| 19545 | ;; This is like exchange-point-and-mark, | 19553 | ;; This is like exchange-point-and-mark, |
| 19546 | ;; but doesn't activate the mark. | 19554 | ;; but doesn't activate the mark. |
| 19547 | ;; It is cleaner to avoid activation, even though the command | 19555 | ;; It is cleaner to avoid activation, even though the command |
| 19548 | ;; loop would deactivate the mark because we inserted text. | 19556 | ;; loop would deactivate the mark because we inserted text. |
| 19549 | (goto-char (prog1 (mark t) | 19557 | (goto-char (prog1 (mark t) |
| 19550 | (set-marker (mark-marker) (point) (current-buffer))))) | 19558 | (set-marker (mark-marker) (point) (current-buffer))))) |
| 19551 | @end group | 19559 | @end group |
| 19552 | @group | 19560 | @group |
| 19553 | ;; If we do get all the way thru, make this-command indicate that. | 19561 | ;; If we do get all the way thru, make this-command indicate that. |
| @@ -19601,11 +19609,11 @@ to save space, it looks like this: | |||
| 19601 | (setq this-command 'yank) | 19609 | (setq this-command 'yank) |
| 19602 | (unless arg (setq arg 1)) | 19610 | (unless arg (setq arg 1)) |
| 19603 | (let ((inhibit-read-only t) | 19611 | (let ((inhibit-read-only t) |
| 19604 | (before (< (point) (mark t)))) | 19612 | (before (< (point) (mark t)))) |
| 19605 | @end group | 19613 | @end group |
| 19606 | @group | 19614 | @group |
| 19607 | (if before | 19615 | (if before |
| 19608 | (funcall (or yank-undo-function 'delete-region) (point) (mark t)) | 19616 | (funcall (or yank-undo-function 'delete-region) (point) (mark t)) |
| 19609 | (funcall (or yank-undo-function 'delete-region) (mark t) (point))) | 19617 | (funcall (or yank-undo-function 'delete-region) (mark t) (point))) |
| 19610 | (setq yank-undo-function nil) | 19618 | (setq yank-undo-function nil) |
| 19611 | @end group | 19619 | @end group |
| @@ -19618,12 +19626,12 @@ to save space, it looks like this: | |||
| 19618 | @end group | 19626 | @end group |
| 19619 | @group | 19627 | @group |
| 19620 | (if before | 19628 | (if before |
| 19621 | ;; This is like exchange-point-and-mark, | 19629 | ;; This is like exchange-point-and-mark, |
| 19622 | ;; but doesn't activate the mark. | 19630 | ;; but doesn't activate the mark. |
| 19623 | ;; It is cleaner to avoid activation, even though the command | 19631 | ;; It is cleaner to avoid activation, even though the command |
| 19624 | ;; loop would deactivate the mark because we inserted text. | 19632 | ;; loop would deactivate the mark because we inserted text. |
| 19625 | (goto-char (prog1 (mark t) | 19633 | (goto-char (prog1 (mark t) |
| 19626 | (set-marker (mark-marker) | 19634 | (set-marker (mark-marker) |
| 19627 | (point) | 19635 | (point) |
| 19628 | (current-buffer)))))) | 19636 | (current-buffer)))))) |
| 19629 | nil) | 19637 | nil) |