Reputation: 21
The best auto-complete can do is match word characters. For example: auto-complete will only match $longvariablename in a previously used variable, $longvariablename[$i]{'key'}. I would like to configure auto-complete, or any other emacs el file to match the entire variable.
As a last resort, I'm going to have to learn lisp #shudder#.
Thanks in advance.
Upvotes: 2
Views: 397
Reputation: 21172
You can customize hippie expand.
For example the following customization expands all strings until a space or a semicolon.
(defun try-expand-perl-extended-var (old)
(let ((old-fun (symbol-function 'he-dabbrev-search)))
(fset 'he-dabbrev-search (symbol-function 'perl-extended-var-search))
(unwind-protect
(try-expand-dabbrev old)
(fset 'he-dabbrev-search old-fun))))
(defun perl-extended-var-search (pattern &optional reverse limit)
(let ((result ())
(regpat (concat (regexp-quote pattern) "[^ ;]+")))
(while (and (not result)
(if reverse
(re-search-backward regpat limit t)
(re-search-forward regpat limit t)))
(setq result (buffer-substring-no-properties (save-excursion
(goto-char (match-beginning 0))
(skip-syntax-backward "w_")
(point))
(match-end 0)))
(if (he-string-member result he-tried-table t)
(setq result nil))) ; ignore if bad prefix or already in table
result))
Don't forget to include your custom function into make-hippie-expand-function
list
(global-set-key [(meta f5)] (make-hippie-expand-function
'(try-expand-perl-extended-var
try-expand-dabbrev-visible
try-expand-dabbrev
try-expand-dabbrev-all-buffers) t))
Upvotes: 4