Changeset 19304

Show
Ignore:
Timestamp:
09/15/08 01:18:36 (4 months ago)
Author:
imakado
Message:

補完候補の並び順を賢く。*lib/というディレクトリがカレントディレクトリに含まれていたら補完候補収得の歳にPERL5LIBに一時的に追加する

Files:
1 modified

Legend:

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

    r19252 r19304  
    3737;; TODO: 
    3838;; set-perl5lib 
    39  
     39;; open doc -> occur 
    4040 
    4141;;;code: 
     
    4646(require 'rx) 
    4747 
     48 
     49 
     50 
    4851(defgroup perl-completion nil 
    4952  "" 
     
    6063                                         (regexp ,plcmp-perl-ident-re))))) 
    6164 
    62 (defvar plcmp-perl-package-re "[a-zA-Z0-9:]+") 
     65(defvar plcmp-perl-package-re "[a-zA-Z:]+") 
    6366 
    6467(defvar plcmp-builtin-functions 
     
    122125 
    123126;;; macros 
     127 
     128;; perl5 lib 
     129;; idea: http://svn.coderepos.org/share/lang/elisp/set-perl5lib/set-perl5lib.el 
     130;;       http://d.hatena.ne.jp/sun-basix/20080117/1200528765 (Japanese) 
     131; (buffer-file-name default-directory 
     132(defcustom plcmp-lib-directory-re "lib/" 
     133  "regexp, used in `plcmp--get-lib-path' to get library path. 
     134eg, when directory of buffer is \"~/someproject/lib/hoge.pm\" and this value is \"lib/\" 
     135set \"~/someproject/lib\" to PERL5LIB automatically during perl-completion's command invocation." 
     136    :group 'perl-completion) 
     137 
     138(defvar plcmp-additional-lib-directories nil 
     139  "list of string(directory),each directory set to PERL5LIB during perl-completion's command invocation. 
     140this variable is buffer local") ;buffer local 
     141(make-variable-buffer-local 'plcmp-additional-lib-directories) 
     142 
     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)))) 
     152 
     153(defun plcmp--get-lib-path () 
     154  "return string(additional library path)" 
     155  (let ((dir (plcmp-get-current-directory)) 
     156        (lib-re (rx-to-string `(and (group 
     157                                     bol 
     158                                     (* not-newline) 
     159                                     ,plcmp-lib-directory-re))))) 
     160    (when (string-match lib-re dir) 
     161      (let ((lib-dir (match-string 1 dir))) 
     162        (and (stringp lib-dir) 
     163             (file-exists-p lib-dir) 
     164             (directory-file-name lib-dir)))))) 
     165 
     166(defmacro plcmp-with-set-perl5-lib (&rest body) 
     167  "Set each path that value of `plcmp--get-lib-path' to PERL5LIB. 
     168then execute BODY" 
     169  `(let ((process-environment (copy-sequence process-environment))) 
     170     (require 'env) 
     171     (let ((additional-lib-list (append plcmp-additional-lib-directories 
     172                                        (when (plcmp--get-lib-path) 
     173                                          (list (plcmp--get-lib-path))))) 
     174           (old-perl5lib (or (getenv "PERL5LIB") ""))) 
     175       (when additional-lib-list 
     176         (let* ((additional-lib-str (mapconcat 'identity additional-lib-list path-separator)) 
     177                (current-perl5lib (concat additional-lib-str path-separator old-perl5lib))) 
     178           (when (and (stringp current-perl5lib) 
     179                      (not (equal "" current-perl5lib))) 
     180             (setenv "PERL5LIB" current-perl5lib) 
     181             (plcmp-log "plcmp-with-set-perl5-lib PERL5LIB: %s" current-perl5lib)) 
     182           (progn 
     183             ,@body)))))) 
     184 
     185 
    124186(defmacro define-plcmp-command (command-name-with-no-prefix args &rest body) 
    125187  (let* ((prefix "plcmp-cmd-") 
     
    129191       (interactive) 
    130192       (unwind-protect 
    131            (progn (plcmp-initialize-variables) 
    132                   (progn 
    133                     ,@body)) 
     193           (plcmp-with-set-perl5-lib 
     194            (progn (plcmp-initialize-variables) 
     195                   ,@body)) 
    134196         (plcmp-cleanup))))) 
    135197(put 'define-plcmp-command 'lisp-indent-function 'defun) 
     
    157219 
    158220(defsubst plcmp-notfound-p (s) 
    159   (string-match "^Can't locate [^ \t]+ in" s)) 
     221  (anything-aif (string-match "^Can't locate [^ \t]+ in" s) 
     222      (prog1 it 
     223        (plcmp-log "module notfound errmsg: %s" s)))) 
    160224 
    161225(defsubst plcmp-tramp-p () 
    162226  (when (and (featurep 'tramp) 
    163227             (fboundp 'tramp-tramp-file-p)) 
    164     (tramp-tramp-file-p (plcmp-get-current-directory)))) 
     228    (let* ((dir (plcmp-get-current-directory)) 
     229           (tramp? (tramp-tramp-file-p dir))) 
     230      (when tramp? 
     231        (prog1 tramp? 
     232          (plcmp-log "plcmp-tramp-p return non-nil: %s" dir)))))) 
    165233 
    166234(defsubst plcmp-insert-each-line (los) 
     
    192260              collect source into unmatch-sources 
    193261              finally (return (nconc match-sources unmatch-sources)))) 
    194     (error sources))) 
    195 ;;(plcmp-re-sort-sources "variable" (plcmp-get-sources-for-complete-all)) 
    196  
    197 (defun* plcmp-collect-matches 
     262    (error (plcmp-log "Error: plcmp-re-sort-sources\nregexps: %s\nsources: %s" 
     263                      regexps 
     264                      sources) 
     265            sources))) 
     266 
     267(defsubst* plcmp-collect-matches 
    198268    (re &optional (count 0) (match-string-fn 'match-string) 
    199269        (point-min (point-min)) (point-max (point-max))) 
     
    202272          while (re-search-forward re point-max t) 
    203273          collect (funcall match-string-fn count)))) 
     274 
     275(defun plcmp-get-occur-fn () 
     276  "return `occur-by-moccur if installed color-moccur.el otherwise return `occur" 
     277  (if (require 'color-moccur nil t) 
     278      'occur-by-moccur 
     279    'occur)) 
     280 
    204281 
    205282;;; log 
     
    210287(defun plcmp-log (&rest messages) 
    211288  (ignore-errors 
    212     (let* ((str (or (ignore-errors (apply 'format messages)) 
    213                     (prin1-to-string messages))) 
    214            (strn (concat str "\n"))) 
    215       (when plcmp-debug 
     289    (when plcmp-debug 
     290      (require 'pp) 
     291      (let* ((str (or (ignore-errors (apply 'format messages)) 
     292                      (pp-to-string messages))) 
     293             (strn (concat str "\n"))) 
    216294        (with-current-buffer (plcmp-log-buf) 
    217295          (goto-char (point-max)) 
    218           (insert strn))) 
    219       str))) 
     296          (insert strn)) 
     297        str)))) 
    220298(defun plcmp-message (&rest args) 
    221299  (when plcmp-debug 
    222     (apply 'message args))) 
     300    (prog1 (apply 'message args) 
     301      (apply 'plcmp-log args)))) 
    223302 
    224303 
     
    233312             (end (condition-case e 
    234313                      (cond 
    235                        ((some (lambda (s) (string-equal s preceding-string)) '("$" "@" "&" "&")) 
     314                       ((some (lambda (s) (string-equal s preceding-string)) '("$" "@" "%" "&")) 
    236315                        (backward-char) 
    237316                        (point)) 
     
    247326                           " " 
    248327                         ""))))) 
    249         (values initial-input real-initial-input))))) 
     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)))))) 
    250332 
    251333;;; installed modules 
     
    281363      (unless (zerop (buffer-size)) 
    282364        (setq plcmp-installed-modules (plcmp-collect-matches plcmp-perl-package-re)) 
    283         (plcmp-message "cached installed modules %s" plcmp-installed-modules))))) 
     365        (message "finished getting installed modules asynchronously.") 
     366        (plcmp-log "cached installed modules %s" plcmp-installed-modules))))) 
    284367 
    285368(defun plcmp--installed-modules-asynchronously () 
     
    301384    proc)) 
    302385 
    303 ;;  (plcmp--installed-modules-asynchronously) 
    304  
    305  
    306 ;; todo: ne (length plcmp--installed-modules-synchronously) 
    307 (defun plcmp--installed-modules-perl () 
    308   (let* ((str (shell-command-to-string (concat " perl -e ' use File::Find; @dirs = grep { q{.} ne $_} @INC" 
    309                                                "; my $dir_name = $dir" 
    310                                                " ;my $mods = sub { if ( -f && /.pm$/ ) { print $File::Find::name, \"\n\"; } }; find $mods, @dirs; ' "))) 
    311          (files (delete-dups (delete "" (delete "." (split-string str "\n")))))) 
    312     (loop for file in files 
    313           collect (plcmp--package-name file)))) 
    314  
    315 (defun plcmp--package-name (file) 
    316   (let ((re (rx-to-string `(and "package" 
    317                                   (+ space) 
    318                                   (group 
    319                                    (regexp ,plcmp-perl-package-re)) 
    320                                   (* space) 
    321                                   ";" 
    322                                   )))) 
    323     (when (and (stringp file) 
    324                (file-exists-p file) 
    325                (file-readable-p file)) 
    326       (with-temp-buffer 
    327         (insert-file-contents file) 
    328         (goto-char (point-min)) 
    329         (when (re-search-forward re nil t) 
    330          (match-string-no-properties 1)))))) 
    331    
     386 
    332387;;; current package 
    333388(defvar plcmp-current-package-name "") 
     
    345400      (goto-char (point-min)) 
    346401      (when (re-search-forward re nil t) 
    347         (setq plcmp-current-package-name 
    348               (match-string-no-properties 1)))))) 
     402        (match-string-no-properties 1))))) 
    349403 
    350404(defvar plcmp-using-modules nil) 
     
    401455  (plcmp-collect-matches plcmp-sub-re 1 'match-string-no-properties)) 
    402456 
     457(defun plcmp-get-module-file-path (module-name) 
     458  (let* ((path (shell-command-to-string (concat "perldoc -l " (shell-quote-argument module-name)))) 
     459         (path (plcmp-trim path))) 
     460    (and (file-exists-p path) 
     461         path))) 
     462 
    403463(defun plcmp--inspect-module-scrape (module-name) 
    404464  (when (and (stringp module-name) 
    405465             (plcmp-module-p module-name)) 
    406     (let* ((path (shell-command-to-string (concat "perldoc -l " 
    407                                                   module-name))) 
    408            (path (plcmp-trim path))) 
     466    (let* ((path (plcmp-get-module-file-path module-name))) 
    409467      (when (and (stringp path) 
    410468                 (file-exists-p path) 
     
    415473 
    416474(defsubst plcmp--inspect-module (module-name) 
    417   (or (plcmp--inspect-module-class-inspector module-name) 
    418       (plcmp--inspect-module-scrape module-name))) 
     475  (prog1 (or (plcmp--inspect-module-class-inspector module-name) 
     476             (plcmp--inspect-module-scrape module-name)) 
     477    (message "getting methods %s ..." module-name))) 
    419478 
    420479 
     
    429488 
    430489;; module-name -> source 
     490(defvar plcmp--mk-module-source-name " Methods") 
     491 
    431492(defun plcmp--mk-module-source (module-name) 
    432493  (anything-aif (assoc-default module-name plcmp-module-methods-alist) 
    433       `((name . ,(concat module-name " Methods")) 
    434         (type . plcmp-completion) 
     494      `((name . ,(concat module-name plcmp--mk-module-source-name)) 
     495        (type . plcmp-completion-method) 
    435496        (init . (lambda () 
    436497                  (with-current-buffer (anything-candidate-buffer 'global) 
     
    482543 (hash . (list of hashes)) 
    483544 (functions . (list of functions)))") 
    484 (add-hook 'plcmp--command-cleanup-hook (lambda () (setq plcmp-current-buffer-words-alist nil))) 
    485  
    486 ;; (with-current-buffer "Plagger.pm" 
    487 ;;   (plcmp-get-face-words '(font-lock-variable-name-face))) 
     545(add-hook 'plcmp--command-cleanup-hook 
     546          (lambda () 
     547            (setq plcmp-current-buffer-words-alist nil))) 
    488548 
    489549 
     
    502562(defun plcmp-get-current-buffer-variables () 
    503563  (let ((alist (plcmp-get-current-buffer-words-alist))) 
    504     (assoc-default 'variable alist 'eq))) 
    505  
    506 (defvar plcmp-anything-source-current-buffer-variables 
     564    (prog1 (assoc-default 'variable alist 'eq) 
     565      (plcmp-log "getting current buffer variables")))) 
     566 
     567(defvar plcmp-anything-source-completion-current-buffer-variables 
    507568  `((name . "buffer variables") 
    508569    (type . plcmp-completion) 
     
    515576(defun plcmp-get-current-buffer-arrays () 
    516577  (let ((alist (plcmp-get-current-buffer-words-alist))) 
    517     (assoc-default 'array plcmp-current-buffer-words-alist 'eq))) 
    518  
    519 (defvar plcmp-anything-source-current-buffer-arrays 
     578    (prog1 (assoc-default 'array alist 'eq) 
     579      (plcmp-log "getting current buffer arrays")))) 
     580 
     581(defvar plcmp-anything-source-completion-current-buffer-arrays 
    520582  `((name . "buffer arrays") 
    521583    (type . plcmp-completion) 
     
    528590(defun plcmp-get-current-buffer-hashes () 
    529591  (let ((alist (plcmp-get-current-buffer-words-alist))) 
    530     (assoc-default 'hash alist 'eq))) 
    531  
    532 (defvar plcmp-anything-source-current-buffer-hashes 
     592    (prog1 (assoc-default 'hash alist 'eq) 
     593      (plcmp-log "getting current buffer hashes")))) 
     594 
     595(defvar plcmp-anything-source-completion-current-buffer-hashes 
    533596  `((name . "buffer hashes") 
    534597    (type . plcmp-completion) 
     
    541604(defun plcmp-get-current-buffer-functions () 
    542605  (let ((alist (plcmp-get-current-buffer-words-alist))) 
    543     (assoc-default 'function alist 'eq))) 
    544  
    545 (defvar plcmp-anything-source-current-buffer-functions 
     606    (prog1 (assoc-default 'function alist 'eq) 
     607      (plcmp-log "getting current buffer functions")))) 
     608 
     609(defvar plcmp-anything-source-completion-current-buffer-functions 
    546610  `((name . "buffer functions") 
    547611    (type . plcmp-completion) 
     
    555619;;; other buffer words 
    556620(defvar plcmp-perl-buffer-re "\\.p[lm]$") 
     621(defvar plcmp-other-perl-buffers-words-faces 
     622  '(font-lock-function-name-face 
     623    font-lock-variable-name-face 
     624    font-lock-keyword-face 
     625    font-lock-builtin-face 
     626    font-lock-type-face 
     627    cperl-array-face 
     628    cperl-hash-face)) 
     629 
    557630(defun plcmp-get-other-perl-buffers-words () 
    558631  (let ((perl-buffers (remove-if-not (lambda (buf) 
    559632                                       (string-match plcmp-perl-buffer-re (buffer-name buf))) 
    560633                                     (buffer-list)))) 
    561     (loop for buffer in perl-buffers 
    562           nconc (with-current-buffer buffer 
    563                   (plcmp-get-face-words))))) 
    564  
     634    (prog1 (loop for buffer in perl-buffers 
     635                 nconc (with-current-buffer buffer 
     636                         (plcmp-get-face-words plcmp-other-perl-buffers-words-faces))) 
     637      (plcmp-log "length of other perl-buffers: %s" (length perl-buffers))))) 
    565638 
    566639 
     
    626699;;;; Anything 
    627700;;;; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     701 
     702(defun plcmp--anything-get-current-source-name () 
     703  "Return the source name for the current selection." 
     704  (declare (special source)) 
     705  ;; The name `anything-get-current-source' should be used in init function etc. 
     706  (if (and (boundp 'anything-source-name) (stringp anything-source-name)) 
     707      anything-source-name 
     708    (with-current-buffer (anything-buffer-get) 
     709      ;; This goto-char shouldn't be necessary, but point is moved to 
     710      ;; point-min somewhere else which shouldn't happen. 
     711      (goto-char (overlay-start anything-selection-overlay)) 
     712      (let* ((header-pos (anything-get-previous-header-pos))) 
     713        (save-excursion 
     714          (assert header-pos) 
     715          (goto-char header-pos) 
     716          (prog1 (buffer-substring-no-properties 
     717                  (line-beginning-position) (line-end-position)) 
     718            (plcmp-log "plcmp-anything-get-current-source-name: %s" 
     719                       (buffer-substring-no-properties 
     720                        (line-beginning-position) (line-end-position))))))))) 
     721 
     722(defun plcmp-get-current-module-name () 
     723  (let* ((module (plcmp--anything-get-current-source-name))) 
     724    (when (string-match 
     725           (rx-to-string `(and 
     726                           bol 
     727                           (group 
     728                            (regexp ,plcmp-perl-package-re)) 
     729                           ,plcmp--mk-module-source-name)) 
     730           module) 
     731      (match-string 1 module)))) 
     732 
    628733(defvar plcmp-type-completion 
    629734    '(plcmp-completion 
    630735      (action . (("Insert" . plcmp-insert) 
    631                  ("Open module file" . plcmp-open-module-file) 
     736;;                  ("Open module file" . plcmp-open-module-file) 
     737;;                  ("Open module file other window" . 
     738;;                   (lambda (candidate) 
     739;;                     (plcmp-open-module-file candidate 
     740;;                                             'switch-to-buffer-other-window))) 
     741;;                  ("Open module file other frame" . 
     742;;                   (lambda (candidate) 
     743;;                     (plcmp-open-module-file candidate 
     744;;                                             'switch-to-buffer-other-frame))) 
     745                  
     746                 ("Add to kill-ring" . kill-new) 
     747                 ("Insert source name" . 
     748                  (lambda (candidate) 
     749                    (let ((name (plcmp-anything-get-current-source-name))) 
     750                      (and (stringp name) 
     751                           (insert name))))) 
     752                 )))) 
     753(add-to-list 'anything-type-attributes plcmp-type-completion) 
     754 
     755(defvar plcmp-type-completion-method 
     756    '(plcmp-completion-method 
     757      (action . (("Insert" . plcmp-insert) 
     758                 ("Open module file" . 
     759                  (lambda (method) 
     760                    (let ((module (plcmp-get-current-module-name))) 
     761                      (plcmp-open-module-file module)))) 
    632762                 ("Open module file other window" . 
    633                   (lambda (candidate) 
    634                     (plcmp-open-module-file candidate 
    635                                             'switch-to-buffer-other-window))) 
     763                  (lambda (method) 
     764                    (let ((module-name (plcmp-get-current-module-name))) 
     765                      (plcmp-open-module-file module-name 'pop-to-buffer)))) 
    636766                 ("Open module file other frame" . 
    637767                  (lambda (candidate) 
    638                     (plcmp-open-module-file candidate 
    639                                             'switch-to-buffer-other-frame))) 
    640                  ("Add command to kill-ring" . kill-new) 
    641                  ;;                 ("Perldoc" . (lambda (candidate) 
    642                  ;;                                (plcmp-perldoc plcmp-data candidate))) 
    643                  ;;                 ("Perldoc -m" . (lambda (candidate) 
    644                  ;;                                   (plcmp-perldoc-m plcmp-data candidate))) 
     768                    (let ((module-name (plcmp-get-current-module-name))) 
     769                      (plcmp-open-module-file module-name 
     770                                              'switch-to-buffer-other-frame)))) 
     771                 ("Add to kill-ring" . kill-new) 
     772                 ("Insert source name" . 
     773                  (lambda (candidate) 
     774                    (let ((name (plcmp-anything-get-current-source-name))) 
     775                      (and (stringp name) 
     776                           (insert name))))) 
    645777                 )))) 
     778(add-to-list 'anything-type-attributes plcmp-type-completion-method) 
    646779 
    647780(defvar plcmp-type-man 
     
    659792                (lambda (candidate) 
    660793                  (plcmp-open-doc candidate 'man 'switch-to-buffer-other-frame))) 
     794               ("occur man buffer" . 
     795                (lambda (candidate) 
     796                  (when (plcmp-open-doc candidate 'man) 
     797                    (call-interactively (plcmp-get-occur-fn) candidate)))) 
    661798               ("Insert man name" . insert) 
    662                ("Add command to kill-ring" . kill-new))))) 
     799               ("Add man name to kill-ring" . kill-new))))) 
    663800 
    664801(defvar plcmp-type-perldoc 
    665802  '(plcmp-perldoc 
    666803    (action . ()))) 
    667  
    668 ;; append plcmp-* types to `anything-type-attributes' 
    669 (add-to-list 'anything-type-attributes plcmp-type-completion) 
    670804(add-to-list 'anything-type-attributes plcmp-type-man) 
    671805 
     
    675809 
    676810;;; perldoc 
    677 (defun plcmp-get-man-buffer (topic) 
     811(defun* plcmp-get-man-buffer (topic &optional (type 'module)) 
    678812  "like `Man-getpage-in-background' but call process synchronously. 
    679813return buffer or nil unless process return 0" 
    680814  (require 'man) 
    681   (let* ((man-args topic) 
     815  (let* ((manual-program (ecase type 
     816                           (module "perldoc") 
     817                           (man manual-program) 
     818                           (function "perldoc -f") 
     819                           (variable "perldoc perlvar"))) 
     820         (man-args topic) 
    682821         (bufname (concat "*Man " man-args "*")) 
    683822         (buffer  (get-buffer bufname))) 
     
    743882(defun* plcmp-open-doc (topic &optional (type 'module) (show-fn 'switch-to-buffer)) 
    744883  (require 'man) 
    745   (let ((manual-program (ecase type 
    746                           (module "perldoc") 
    747                           (man manual-program) 
    748                           (function "perldoc -f") 
    749                           (variable "perldoc perlvar")))) 
    750     (let ((manbuf (plcmp-get-man-buffer topic))) 
    751       (when (bufferp manbuf) 
    752         (funcall show-fn manbuf))))) 
     884  (let ((manbuf (plcmp-get-man-buffer topic type))) 
     885    (when (and (bufferp manbuf) 
     886               (functionp show-fn)) 
     887      (funcall show-fn manbuf)))) 
     888 
    753889 
    754890;;; open module file 
    755891(defun plcmp--find-module-file-no-select (module-name) 
    756892  (when (plcmp-module-p module-name) 
    757     (let* ((path (shell-command-to-string (concat "perldoc -l " module-name))) 
    758            (path (expand-file-name (plcmp-trim path)))) 
     893    (let* ((path (plcmp-get-module-file-path module-name)) 
     894           (path (expand-file-name path))) 
    759895      (when (and (file-exists-p path) 
    760896                 (file-readable-p path)) 
     
    807943    (type . plcmp-completion) 
    808944    (init . (lambda () 
    809               (let ((words (plcmp-get-buffer-dabbrevs))) 
     945              (let* ((words (plcmp-get-buffer-dabbrevs)) 
     946                     (words (delete plcmp-real-initial-input words))) 
    810947                (with-current-buffer (anything-candidate-buffer 'global) 
    811948                  (plcmp-insert-each-line words))))) 
     949    (requires-pattern . 4) 
    812950    (candidates-in-buffer))) 
    813951 
     
    818956              (with-current-buffer (anything-candidate-buffer 'global) 
    819957                (plcmp-insert-each-line (plcmp-get-other-perl-buffers-words))))) 
     958    (requires-pattern . 3) 
    820959    (candidates-in-buffer))) 
     960 
    821961 
    822962;; man, perldoc 
     
    850990;;; complete-all 
    851991(defvar plcmp-completion-all-static-sources 
    852   '(plcmp-anything-source-completion-buffer-dabbrevs 
     992  '( 
     993    plcmp-anything-source-completion-buffer-dabbrevs 
     994    plcmp-anything-source-completion-using-modules 
     995    plcmp-anything-source-completion-current-buffer-variables 
     996    plcmp-anything-source-completion-current-buffer-arrays 
     997    plcmp-anything-source-completion-current-buffer-hashes 
     998    plcmp-anything-source-completion-current-buffer-functions 
     999    plcmp-anything-source-completion-builtin-variables 
     1000    plcmp-anything-source-completion-builtin-functions     
    8531001    plcmp-anything-source-completion-other-perl-buffers-words 
    854     plcmp-anything-source-completion-builtin-variables 
    855     plcmp-anything-source-completion-builtin-functions 
    856     plcmp-anything-source-completion-using-modules 
    857     plcmp-anything-source-completion-installed-modules)) 
     1002    plcmp-anything-source-completion-installed-modules 
     1003    )) 
    8581004 
    8591005(defun plcmp-get-sources-for-complete-all () 
     
    9011047                       (save-excursion (or (ignore-errors (backward-sexp) 
    9021048                                                          (point)) 
    903                                            (point)))))) 
    904         (cond 
    905          ;; package 
    906          ;; $self->`!!' 
    907          ;; __PACKAGE__->`!!' 
    908          ((and (plcmp-method-p) 
    909                (string-match (rx bol 
    910                                  (or "$self" 
    911                                      "__PACKAGE__") 
    912                                  eol) 
    913                              obj-str)) 
    914           'package) 
    915          ;; method 
    916          ;; Foo->`!!' 
    917          ((plcmp-method-p) 
    918           'method) 
    919          ;; variable 
    920          ;; $foo`!!' 
    921          ((string-equal "$" (plcmp-preceding-string 1)) 
    922           'variable) 
    923          ;; array 
    924          ((string-equal "@" (plcmp-preceding-string 1)) 
    925           'array) 
    926          ;; hash 
    927          ((string-equal "%" (plcmp-preceding-string 1)) 
    928           'array) 
    929          ;; function 
    930          ((string-equal "&" (plcmp-preceding-string 1)) 
    931           'function) 
    932          ;; installed-module 
    933          ;; use `!!' 
    934          ((string-match (rx bol (* space) "use" (+ space)) 
    935                         (buffer-substring (point-at-bol) (point)))