Changeset 19503

Show
Ignore:
Timestamp:
09/18/08 18:34:06 (4 months ago)
Author:
imakado
Message:

initialinput収得部分変更。初回起動時の補完候補収得の際にもPERL5LIBを自動で追加するように。他のバッファから補完候補を収得する部分の実装。smart-completeのアルゴリズム変更

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/elisp/perl-completion/branch/1.0/perl-completion.el

    r19304 r19503  
    2929 
    3030 
    31  
    32 ;;builtin variables:  
    33 ;; (search . ((lambda (re arg1 arg2) 
    34 ;;                  (re-search-forward (regexp-quote re) nil t)))) 
    35  
    36  
    3731;; TODO: 
    3832;; set-perl5lib 
    3933;; open doc -> occur 
     34;; when remote(tramp) set-perl5lib 
     35;; plcmp-cmd-show-environment 
    4036 
    4137;;;code: 
     
    141137(make-variable-buffer-local 'plcmp-additional-lib-directories) 
    142138 
    143 (defun plcmp-cmd-set-additional-lib-directory () 
    144   "ask directory, then set directory to `plcmp-additional-lib-directories'" 
    145   (interactive) 
    146   (let* ((dir (read-directory-name "set to PERL5LIB(this buffer only): " nil nil t)) 
    147          (dir (directory-file-name dir))) 
    148     (when (and (stringp dir) 
    149                (file-exists-p dir)) 
    150       (add-to-list 'plcmp-additional-lib-directories dir) 
    151       (message "added %s to PERL5LIB" dir)))) 
     139 
    152140 
    153141(defun plcmp--get-lib-path () 
     
    179167                      (not (equal "" current-perl5lib))) 
    180168             (setenv "PERL5LIB" current-perl5lib) 
    181              (plcmp-log "plcmp-with-set-perl5-lib PERL5LIB: %s" current-perl5lib)) 
    182            (progn 
    183              ,@body)))))) 
     169             (plcmp-log "plcmp-with-set-perl5-lib PERL5LIB: %s" current-perl5lib))))) 
     170     (progn 
     171       ,@body))) 
    184172 
    185173 
     
    249237            regexps)))) 
    250238 
    251 (defun plcmp-re-sort-sources (regexps sources) 
     239(defun plcmp-re-sort-sources (regexps sources &optional reverse) 
    252240  (condition-case e 
    253       (let ((regexps (if (stringp regexps) (list regexps) regexps)) 
    254             (match-sources) 
    255             (unmatch-sources)) 
    256         (loop for source in sources 
     241      (let* ((regexps (if (stringp regexps) (list regexps) regexps)) 
     242             (match-sources) 
     243             (unmatch-sources) 
     244             (sorted-sources (loop for source in sources 
    257245              if (plcmp--re-match-sources1 regexps source) 
    258246              collect source into match-sources 
    259247              else 
    260248              collect source into unmatch-sources 
    261               finally (return (nconc match-sources unmatch-sources)))) 
     249              finally return (if reverse 
     250                                 (nconc unmatch-sources match-sources) 
     251                               (nconc match-sources unmatch-sources))))) 
     252        (prog1 sorted-sources 
     253          (plcmp-log "plcmp-re-sort-sources: %s" sorted-sources))) 
    262254    (error (plcmp-log "Error: plcmp-re-sort-sources\nregexps: %s\nsources: %s" 
    263255                      regexps 
    264256                      sources) 
    265             sources))) 
     257           sources))) 
    266258 
    267259(defsubst* plcmp-collect-matches 
     
    290282      (require 'pp) 
    291283      (let* ((str (or (ignore-errors (apply 'format messages)) 
    292                       (pp-to-string messages))) 
     284                      (pp-to-string (car messages)))) 
    293285             (strn (concat str "\n"))) 
    294286        (with-current-buffer (plcmp-log-buf) 
     
    304296(defvar plcmp-initial-input "") 
    305297(defvar plcmp-real-initial-input "real initial-input if required `anything-match-plugin' initial-input is not real initial-input") 
     298 
     299(defun plcmp--fullname () 
     300  (save-excursion 
     301    (let ((start (point))) 
     302      (skip-chars-backward "a-zA-Z0-9_") 
     303      (let ((str (plcmp-preceding-string 2))) 
     304        (when (string-equal str "::") 
     305          (buffer-substring-no-properties start (point))))))) 
     306           
     307 
    306308(defun plcmp-get-initial-real-input-list () 
    307309  "return list (initial-input real-initial-input)" 
    308310  (save-excursion 
    309     (let ((start (point))) 
    310       (skip-syntax-backward "w_") 
    311       (let* ((preceding-string (char-to-string (preceding-char))) 
    312              (end (condition-case e 
    313                       (cond 
    314                        ((some (lambda (s) (string-equal s preceding-string)) '("$" "@" "%" "&")) 
    315                         (backward-char) 
    316                         (point)) 
    317                        (t 
    318                         (point))) 
    319                     (error (point)))) 
    320              (real-initial-input 
    321               (buffer-substring-no-properties start end)) 
    322              (initial-input 
    323               (regexp-quote 
    324                (concat real-initial-input 
    325                        (if (featurep 'anything-match-plugin) 
    326                            " " 
    327                          ""))))) 
    328         (prog1 (values initial-input real-initial-input) 
    329           (plcmp-log "plcmp-get-initial-real-input-list:\ninitial-input: %s\nreal-initial-input: %s" 
    330                      initial-input 
    331                      real-initial-input)))))) 
     311    (let* ((start (point)) 
     312           (real-initial-input 
     313            (cond 
     314             ((plcmp--fullname)) 
     315             (t 
     316              (skip-syntax-backward "w_") 
     317              (let* ((preceding-string (char-to-string (preceding-char))) 
     318                     (end (condition-case e 
     319                              (cond 
     320                               ((some (lambda (s) (string-equal s preceding-string)) '("$" "@" "%" "&")) 
     321                                (backward-char) 
     322                                (point)) 
     323                               (t 
     324                                (point))) 
     325                            (error (point))))) 
     326                (buffer-substring-no-properties start end))))) 
     327           (initial-input 
     328            (regexp-quote 
     329             (concat real-initial-input 
     330                     (if (and (featurep 'anything-match-plugin) 
     331                              (not (string-equal real-initial-input ""))) 
     332                         " " 
     333                       ""))))) 
     334      (prog1 (values initial-input real-initial-input) 
     335        (plcmp-log "plcmp-get-initial-real-input-list:\ninitial-input: %s\nreal-initial-input: %s" 
     336                   initial-input 
     337                   real-initial-input))))) 
     338 
    332339 
    333340;;; installed modules 
     
    338345  (unless (plcmp-tramp-p) 
    339346    (or plcmp-installed-modules 
    340         (prog1 (plcmp--installed-modules-synchronously) 
    341           (plcmp--installed-modules-asynchronously))))) 
     347        (setq plcmp-installed-modules 
     348              (plcmp--installed-modules-synchronously))))) 
    342349 
    343350(defun plcmp--installed-modules-synchronously () 
     
    350357                        "| perl -nle 's/package\s+(.+);/$1/; print' " 
    351358                        "| sort " 
    352                         "| uniq "))) 
     359                        "| uniq " 
     360                        ))) 
    353361         (modules (split-string modules-str "\n"))) 
    354362    (message "done") 
     
    370378  (message "fetching installed modules...") 
    371379  (let* ((command "find") 
    372          (args (concat "find `perl -e 'pop @INC; print join(q{ }, @INC);'`" 
     380         (args (concat "`perl -e 'pop @INC; print join(q{ }, @INC);'`" 
    373381                       " -name '*.pm' -type f " 
    374382                       "| xargs grep -E -h -o 'package [a-zA-Z0-9:]+;' " 
     
    458466  (let* ((path (shell-command-to-string (concat "perldoc -l " (shell-quote-argument module-name)))) 
    459467         (path (plcmp-trim path))) 
    460     (and (file-exists-p path) 
     468    (and (stringp path) 
     469         (file-exists-p path) 
    461470         path))) 
    462471 
     
    493502  (anything-aif (assoc-default module-name plcmp-module-methods-alist) 
    494503      `((name . ,(concat module-name plcmp--mk-module-source-name)) 
    495         (type . plcmp-completion-method) 
     504        (action . (("Insert" . plcmp-insert) 
     505                   ("Show doc" . 
     506                    (lambda (candidate) 
     507                      (let* ((module (plcmp-get-current-module-name)) 
     508                             (buf (plcmp-get-man-buffer module 'module))) 
     509                        (save-selected-window 
     510                          (pop-to-buffer buf))))) 
     511                   ("Show doc and go" . 
     512                    (lambda (candidate) 
     513                      (let* ((module (plcmp-get-current-module-name)) 
     514                             (buf (plcmp-get-man-buffer module 'module))) 
     515                        (pop-to-buffer buf)))) 
     516                   ("Open module file" . 
     517                    (lambda (method) 
     518                      (let ((module (plcmp-get-current-module-name))) 
     519                        (plcmp-open-module-file module)))) 
     520                   ("Open module file other window" . 
     521                    (lambda (method) 
     522                      (let ((module-name (plcmp-get-current-module-name))) 
     523                        (plcmp-open-module-file module-name 'pop-to-buffer)))) 
     524                   ("Open module file other frame" . 
     525                  (lambda (candidate) 
     526                    (let ((module-name (plcmp-get-current-module-name))) 
     527                      (plcmp-open-module-file module-name 
     528                                              'switch-to-buffer-other-frame)))) 
     529                   ("Add to kill-ring" . kill-new) 
     530                   ("Insert source name" . 
     531                    (lambda (candidate) 
     532                      (let ((name (plcmp-anything-get-current-source-name))) 
     533                        (and (stringp name) 
     534                             (insert name))))) 
     535                   )) 
    496536        (init . (lambda () 
    497537                  (with-current-buffer (anything-candidate-buffer 'global) 
     
    619659;;; other buffer words 
    620660(defvar plcmp-perl-buffer-re "\\.p[lm]$") 
     661(defvar plcmp-other-perl-buffer-limit-number 30) 
    621662(defvar plcmp-other-perl-buffers-words-faces 
    622663  '(font-lock-function-name-face 
     
    629670 
    630671(defun plcmp-get-other-perl-buffers-words () 
    631   (let ((perl-buffers (remove-if-not (lambda (buf) 
     672  (let* ((perl-buffers (remove-if-not (lambda (buf) 
    632673                                       (string-match plcmp-perl-buffer-re (buffer-name buf))) 
    633                                      (buffer-list)))) 
     674                                     (buffer-list))) 
     675         (perl-buffers (subseq perl-buffers 0 plcmp-other-perl-buffer-limit-number))) 
    634676    (prog1 (loop for buffer in perl-buffers 
     677                 when (bufferp buffer) 
    635678                 nconc (with-current-buffer buffer 
    636679                         (plcmp-get-face-words plcmp-other-perl-buffers-words-faces))) 
    637680      (plcmp-log "length of other perl-buffers: %s" (length perl-buffers))))) 
    638681 
     682 
     683(defun plcmp--mk-other-perl-buffer-source (source-name faces buffer-name) 
     684  `((name . ,(concat source-name " *" buffer-name "*")) 
     685    (action . (("Insert" . plcmp-insert))) 
     686    (init . (lambda () 
     687              (let ((words (with-current-buffer (get-buffer ,buffer-name) 
     688                             (plcmp-get-face-words ',faces)))) 
     689                (with-current-buffer (anything-candidate-buffer 'global) 
     690                  (plcmp-insert-each-line words))))) 
     691    (candidates-in-buffer))) 
     692 
     693(defun plcmp--sources-other-perl-buffers (source-name faces) 
     694  (let* ((perl-buffers (remove-if-not (lambda (buf) 
     695                                        (string-match plcmp-perl-buffer-re (buffer-name buf))) 
     696                                      (buffer-list))) 
     697         (perl-buffers (subseq perl-buffers 0 plcmp-other-perl-buffer-limit-number)) 
     698         (sources (loop for buffer in perl-buffers 
     699                        when (bufferp buffer) 
     700                        collect (with-current-buffer buffer 
     701                                  (plcmp--mk-other-perl-buffer-source 
     702                                   source-name 
     703                                   faces 
     704                                   (buffer-name buffer)))))) 
     705    (prog1 sources 
     706      (plcmp-log "plcmp--sources-other-perl-buffers:") 
     707      (plcmp-log sources)))) 
     708     
     709(defun plcmp-get-sources-other-perl-buffers-variable () 
     710  (plcmp--sources-other-perl-buffers "variables" '(font-lock-variable-name-face))) 
     711 
     712(defun plcmp-get-sources-other-perl-buffers-hashes () 
     713  (plcmp--sources-other-perl-buffers "hashes" '(cperl-hash-face))) 
     714 
     715(defun plcmp-get-sources-other-perl-buffers-arrays () 
     716  (plcmp--sources-other-perl-buffers "arrays" '(cperl-array-face))) 
     717 
     718(defun plcmp-get-sources-other-perl-buffers-functions () 
     719  (plcmp--sources-other-perl-buffers "functions" '(font-lock-function-name-face))) 
    639720 
    640721;;; man 
     
    731812      (match-string 1 module)))) 
    732813 
     814;;;TODO 
     815(defun plcmp-completion-get-man-buffer (candidate) 
     816  "return manpage buffer ,called in completion source action" 
     817  (let* ((name (plcmp--anything-get-current-source-name)) 
     818         (ret (cond 
     819               ((string-equal name "builtin functions") 
     820                (plcmp-get-man-buffer candidate 'function)) 
     821               ((or (string-equal name "using modules") 
     822                    (string-equal name "installed modules")) 
     823                (plcmp-get-man-buffer candidate)) 
     824               ((string-equal name "builtin variables") 
     825                (plcmp-get-man-buffer "" 'variables)) 
     826               ((string-match (concat plcmp--mk-module-source-name "$") 
     827                              name) 
     828                (plcmp-get-current-module-name))))) 
     829    (prog1 ret 
     830      (plcmp-log "plcmp-completion-get-man-buffer candidate: %s return: %s" 
     831                 candidate 
     832                 ret)))) 
     833 
     834 
    733835(defvar plcmp-type-completion 
    734836    '(plcmp-completion 
    735837      (action . (("Insert" . plcmp-insert) 
     838                 ("Show man" . 
     839                  (lambda (candidate) 
     840                    (anything-aif (plcmp-completion-get-man-buffer candidate) 
     841                        (switch-to-buffer it)))) 
    736842;;                  ("Open module file" . plcmp-open-module-file) 
    737843;;                  ("Open module file other window" . 
     
    795901                (lambda (candidate) 
    796902                  (when (plcmp-open-doc candidate 'man) 
    797                     (call-interactively (plcmp-get-occur-fn) candidate)))) 
     903                    (call-interactively (plcmp-get-occur-fn) 
     904                                        (regexp-quote candidate))))) 
    798905               ("Insert man name" . insert) 
    799906               ("Add man name to kill-ring" . kill-new))))) 
     
    818925                           (function "perldoc -f") 
    819926                           (variable "perldoc perlvar"))) 
    820          (man-args topic) 
    821          (bufname (concat "*Man " man-args "*")) 
    822          (buffer  (get-buffer bufname))) 
    823     (if buffer 
    824         buffer 
    825       (require 'env) 
    826       (message "Invoking %s %s in the background" manual-program man-args) 
    827       (setq buffer (generate-new-buffer bufname)) 
    828       (with-current-buffer buffer 
    829         (setq buffer-undo-list t) 
    830         (setq Man-original-frame (selected-frame)) 
    831         (setq Man-arguments man-args)) 
    832       (let ((process-environment (copy-sequence process-environment)) 
     927         (command (if (eq type 'variable) 
     928                      manual-program 
     929                    (concat manual-program " " topic))) 
     930         (bufname (concat "*perldoc " topic "*")) 
     931         (buffer  (get-buffer-create bufname))) 
     932    (require 'env) 
     933    (let ((process-environment (copy-sequence process-environment)) 
    833934            ;; The following is so Awk script gets \n intact 
    834935            ;; But don't prevent decoding of the outside. 
     
    848949        ;; Prevent any attempt to use display terminal fanciness. 
    849950        (setenv "TERM" "dumb") 
    850         ;; In Debian Woody, at least, we get overlong lines under X 
    851         ;; unless COLUMNS or MANWIDTH is set.  This isn't a problem on 
    852         ;; a tty.  man(1) says: 
    853         ;;        MANWIDTH 
    854         ;;               If $MANWIDTH is set, its value is used as the  line 
    855         ;;               length  for which manual pages should be formatted. 
    856         ;;               If it is not set, manual pages  will  be  formatted 
    857         ;;               with  a line length appropriate to the current ter- 
    858         ;;               minal (using an ioctl(2) if available, the value of 
    859         ;;               $COLUMNS,  or falling back to 80 characters if nei- 
    860         ;;               ther is available). 
    861         (if window-system 
    862             (unless (or (getenv "MANWIDTH") (getenv "COLUMNS")) 
    863               ;; This isn't strictly correct, since we don't know how 
    864               ;; the page will actually be displayed, but it seems 
    865               ;; reasonable. 
    866               (setenv "COLUMNS" (number-to-string 
    867                                  (cond 
    868                                   ((and (integerp Man-width) (> Man-width 0)) 
    869                                    Man-width) 
    870                                   (Man-width (frame-width)) 
    871                                   ((window-width))))))) 
    872         (setenv "GROFF_NO_SGR" "1") 
    873         (let ((exit-status 
    874                (call-process shell-file-name nil (list buffer nil) nil 
    875                              shell-command-switch 
    876                              (format (Man-build-man-command) man-args))) 
    877               (msg "")) 
    878           (when (and (numberp exit-status) 
    879                      (= exit-status 0)) 
    880             (get-buffer bufname))))))) 
     951        (save-window-excursion (shell-command command bufname)) 
     952        (get-buffer bufname)))) 
    881953 
    882954(defun* plcmp-open-doc (topic &optional (type 'module) (show-fn 'switch-to-buffer)) 
     
    906978(defvar plcmp-anything-source-completion-using-modules 
    907979  `((name . "using modules") 
    908     (type . plcmp-completion) 
     980    (action . (("Insert" . plcmp-insert) 
     981               ("Show doc" . 
     982                (lambda (candidate) 
     983                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     984                    (save-selected-window 
     985                      (pop-to-buffer buf))))) 
     986               ("Show doc and go" . 
     987                (lambda (candidate) 
     988                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     989                    (pop-to-buffer buf)))) 
     990               ("occur" . 
     991                (lambda (candidate) 
     992                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     993                    (switch-to-buffer buf) 
     994                    (call-interactively (plcmp-get-occur-fn))))) 
     995               ("Add to kill-ring" . kill-new))) 
    909996    (init . (lambda () 
    910997              (with-current-buffer (anything-candidate-buffer 'global) 
     
    9141001(defvar plcmp-anything-source-completion-builtin-functions 
    9151002  `((name . "builtin functions") 
    916     (type . plcmp-completion) 
     1003    (action . (("Insert" . plcmp-insert) 
     1004               ("Show doc" . 
     1005                (lambda (candidate) 
     1006                  (let ((buf (plcmp-get-man-buffer candidate 'function))) 
     1007                    (save-selected-window 
     1008                      (pop-to-buffer buf))))) 
     1009               ("Show doc and go" . 
     1010                (lambda (candidate) 
     1011                  (let ((buf (plcmp-get-man-buffer candidate 'function))) 
     1012                    (switch-to-buffer-other-window buf)))) 
     1013               ("occur" . 
     1014                (lambda (candidate) 
     1015                  (let ((buf (plcmp-get-man-buffer candidate 'function))) 
     1016                    (switch-to-buffer buf) 
     1017                    (funcall (plcmp-get-occur-fn) 
     1018                             (regexp-quote candidate) 
     1019                             nil)))) 
     1020               ("Add to kill-ring" . kill-new))) 
    9171021    (init . (lambda () 
    9181022              (with-current-buffer (anything-candidate-buffer 'global) 
     
    9221026(defvar plcmp-anything-source-completion-builtin-variables 
    9231027  `((name . "builtin variables") 
    924     (type . plcmp-completion) 
     1028    (action . (("Insert" . plcmp-insert) 
     1029               ("Show doc" . 
     1030                (lambda (candidate) 
     1031                  (let ((buf (plcmp-get-man-buffer candidate 'variable)) 
     1032                        (re (rx-to-string `(and bol (= 4 space) 
     1033                                                (group (eval ,candidate)) 
     1034                                                (syntax whitespace))))) 
     1035                    (with-current-buffer buf 
     1036                      (re-search-forward re nil t)) 
     1037                    (save-selected-window 
     1038                      (pop-to-buffer buf))))) 
     1039               ("Show doc and go" . 
     1040                (lambda (candidate) 
     1041                  (let ((buf (plcmp-get-man-buffer candidate 'variable)) 
     1042                        (re (rx-to-string `(and bol (= 4 space) 
     1043                                                (group (eval ,candidate)) 
     1044                                                (syntax whitespace))))) 
     1045                    (switch-to-buffer-other-window buf) 
     1046                    (re-search-forward re nil t)))) 
     1047               ("occur" . 
     1048                (lambda (candidate) 
     1049                  (let ((buf (plcmp-get-man-buffer candidate 'variable))) 
     1050                    (switch-to-buffer buf) 
     1051                    (funcall (plcmp-get-occur-fn) 
     1052                             (regexp-quote candidate) 
     1053                             nil)))) 
     1054               ("Add to kill-ring" . kill-new))) 
    9251055    (init . (lambda () 
    9261056              (with-current-buffer (anything-candidate-buffer 'global) 
     
    9321062(defvar plcmp-anything-source-completion-installed-modules 
    9331063  `((name . "installed modules") 
    934     (type . plcmp-completion) 
     1064    (action . (("Insert" . plcmp-insert) 
     1065               ("Show doc" . 
     1066                (lambda (candidate) 
     1067                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     1068                    (save-selected-window 
     1069                      (pop-to-buffer buf))))) 
     1070               ("Show doc and go" . 
     1071                (lambda (candidate) 
     1072                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     1073                    (pop-to-buffer buf)))) 
     1074               ("occur" . 
     1075                (lambda (candidate) 
     1076                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     1077                    (switch-to-buffer buf) 
     1078                    (call-interactively (plcmp-get-occur-fn))))) 
     1079               ("Add to kill-ring" . kill-new))) 
    9351080    (init . (lambda () 
    9361081              (with-current-buffer (anything-candidate-buffer 'global) 
     
    9411086(defvar plcmp-anything-source-completion-buffer-dabbrevs 
    9421087  `((name . "buffer dabbrevs") 
    943     (type . plcmp-completion) 
     1088    (action . (("Insert" . plcmp-insert) 
     1089               ("occur" . 
     1090                (lambda (candidate) 
     1091                  (funcall (plcmp-get-occur-fn) 
     1092                           (regexp-quote candidate) 
     1093                           nil))) 
     1094               ("Add to kill-ring" . kill-new))) 
    9441095    (init . (lambda () 
    9451096              (let* ((words (plcmp-get-buffer-dabbrevs)) 
     
    9521103(defvar plcmp-anything-source-completion-other-perl-buffers-words 
    9531104  `((name . "other buffer keywords") 
    954     (type . plcmp-completion) 
     1105    (action . (("Insert" . plcmp-insert))) 
    9551106    (init . (lambda () 
    9561107              (with-current-buffer (anything-candidate-buffer 'global) 
     
    9631114(defvar plcmp-anything-source-doc-man-pages 
    9641115  '((name . "perl man pages") 
    965     (type . plcmp-doc) 
     1116    (action . (("Show man" . woman))) 
    9661117    (init . (lambda () 
    9671118              (with-current-buffer (anything-candidate-buffer 'global) 
     
    9691120    (candidates-in-buffer))) 
    9701121 
     1122(defvar plcmp-anything-source-doc-using-modules 
     1123  '((name . "using modules") 
     1124    (action . (("Show doc" . 
     1125                (lambda (candidate) 
     1126                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     1127                    (save-selected-window 
     1128                      (pop-to-buffer buf))))) 
     1129               ("Show doc and go" . 
     1130                (lambda (candidate) 
     1131                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     1132                    (switch-to-buffer buf)))) 
     1133               ("occur doc buffer" . 
     1134                (lambda (candidate) 
     1135                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     1136                    (switch-to-buffer buf) 
     1137                    (call-interactively (plcmp-get-occur-fn) 
     1138                                        (regexp-quote candidate))))) 
     1139               ("Add to kill-ring" . kill-new))) 
     1140    (init . (lambda () 
     1141              (with-current-buffer (anything-candidate-buffer 'global) 
     1142                (plcmp-insert-each-line plcmp-using-modules)))) 
     1143    (candidates-in-buffer))) 
     1144 
     1145(defvar plcmp-anything-source-doc-installed-modules 
     1146  '((name . "installed modules") 
     1147    (action . (("Show doc" . 
     1148                (lambda (candidate) 
     1149                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     1150                    (save-selected-window 
     1151                      (pop-to-buffer buf))))) 
     1152               ("Show doc and go" . 
     1153                (lambda (candidate) 
     1154                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     1155                    (switch-to-buffer buf)))) 
     1156               ("occur doc buffer" . 
     1157                (lambda (candidate) 
     1158                  (let ((buf (plcmp-get-man-buffer candidate 'module))) 
     1159                    (switch-to-buffer buf) 
     1160                    (call-interactively (plcmp-get-occur-fn))))) 
     1161               ("Add to kill-ring" . kill-new))) 
     1162    (init . (lambda () 
     1163              (with-current-buffer (anything-candidate-buffer 'global) 
     1164                (plcmp-insert-each-line plcmp-installed-modules)))) 
     1165    (candidates-in-buffer))) 
     1166 
     1167 
    9711168;; menu 
    9721169(defvar plcmp-anything-source-menu 
    973   '((name . "perl-completion menu") 
     1170  `((name . "perl-completion menu") 
    9741171    (type . command) 
    975     (init . (lambda () 
    976               (with-current-buffer (anything-candidate-buffer 'global) 
    977                 (let ((commands (loop for sym being the symbols 
    978                                       for s = (symbol-name sym) 
    979