Mercurial > emacs
comparison lispref/positions.texi @ 89910:548375b6b1f8
Update unicode branch
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 19 Apr 2004 07:01:43 +0000 |
parents | 375f2633d815 |
children | b9eee0a7bef5 |
comparison
equal
deleted
inserted
replaced
89909:68c22ea6027c | 89910:548375b6b1f8 |
---|---|
16 after that position. | 16 after that position. |
17 | 17 |
18 Positions are usually represented as integers starting from 1, but can | 18 Positions are usually represented as integers starting from 1, but can |
19 also be represented as @dfn{markers}---special objects that relocate | 19 also be represented as @dfn{markers}---special objects that relocate |
20 automatically when text is inserted or deleted so they stay with the | 20 automatically when text is inserted or deleted so they stay with the |
21 surrounding characters. @xref{Markers}. | 21 surrounding characters. Functions that expect an argument to be a |
22 position (an integer), but accept a marker as a substitute, normally | |
23 ignore the marker buffer. Of course, markers used this way usually | |
24 point to a position in the buffer that the function operates on, but | |
25 that is entirely the programmer's responsibility. @xref{Markers}. | |
22 | 26 |
23 See also the ``field'' feature (@pxref{Fields}), which provides | 27 See also the ``field'' feature (@pxref{Fields}), which provides |
24 functions that are used by many cursor-motion commands. | 28 functions that are used by many cursor-motion commands. |
25 | 29 |
26 @menu | 30 @menu |
87 in effect, in which case it is the position of the end of the region | 91 in effect, in which case it is the position of the end of the region |
88 that you narrowed to. (@xref{Narrowing}.) | 92 that you narrowed to. (@xref{Narrowing}.) |
89 @end defun | 93 @end defun |
90 | 94 |
91 @defun buffer-end flag | 95 @defun buffer-end flag |
92 This function returns @code{(point-min)} if @var{flag} is less than 1, | 96 This function returns @code{(point-max)} if @var{flag} is greater than |
93 @code{(point-max)} otherwise. The argument @var{flag} must be a number. | 97 0, @code{(point-min)} otherwise. The argument @var{flag} must be a |
98 number. | |
94 @end defun | 99 @end defun |
95 | 100 |
96 @defun buffer-size &optional buffer | 101 @defun buffer-size &optional buffer |
97 This function returns the total number of characters in the current | 102 This function returns the total number of characters in the current |
98 buffer. In the absence of any narrowing (@pxref{Narrowing}), | 103 buffer. In the absence of any narrowing (@pxref{Narrowing}), |
183 @subsection Motion by Words | 188 @subsection Motion by Words |
184 | 189 |
185 These functions for parsing words use the syntax table to decide | 190 These functions for parsing words use the syntax table to decide |
186 whether a given character is part of a word. @xref{Syntax Tables}. | 191 whether a given character is part of a word. @xref{Syntax Tables}. |
187 | 192 |
188 @deffn Command forward-word count | 193 @deffn Command forward-word &optional count |
189 This function moves point forward @var{count} words (or backward if | 194 This function moves point forward @var{count} words (or backward if |
190 @var{count} is negative). ``Moving one word'' means moving until point | 195 @var{count} is negative). ``Moving one word'' means moving until point |
191 crosses a word-constituent character and then encounters a | 196 crosses a word-constituent character and then encounters a |
192 word-separator character. However, this function cannot move point past | 197 word-separator character. However, this function cannot move point past |
193 the boundary of the accessible portion of the buffer, or across a field | 198 the boundary of the accessible portion of the buffer, or across a field |
201 | 206 |
202 If @code{inhibit-field-text-motion} is non-@code{nil}, | 207 If @code{inhibit-field-text-motion} is non-@code{nil}, |
203 this function ignores field boundaries. | 208 this function ignores field boundaries. |
204 | 209 |
205 In an interactive call, @var{count} is specified by the numeric prefix | 210 In an interactive call, @var{count} is specified by the numeric prefix |
206 argument. | 211 argument. If @var{count} is omitted or @code{nil}, it defaults to 1. |
207 @end deffn | 212 @end deffn |
208 | 213 |
209 @deffn Command backward-word count | 214 @deffn Command backward-word &optional count |
210 This function is just like @code{forward-word}, except that it moves | 215 This function is just like @code{forward-word}, except that it moves |
211 backward until encountering the front of a word, rather than forward. | 216 backward until encountering the front of a word, rather than forward. |
212 | |
213 In an interactive call, @var{count} is set to the numeric prefix | |
214 argument. | |
215 | |
216 @c [Now optimized by compiler.] | |
217 @c This function is rarely used in programs, as it is more efficient to | |
218 @c call @code{forward-word} with a negative argument. | |
219 @end deffn | 217 @end deffn |
220 | 218 |
221 @defvar words-include-escapes | 219 @defvar words-include-escapes |
222 @c Emacs 19 feature | 220 @c Emacs 19 feature |
223 This variable affects the behavior of @code{forward-word} and everything | 221 This variable affects the behavior of @code{forward-word} and everything |
403 @example | 401 @example |
404 @group | 402 @group |
405 (defun current-line () | 403 (defun current-line () |
406 "Return the vertical position of point@dots{}" | 404 "Return the vertical position of point@dots{}" |
407 (+ (count-lines (window-start) (point)) | 405 (+ (count-lines (window-start) (point)) |
408 (if (= (current-column) 0) 1 0) | 406 (if (= (current-column) 0) 1 0))) |
409 -1)) | 407 @end group |
410 @end group | 408 @end example |
411 @end example | 409 @end defun |
410 | |
411 @defun line-number-at-pos &optional pos | |
412 @cindex line number | |
413 This function returns the line number in the current buffer | |
414 corresponding the buffer position @var{pos}. If @var{pos} is @code{nil} | |
415 or omitted, the current buffer position is used. | |
412 @end defun | 416 @end defun |
413 | 417 |
414 @ignore | 418 @ignore |
415 @c ================ | 419 @c ================ |
416 The @code{previous-line} and @code{next-line} commands are functions | 420 The @code{previous-line} and @code{next-line} commands are functions |
660 This function moves forward out of @var{arg} (default 1) levels of parentheses. | 664 This function moves forward out of @var{arg} (default 1) levels of parentheses. |
661 A negative argument means move backward but still to a less deep spot. | 665 A negative argument means move backward but still to a less deep spot. |
662 @end deffn | 666 @end deffn |
663 | 667 |
664 @deffn Command down-list &optional arg | 668 @deffn Command down-list &optional arg |
665 This function moves forward into @var{arg} (default 1) levels of parentheses. A | 669 This function moves forward into @var{arg} (default 1) levels of |
666 negative argument means move backward but still go | 670 parentheses. A negative argument means move backward but still go |
667 deeper in parentheses (@minus{}@var{arg} levels). | 671 deeper in parentheses (@minus{}@var{arg} levels). |
668 @end deffn | 672 @end deffn |
669 | 673 |
670 @deffn Command forward-sexp &optional arg | 674 @deffn Command forward-sexp &optional arg |
671 This function moves forward across @var{arg} (default 1) balanced expressions. | 675 This function moves forward across @var{arg} (default 1) balanced expressions. |
693 | 697 |
694 @deffn Command backward-sexp &optional arg | 698 @deffn Command backward-sexp &optional arg |
695 This function moves backward across @var{arg} (default 1) balanced expressions. | 699 This function moves backward across @var{arg} (default 1) balanced expressions. |
696 @end deffn | 700 @end deffn |
697 | 701 |
698 @deffn Command beginning-of-defun arg | 702 @deffn Command beginning-of-defun &optional arg |
699 This function moves back to the @var{arg}th beginning of a defun. If | 703 This function moves back to the @var{arg}th beginning of a defun. If |
700 @var{arg} is negative, this actually moves forward, but it still moves | 704 @var{arg} is negative, this actually moves forward, but it still moves |
701 to the beginning of a defun, not to the end of one. | 705 to the beginning of a defun, not to the end of one. |
702 @end deffn | 706 @end deffn |
703 | 707 |
704 @deffn Command end-of-defun arg | 708 @deffn Command end-of-defun &optional arg |
705 This function moves forward to the @var{arg}th end of a defun. If | 709 This function moves forward to the @var{arg}th end of a defun. If |
706 @var{arg} is negative, this actually moves backward, but it still moves | 710 @var{arg} is negative, this actually moves backward, but it still moves |
707 to the end of a defun, not to the beginning of one. | 711 to the end of a defun, not to the beginning of one. |
708 @end deffn | 712 @end deffn |
709 | 713 |
792 @end example | 796 @end example |
793 | 797 |
794 Note that char classes are not currently supported in | 798 Note that char classes are not currently supported in |
795 @var{character-set}; they will be treated as literals. Thus you | 799 @var{character-set}; they will be treated as literals. Thus you |
796 cannot use @code{"[:alpha:]"} instead of @code{"a-zA-Z"} to include | 800 cannot use @code{"[:alpha:]"} instead of @code{"a-zA-Z"} to include |
797 non-ASCII letters. A way to skip forward over all letters is: | 801 non-@acronym{ASCII} letters. A way to skip forward over all letters is: |
798 | 802 |
799 @example | 803 @example |
800 (re-search-forward "\\=[[:alpha:]]*" nil t) | 804 (re-search-forward "\\=[[:alpha:]]*" nil t) |
801 @end example | 805 @end example |
802 @end defun | 806 @end defun |
872 @end example | 876 @end example |
873 @end defspec | 877 @end defspec |
874 | 878 |
875 @strong{Warning:} Ordinary insertion of text adjacent to the saved | 879 @strong{Warning:} Ordinary insertion of text adjacent to the saved |
876 point value relocates the saved value, just as it relocates all markers. | 880 point value relocates the saved value, just as it relocates all markers. |
877 Therefore, when the saved point value is restored, it normally comes | 881 More precisely, the saved value is a marker with insertion type |
878 before the inserted text. | 882 @code{nil}. @xref{Marker Insertion Types}. Therefore, when the saved |
883 point value is restored, it normally comes before the inserted text. | |
879 | 884 |
880 Although @code{save-excursion} saves the location of the mark, it does | 885 Although @code{save-excursion} saves the location of the mark, it does |
881 not prevent functions which modify the buffer from setting | 886 not prevent functions which modify the buffer from setting |
882 @code{deactivate-mark}, and thus causing the deactivation of the mark | 887 @code{deactivate-mark}, and thus causing the deactivation of the mark |
883 after the command finishes. @xref{The Mark}. | 888 after the command finishes. @xref{The Mark}. |
914 | 919 |
915 In an interactive call, @var{start} and @var{end} are set to the bounds | 920 In an interactive call, @var{start} and @var{end} are set to the bounds |
916 of the current region (point and the mark, with the smallest first). | 921 of the current region (point and the mark, with the smallest first). |
917 @end deffn | 922 @end deffn |
918 | 923 |
919 @deffn Command narrow-to-page move-count | 924 @deffn Command narrow-to-page &optional move-count |
920 This function sets the accessible portion of the current buffer to | 925 This function sets the accessible portion of the current buffer to |
921 include just the current page. An optional first argument | 926 include just the current page. An optional first argument |
922 @var{move-count} non-@code{nil} means to move forward or backward by | 927 @var{move-count} non-@code{nil} means to move forward or backward by |
923 @var{move-count} pages and then narrow to one page. The variable | 928 @var{move-count} pages and then narrow to one page. The variable |
924 @code{page-delimiter} specifies where pages start and end | 929 @code{page-delimiter} specifies where pages start and end |
994 This is the contents of foo@point{} | 999 This is the contents of foo@point{} |
995 ---------- Buffer: foo ---------- | 1000 ---------- Buffer: foo ---------- |
996 @end group | 1001 @end group |
997 @end example | 1002 @end example |
998 @end defspec | 1003 @end defspec |
1004 | |
1005 @ignore | |
1006 arch-tag: 56e8ff26-4ffe-4832-a141-7e991a2d0f87 | |
1007 @end ignore |