Mercurial > emacs
comparison lisp/progmodes/cperl-mode.el @ 104544:5a7504ff8b85
(cperl-imenu-name-and-position): Copy imenu-example--name-and-position
function here for own use.
(cperl-xsub-scan): Use cperl-imenu-name-and-position.
(cperl-time-fontification): Use forward-line rather than goto-line.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 22 Aug 2009 19:39:54 +0000 |
parents | e667f4aad5f2 |
children | 45d111e58a36 |
comparison
equal
deleted
inserted
replaced
104543:da8b3e61b182 | 104544:5a7504ff8b85 |
---|---|
6872 (progn | 6872 (progn |
6873 (make-local-variable 'parse-sexp-lookup-properties) | 6873 (make-local-variable 'parse-sexp-lookup-properties) |
6874 ;; Do not introduce variable if not needed, we check it! | 6874 ;; Do not introduce variable if not needed, we check it! |
6875 (set 'parse-sexp-lookup-properties t)))) | 6875 (set 'parse-sexp-lookup-properties t)))) |
6876 | 6876 |
6877 ;; Copied from imenu-example--name-and-position. | |
6878 (defvar imenu-use-markers) | |
6879 | |
6880 (defun cperl-imenu-name-and-position () | |
6881 "Return the current/previous sexp and its (beginning) location. | |
6882 Does not move point." | |
6883 (save-excursion | |
6884 (forward-sexp -1) | |
6885 (let ((beg (if imenu-use-markers (point-marker) (point))) | |
6886 (end (progn (forward-sexp) (point)))) | |
6887 (cons (buffer-substring beg end) | |
6888 beg)))) | |
6889 | |
6877 (defun cperl-xsub-scan () | 6890 (defun cperl-xsub-scan () |
6878 (require 'imenu) | 6891 (require 'imenu) |
6879 (let ((index-alist '()) | 6892 (let ((index-alist '()) |
6880 (prev-pos 0) index index1 name package prefix) | 6893 (prev-pos 0) index index1 name package prefix) |
6881 (goto-char (point-min)) | 6894 (goto-char (point-min)) |
6894 (setq prefix (buffer-substring (match-beginning 1) (match-end 1))) | 6907 (setq prefix (buffer-substring (match-beginning 1) (match-end 1))) |
6895 (setq prefix nil))) | 6908 (setq prefix nil))) |
6896 ((not package) nil) ; C language section | 6909 ((not package) nil) ; C language section |
6897 ((match-beginning 3) ; XSUB | 6910 ((match-beginning 3) ; XSUB |
6898 (goto-char (1+ (match-beginning 3))) | 6911 (goto-char (1+ (match-beginning 3))) |
6899 (setq index (imenu-example--name-and-position)) | 6912 (setq index (cperl-imenu-name-and-position)) |
6900 (setq name (buffer-substring (match-beginning 3) (match-end 3))) | 6913 (setq name (buffer-substring (match-beginning 3) (match-end 3))) |
6901 (if (and prefix (string-match (concat "^" prefix) name)) | 6914 (if (and prefix (string-match (concat "^" prefix) name)) |
6902 (setq name (substring name (length prefix)))) | 6915 (setq name (substring name (length prefix)))) |
6903 (cond ((string-match "::" name) nil) | 6916 (cond ((string-match "::" name) nil) |
6904 (t | 6917 (t |
6906 (push index1 index-alist))) | 6919 (push index1 index-alist))) |
6907 (setcar index name) | 6920 (setcar index name) |
6908 (push index index-alist)) | 6921 (push index index-alist)) |
6909 (t ; BOOT: section | 6922 (t ; BOOT: section |
6910 ;; (beginning-of-line) | 6923 ;; (beginning-of-line) |
6911 (setq index (imenu-example--name-and-position)) | 6924 (setq index (cperl-imenu-name-and-position)) |
6912 (setcar index (concat package "::BOOT:")) | 6925 (setcar index (concat package "::BOOT:")) |
6913 (push index index-alist))))) | 6926 (push index index-alist))))) |
6914 index-alist)) | 6927 index-alist)) |
6915 | 6928 |
6916 (defvar cperl-unreadable-ok nil) | 6929 (defvar cperl-unreadable-ok nil) |
8756 (or lim (setq lim 40)) | 8769 (or lim (setq lim 40)) |
8757 (let* ((timems (function (lambda () | 8770 (let* ((timems (function (lambda () |
8758 (let ((tt (current-time))) | 8771 (let ((tt (current-time))) |
8759 (+ (* 1000 (nth 1 tt)) (/ (nth 2 tt) 1000)))))) | 8772 (+ (* 1000 (nth 1 tt)) (/ (nth 2 tt) 1000)))))) |
8760 (tt (funcall timems)) (c 0) delta tot) | 8773 (tt (funcall timems)) (c 0) delta tot) |
8761 (goto-line l) | 8774 (goto-char (point-min)) |
8775 (forward-line (1- l)) | |
8762 (cperl-mode) | 8776 (cperl-mode) |
8763 (setq tot (- (- tt (setq tt (funcall timems))))) | 8777 (setq tot (- (- tt (setq tt (funcall timems))))) |
8764 (message "cperl-mode at %s: %s" l tot) | 8778 (message "cperl-mode at %s: %s" l tot) |
8765 (while (and (< c lim) (not (eobp))) | 8779 (while (and (< c lim) (not (eobp))) |
8766 (forward-line step) | 8780 (forward-line step) |