最好的自动完成功能是匹配单词字符。例如:auto-complete将仅匹配先前使用的变量$ longvariablename [$ i] {'key'}中的$ longvariablename。我想配置自动完成或任何其他emacs el文件以匹配整个变量。
作为最后的手段,我将不得不学习lisp #shudder#。
提前致谢。
答案 0 :(得分:3)
您可以自定义hippie expand。
例如,以下自定义扩展所有字符串,直到空格或分号。
(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))
不要忘记将自定义功能包含在make-hippie-expand-function
列表
(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))