Phải mất một số thao tác, nhưng bạn có thể kết hợp hoàn thành công ty và mở rộng hippie để cung cấp cho bạn trình đơn bật lên của các dòng từ bộ đệm hiện tại.
Trước tiên, bạn cần phải xác định một hàm để gọi thử-mở rộng-line (sửa đổi để trở việc mở rộng thay vì gọi ông mở rộng và trở t) từ hippie-exp.el và thu thập tất cả các bản mở rộng:
(defun get-hippie-expand-lines()
(let (completions-list candidate)
(setq candidate (my-try-expand-line nil))
(if candidate
(progn
(push candidate completions-list)
(while (progn
(setq candidate (my-try-expand-line t))
(if candidate
(push candidate completions-list)
nil))))
nil)
completions-list))
Sau đó, bạn có thể viết chương trình phụ trợ của công ty nhỏ để cung cấp cho bạn các ứng viên hoàn thành thông qua cửa sổ bật lên của công ty.
(defun company-hippie-line (command &optional arg &rest ignored)
(interactive (list 'interactive))
(cl-case command
(interactive (company-begin-backend 'company-hippie-line))
(prefix (and (not (looking-at "[:word:]"))
(let (p1 p2)
(save-excursion
(end-of-line)
(setq p2 (point))
(back-to-indentation)
(setq p1 (point)))
(buffer-substring-no-properties p1 p2))))
(candidates (get-hippie-expand-lines))))
;; Uncomment if you want to get line completion popups whenever found
;; (add-to-list 'company-backends 'company-hippie-line)
(global-set-key (kbd "C-x l") 'company-hippie-line)
Xem thêm thảo luận tại this post.
Tuyệt vời! Bây giờ, có thể sử dụng nó với một danh sách popup? –
@DavidWolever: http: // cx4a.org/software/auto-complete/là một cách để có được quảng cáo nhưng AC là một con thú của một thư viện. Tôi sẽ không biết về việc sử dụng nó. – progo