Mercurial > emacs
comparison lisp/speedbar.el @ 111431:e4200648c86f
Replace more speedbar uses of end-of-line etc with line-end-position.
* lisp/speedbar.el (speedbar-generic-item-info)
(speedbar-item-info-tag-helper, speedbar-change-expand-button-char)
(speedbar-add-indicator, speedbar-check-vc-this-line)
(speedbar-check-obj-this-line, speedbar-extract-one-symbol)
(speedbar-buffers-line-directory, speedbar-buffer-revert-buffer):
Replace more uses of end-of-line etc with line-end-position.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 06 Nov 2010 18:06:37 -0700 |
parents | 249a1455856a |
children | 56b71cddc9c5 |
comparison
equal
deleted
inserted
replaced
111430:b75e6634a171 | 111431:e4200648c86f |
---|---|
1470 (if (looking-at "\\([0-9]+\\):") (goto-char (match-end 0))) | 1470 (if (looking-at "\\([0-9]+\\):") (goto-char (match-end 0))) |
1471 ;; Skip items in "folder" type text characters. | 1471 ;; Skip items in "folder" type text characters. |
1472 (if (looking-at "\\s-*[[<({].[]>)}] ") (goto-char (match-end 0))) | 1472 (if (looking-at "\\s-*[[<({].[]>)}] ") (goto-char (match-end 0))) |
1473 ;; Get the text | 1473 ;; Get the text |
1474 (speedbar-message "Text: %s" (buffer-substring-no-properties | 1474 (speedbar-message "Text: %s" (buffer-substring-no-properties |
1475 (point) (progn (end-of-line) (point)))))) | 1475 (point) (line-end-position))))) |
1476 | 1476 |
1477 (defun speedbar-item-info () | 1477 (defun speedbar-item-info () |
1478 "Display info in the minibuffer about the button the mouse is over. | 1478 "Display info in the minibuffer about the button the mouse is over. |
1479 This function can be replaced in `speedbar-mode-functions-list' as | 1479 This function can be replaced in `speedbar-mode-functions-list' as |
1480 `speedbar-item-info'." | 1480 `speedbar-item-info'." |
1496 (defun speedbar-item-info-tag-helper () | 1496 (defun speedbar-item-info-tag-helper () |
1497 "Display info about a tag that is on the current line. | 1497 "Display info about a tag that is on the current line. |
1498 Return nil if not applicable." | 1498 Return nil if not applicable." |
1499 (save-excursion | 1499 (save-excursion |
1500 (beginning-of-line) | 1500 (beginning-of-line) |
1501 (if (re-search-forward " [-+=]?> \\([^\n]+\\)" | 1501 (if (re-search-forward " [-+=]?> \\([^\n]+\\)" (line-end-position) t) |
1502 (save-excursion(end-of-line)(point)) t) | |
1503 (let* ((tag (match-string 1)) | 1502 (let* ((tag (match-string 1)) |
1504 (attr (speedbar-line-token)) | 1503 (attr (speedbar-line-token)) |
1505 (item nil) | 1504 (item nil) |
1506 (semantic-tagged (if (fboundp 'semantic-tag-p) | 1505 (semantic-tagged (if (fboundp 'semantic-tag-p) |
1507 (semantic-tag-p attr)))) | 1506 (semantic-tag-p attr)))) |
1515 (funcall semantic-sb-info-format-tag-function attr) | 1514 (funcall semantic-sb-info-format-tag-function attr) |
1516 ))) | 1515 ))) |
1517 (looking-at "\\([0-9]+\\):") | 1516 (looking-at "\\([0-9]+\\):") |
1518 (setq item (file-name-nondirectory (speedbar-line-directory))) | 1517 (setq item (file-name-nondirectory (speedbar-line-directory))) |
1519 (speedbar-message "Tag: %s in %s" tag item))) | 1518 (speedbar-message "Tag: %s in %s" tag item))) |
1520 (if (re-search-forward "{[+-]} \\([^\n]+\\)$" | 1519 (if (re-search-forward "{[+-]} \\([^\n]+\\)$" (line-end-position) t) |
1521 (save-excursion(end-of-line)(point)) t) | |
1522 (speedbar-message "Group of tags \"%s\"" (match-string 1)) | 1520 (speedbar-message "Group of tags \"%s\"" (match-string 1)) |
1523 (if (re-search-forward " [+-]?[()|@] \\([^\n]+\\)$" nil t) | 1521 (if (re-search-forward " [+-]?[()|@] \\([^\n]+\\)$" nil t) |
1524 (let* ((detailtext (match-string 1)) | 1522 (let* ((detailtext (match-string 1)) |
1525 (detail (or (speedbar-line-token) detailtext)) | 1523 (detail (or (speedbar-line-token) detailtext)) |
1526 (parent (save-excursion | 1524 (parent (save-excursion |
2060 | 2058 |
2061 (defun speedbar-change-expand-button-char (char) | 2059 (defun speedbar-change-expand-button-char (char) |
2062 "Change the expansion button character to CHAR for the current line." | 2060 "Change the expansion button character to CHAR for the current line." |
2063 (save-excursion | 2061 (save-excursion |
2064 (beginning-of-line) | 2062 (beginning-of-line) |
2065 (if (re-search-forward ":\\s-*.\\([-+?]\\)" (save-excursion (end-of-line) | 2063 (if (re-search-forward ":\\s-*.\\([-+?]\\)" (line-end-position) t) |
2066 (point)) t) | |
2067 (speedbar-with-writable | 2064 (speedbar-with-writable |
2068 (goto-char (match-end 1)) | 2065 (goto-char (match-end 1)) |
2069 (insert-char char 1 t) | 2066 (insert-char char 1 t) |
2070 (forward-char -1) | 2067 (forward-char -1) |
2071 (delete-char -1) | 2068 (delete-char -1) |
2850 (not (string= indicator-string " "))) | 2847 (not (string= indicator-string " "))) |
2851 (insert speedbar-indicator-separator)) | 2848 (insert speedbar-indicator-separator)) |
2852 (speedbar-with-writable | 2849 (speedbar-with-writable |
2853 (save-excursion | 2850 (save-excursion |
2854 (if (and replace-this | 2851 (if (and replace-this |
2855 (re-search-forward replace-this (save-excursion (end-of-line) | 2852 (re-search-forward replace-this (line-end-position) t)) |
2856 (point)) | |
2857 t)) | |
2858 (delete-region (match-beginning 0) (match-end 0)))) | 2853 (delete-region (match-beginning 0) (match-end 0)))) |
2859 (end-of-line) | 2854 (end-of-line) |
2860 (if (not (string= " " indicator-string)) | 2855 (if (not (string= " " indicator-string)) |
2861 (let ((start (point))) | 2856 (let ((start (point))) |
2862 (insert indicator-string) | 2857 (insert indicator-string) |
2950 (let* ((d (string-to-number depth)) | 2945 (let* ((d (string-to-number depth)) |
2951 (f (speedbar-line-directory d)) | 2946 (f (speedbar-line-directory d)) |
2952 (fn (buffer-substring-no-properties | 2947 (fn (buffer-substring-no-properties |
2953 ;; Skip-chars: thanks ptype@dra.hmg.gb | 2948 ;; Skip-chars: thanks ptype@dra.hmg.gb |
2954 (point) (progn | 2949 (point) (progn |
2955 (skip-chars-forward "^ " | 2950 (skip-chars-forward "^ " (line-end-position)) |
2956 (save-excursion (end-of-line) | |
2957 (point))) | |
2958 (point)))) | 2951 (point)))) |
2959 (fulln (concat f fn))) | 2952 (fulln (concat f fn))) |
2960 (if (<= 2 speedbar-verbosity-level) | 2953 (if (<= 2 speedbar-verbosity-level) |
2961 (speedbar-message "Speedbar vc check...%s" fulln)) | 2954 (speedbar-message "Speedbar vc check...%s" fulln)) |
2962 (and (file-writable-p fulln) | 2955 (and (file-writable-p fulln) |
3024 (let* ((d (string-to-number depth)) | 3017 (let* ((d (string-to-number depth)) |
3025 (f (speedbar-line-directory d)) | 3018 (f (speedbar-line-directory d)) |
3026 (fn (buffer-substring-no-properties | 3019 (fn (buffer-substring-no-properties |
3027 ;; Skip-chars: thanks ptype@dra.hmg.gb | 3020 ;; Skip-chars: thanks ptype@dra.hmg.gb |
3028 (point) (progn | 3021 (point) (progn |
3029 (skip-chars-forward "^ " | 3022 (skip-chars-forward "^ " (line-end-position)) |
3030 (save-excursion (end-of-line) | |
3031 (point))) | |
3032 (point)))) | 3023 (point)))) |
3033 (fulln (concat f fn))) | 3024 (fulln (concat f fn))) |
3034 (if (<= 2 speedbar-verbosity-level) | 3025 (if (<= 2 speedbar-verbosity-level) |
3035 (speedbar-message "Speedbar obj check...%s" fulln)) | 3026 (speedbar-message "Speedbar obj check...%s" fulln)) |
3036 (let ((oa speedbar-obj-alist)) | 3027 (let ((oa speedbar-obj-alist)) |
3762 "At point, return nil, or one alist in the form (SYMBOL . POSITION). | 3753 "At point, return nil, or one alist in the form (SYMBOL . POSITION). |
3763 The line should contain output from etags. Parse the output using the | 3754 The line should contain output from etags. Parse the output using the |
3764 regular expression EXPR." | 3755 regular expression EXPR." |
3765 (let* ((sym (if (stringp expr) | 3756 (let* ((sym (if (stringp expr) |
3766 (if (save-excursion | 3757 (if (save-excursion |
3767 (re-search-forward expr (save-excursion | 3758 (re-search-forward expr (line-end-position) t)) |
3768 (end-of-line) | |
3769 (point)) t)) | |
3770 (buffer-substring-no-properties (match-beginning 1) | 3759 (buffer-substring-no-properties (match-beginning 1) |
3771 (match-end 1))) | 3760 (match-end 1))) |
3772 (funcall expr))) | 3761 (funcall expr))) |
3773 (pos (let ((j (re-search-forward "[\C-?\C-a]\\([0-9]+\\),\\([0-9]+\\)" | 3762 (pos (let ((j (re-search-forward "[\C-?\C-a]\\([0-9]+\\),\\([0-9]+\\)" |
3774 (save-excursion | 3763 (line-end-position) t))) |
3775 (end-of-line) | |
3776 (point)) | |
3777 t))) | |
3778 (if (and j sym) | 3764 (if (and j sym) |
3779 (1+ (string-to-number (buffer-substring-no-properties | 3765 (1+ (string-to-number (buffer-substring-no-properties |
3780 (match-beginning 2) | 3766 (match-beginning 2) |
3781 (match-end 2)))) | 3767 (match-end 2)))) |
3782 0)))) | 3768 0)))) |
3946 (if (not (re-search-backward "^0:" nil t)) | 3932 (if (not (re-search-backward "^0:" nil t)) |
3947 nil | 3933 nil |
3948 (let* ((bn (speedbar-line-text)) | 3934 (let* ((bn (speedbar-line-text)) |
3949 (buffer (if bn (get-buffer bn)))) | 3935 (buffer (if bn (get-buffer bn)))) |
3950 (if buffer | 3936 (if buffer |
3951 (if (save-excursion | 3937 (if (eq start (line-end-position)) |
3952 (end-of-line) | |
3953 (eq start (point))) | |
3954 (or (with-current-buffer buffer default-directory) | 3938 (or (with-current-buffer buffer default-directory) |
3955 "") | 3939 "") |
3956 (buffer-file-name buffer)))))))) | 3940 (buffer-file-name buffer)))))))) |
3957 | 3941 |
3958 (defun speedbar-buffer-click (text token indent) | 3942 (defun speedbar-buffer-click (text token indent) |
3980 (interactive) | 3964 (interactive) |
3981 (save-excursion | 3965 (save-excursion |
3982 (beginning-of-line) | 3966 (beginning-of-line) |
3983 ;; If this fails, then it is a non-standard click, and as such, | 3967 ;; If this fails, then it is a non-standard click, and as such, |
3984 ;; perfectly allowed | 3968 ;; perfectly allowed |
3985 (if (re-search-forward "[]>?}] [^ ]" | 3969 (if (re-search-forward "[]>?}] [^ ]" (line-end-position) t) |
3986 (line-end-position) | |
3987 t) | |
3988 (let ((text (progn | 3970 (let ((text (progn |
3989 (forward-char -1) | 3971 (forward-char -1) |
3990 (buffer-substring (point) (save-excursion | 3972 (buffer-substring (point) (line-end-position))))) |
3991 (end-of-line) | |
3992 (point)))))) | |
3993 (if (get-buffer text) | 3973 (if (get-buffer text) |
3994 (progn | 3974 (progn |
3995 (set-buffer text) | 3975 (set-buffer text) |
3996 (revert-buffer t))))))) | 3976 (revert-buffer t))))))) |
3997 | 3977 |