Mercurial > hg > xemacs-beta
comparison lisp/simple.el @ 410:de805c49cfc1 r21-2-35
Import from CVS: tag r21-2-35
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:19:21 +0200 |
parents | 501cfd01ee6d |
children | 697ef44129c6 |
comparison
equal
deleted
inserted
replaced
409:301b9ebbdf3b | 410:de805c49cfc1 |
---|---|
717 (t | 717 (t |
718 ;; give a basic line count | 718 ;; give a basic line count |
719 (message "Line %d" buffer-line))))))) | 719 (message "Line %d" buffer-line))))))) |
720 (setq zmacs-region-stays t)) | 720 (setq zmacs-region-stays t)) |
721 | 721 |
722 ;;; Bob Weiner, Altrasoft, 02/12/1998 | 722 ;; new in XEmacs 21.2 (not in FSF). |
723 ;;; Added the 3rd arg in `count-lines' to conditionalize the counting of | 723 (defun line-number (&optional pos respect-narrowing) |
724 ;;; collapsed lines. | 724 "Return the line number of POS (defaults to point). |
725 If RESPECT-NARROWING is non-nil, then the narrowed line number is returned; | |
726 otherwise, the absolute line number is returned. The returned line can always | |
727 be given to `goto-line' to get back to the current line." | |
728 (if (and pos (/= pos (point))) | |
729 (save-excursion | |
730 (goto-char pos) | |
731 (line-number nil respect-narrowing)) | |
732 (1+ (count-lines (if respect-narrowing (point-min) 1) (point-at-bol))))) | |
733 | |
725 (defun count-lines (start end &optional ignore-invisible-lines-flag) | 734 (defun count-lines (start end &optional ignore-invisible-lines-flag) |
726 "Return number of lines between START and END. | 735 "Return number of lines between START and END. |
727 This is usually the number of newlines between them, | 736 This is usually the number of newlines between them, |
728 but can be one more if START is not equal to END | 737 but can be one more if START is not equal to END |
729 and the greater of them is not at the start of a line. | 738 and the greater of them is not at the start of a line. |
730 | 739 |
731 With optional IGNORE-INVISIBLE-LINES-FLAG non-nil, lines collapsed with | 740 With optional IGNORE-INVISIBLE-LINES-FLAG non-nil, lines collapsed with |
732 selective-display are excluded from the line count." | 741 selective-display are excluded from the line count. |
742 | |
743 NOTE: The expression to return the current line number is not obvious: | |
744 | |
745 (1+ (count-lines 1 (point-at-bol))) | |
746 | |
747 See also `line-number'." | |
733 (save-excursion | 748 (save-excursion |
734 (save-restriction | 749 (save-restriction |
735 (narrow-to-region start end) | 750 (narrow-to-region start end) |
736 (goto-char (point-min)) | 751 (goto-char (point-min)) |
737 (if (and (not ignore-invisible-lines-flag) (eq selective-display t)) | 752 (if (and (not ignore-invisible-lines-flag) (eq selective-display t)) |