Changeset 15428 for lang/elisp
- Timestamp:
- 07/08/08 01:11:03 (5 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/elisp/perl-completion/trunk/perl-completion.el
r14626 r15428 168 168 (initial-input "") 169 169 state 170 default-action-state 171 persistent-action-buffer-point 170 172 using-modules 171 173 current-buffer … … 313 315 (error (plcmp-log "Error plcmp-ignore-errors : %s" (error-message-string e))))) 314 316 317 ;; idea: anything-dabbrev-expand.el 318 (lexical-let ((store-times 0)) 319 (defun plcmp-seq-times (command-name &optional max) 320 (let ((max (or max -99))) 321 (if (eq last-command command-name) 322 (if (= (incf store-times) max) 323 (setq store-times 0) 324 store-times) 325 (setq store-times 0))))) 326 315 327 ;;; log 316 328 (defvar plcmp-debug nil) … … 403 415 else 404 416 collect s into methods 405 finally return (nconc methods unders 406 ;; (sort methods 'string<) 407 ;; (sort unders 'string<) 408 ))) 417 finally return (nconc methods unders))) 409 418 410 419 (defsubst plcmp-inspect-methods (module) … … 492 501 (using-modules installed-modules current-package 493 502 current-buffer obj-instance-of-module-maybe-alist 494 current-object other-perl-buffers )503 current-object other-perl-buffers default-action-state) 495 504 ;; initialize slots 496 505 (setf installed-modules (plcmp-fetch-installed-modules struct) … … 501 510 obj-instance-of-module-maybe-alist (plcmp-get-obj-instance-of-module-maybe-alist struct) 502 511 other-perl-buffers (plcmp-get-other-perl-buffers struct) 503 current-object "") 512 current-object "" 513 default-action-state nil 514 persistent-action-buffer-point nil) 504 515 505 516 ;; initialize variable … … 534 545 (string-match "^\\(\\$self\\|__PACKAGE__\\)$" obj-str)) 535 546 (setf initial-input start-input 536 state 'se tf547 state 'self 537 548 current-object obj-str)) 538 549 ;; methods … … 820 831 ;;;; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 821 832 ;;; actions 822 (defun plcmp-insert ( candidate)833 (defun plcmp-insert (struct candidate) 823 834 (plcmp-with-completion-data-slots plcmp-data 824 (initial-input) 825 (delete-backward-char (length initial-input)) 826 (insert (plcmp-get-real-candidate candidate)))) 835 (initial-input default-action-state persistent-action-buffer-point) 836 (cond 837 ((eq default-action-state 'perldoc-m) 838 (multiple-value-bind (output-buf module method) 839 (plcmp-perldoc-m-create-buffer struct candidate) 840 (pop-to-buffer output-buf) 841 (goto-char persistent-action-buffer-point))) 842 (t 843 (delete-backward-char (length initial-input)) 844 (insert (plcmp-get-real-candidate candidate)))))) 827 845 828 846 (defun plcmp-insert-modulename (candidate) … … 899 917 900 918 (defun plcmp-fontify-re-search-forward (regexp) 901 (when (re-search-forward regexp nil t) 902 (let ((beg (match-beginning 1)) 903 (end (match-end 1))) 904 (when (and beg end) 905 (if (overlayp plcmp-overlay) 906 (move-overlay plcmp-overlay beg end (current-buffer)) 907 (setq plcmp-overlay (make-overlay beg end))) 908 (overlay-put plcmp-overlay 'face plcmp-search-match-face))))) 919 (let ((struct plcmp-data)) ;TODO 920 (plcmp-with-completion-data-slots struct 921 (persistent-action-buffer-point) 922 (when (re-search-forward regexp nil t) 923 (let ((beg (match-beginning 1)) 924 (end (match-end 1))) 925 ;; remember point 926 (setq persistent-action-buffer-point (point)) 927 928 (when (and beg end) 929 (if (overlayp plcmp-overlay) 930 (move-overlay plcmp-overlay beg end (current-buffer)) 931 (setq plcmp-overlay (make-overlay beg end))) 932 (overlay-put plcmp-overlay 'face plcmp-search-match-face))))))) 909 933 910 934 (defun plcmp-visit-and-re-search-forward (regexp buffer-name) … … 1006 1030 (plcmp-open-perldoc modname 'module pop-to-buffer))))) 1007 1031 1032 (defun plcmp-perldoc-m-create-buffer (struct candidate) 1033 (let (module method) 1034 (plcmp-acond 1035 ((plcmp-get-module-and-method-by-candidate struct candidate) 1036 (setq module (first it) 1037 method (second it))) 1038 (t 1039 (setq module (plcmp-get-real-candidate candidate)))) 1040 (let ((cperl-mode-hook nil) 1041 (output-buf (concat "*Perldoc -m " module "*"))) 1042 (cond 1043 ((buffer-live-p (get-buffer output-buf)) 1044 (values output-buf module method)) 1045 (t 1046 (shell-command (concat "perldoc -m " module) output-buf) 1047 1048 (with-current-buffer output-buf 1049 (goto-char (point-min)) 1050 (cperl-mode)) 1051 1052 (values output-buf module method)))))) 1053 1054 (defun plcmp-perldoc-m (struct candidate) 1055 (multiple-value-bind (output-buf module method) 1056 (plcmp-perldoc-m-create-buffer struct candidate) 1057 (let* ((re (cond ((null method) 1058 "") 1059 ((= (plcmp-seq-times 'plcmp-persistent-perldoc-m) 0) 1060 (rx-to-string `(and "sub" (1+ space) (group (eval ,method))))) 1061 (t 1062 (rx-to-string `(and symbol-start (group (eval ,method)) symbol-end)))))) 1063 (plcmp-visit-and-re-search-forward re output-buf)))) 1064 1065 (defun plcmp-persistent-perldoc-m () 1066 (interactive) 1067 (let ((struct plcmp-data)) 1068 (plcmp-with-completion-data-slots struct 1069 (default-action-state) 1070 (save-selected-window 1071 (select-window (get-buffer-window plcmp-anything-buffer)) 1072 (select-window (setq minibuffer-scroll-window 1073 (if (one-window-p t) (split-window) (next-window (selected-window) 1)))) 1074 (let* ((plcmp-anything-window (get-buffer-window plcmp-anything-buffer)) 1075 (selection (if plcmp-anything-saved-sources 1076 ;; the action list is shown 1077 plcmp-anything-saved-selection 1078 (plcmp-anything-get-selection)))) 1079 (set-window-dedicated-p plcmp-anything-window t) 1080 (unwind-protect 1081 (progn 1082 (setq default-action-state 'perldoc-m) 1083 (plcmp-perldoc-m struct selection)) 1084 (set-window-dedicated-p plcmp-anything-window nil))))))) 1008 1085 1009 1086 (defun plcmp-open-module-file (struct candidate) … … 1048 1125 1049 1126 ;; call action with selection 1050 ;;(define-key map (kbd "M") 'plcmp-action-insert-modulename)1127 (define-key map (kbd "M") 'plcmp-persistent-perldoc-m) 1051 1128 (define-key map (kbd "D") 'plcmp-action-perldoc) 1052 1129 (define-key map (kbd "O") 'plcmp-action-open-module-file) … … 1111 1188 (defvar plcmp-anything-type-attributes 1112 1189 `((plcmp 1113 (action . (("Insert" . plcmp-insert) 1190 (action . (("Insert" . (lambda (candidate) 1191 (plcmp-insert plcmp-data candidate))) 1114 1192 ("Open module file" . (lambda (candidate) 1115 1193 (plcmp-open-module-file plcmp-data candidate))) 1116 1194 ("Perldoc" . (lambda (candidate) 1117 1195 (plcmp-perldoc plcmp-data candidate))) 1196 ("Perldoc -m" . (lambda (candidate) 1197 (plcmp-perldoc-m plcmp-data candidate))) 1118 1198 )) 1119 1199 (persistent-action . (lambda (candidate) … … 1183 1263 1184 1264 (defvar plcmp-anything-source-all 1185 `((name . " installed-modules")1265 `((name . "All") 1186 1266 (type . plcmp) 1187 1267 (init . (lambda () … … 1269 1349 (interactive) 1270 1350 (plcmp-call-action-by-action-name "Open module file")) 1351 1352 (defun plcmp-action-perldoc-m () 1353 (interactive) 1354 (plcmp-call-action-by-action-name "Perldoc -m")) 1271 1355 1272 1356 (defun plcmp-action-perldoc () … … 1323 1407 (if (null initial-pattern) 1324 1408 (read-string "pattern: ") 1325 (read-string "pattern: " initial-pattern) 1326 (plcmp-anything-check-minibuffer-input)) 1409 (read-string "pattern: " initial-pattern)) 1327 1410 )) 1328 1411 (plcmp-anything-cleanup)
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)