Speed up auto-completion in 'sh-script-mode'
* lisp/progmodes/sh-script.el (sh--cmd-completion-table-gen): New function, replacement for 'sh--cmd-completion-table'. (sh--cmd-completion-table): Function removed. (sh-completion-at-point-function): Use 'sh--cmd-completion-table-gen'. (Bug#59678)
This commit is contained in:
parent
e5b0141b0d
commit
f72cda2b82
1 changed files with 14 additions and 16 deletions
|
@ -1688,19 +1688,17 @@ This adds rules for comments and assignments."
|
||||||
;; (defun sh--var-completion-table (string pred action)
|
;; (defun sh--var-completion-table (string pred action)
|
||||||
;; (complete-with-action action (sh--vars-before-point) string pred))
|
;; (complete-with-action action (sh--vars-before-point) string pred))
|
||||||
|
|
||||||
(defun sh--cmd-completion-table (string pred action)
|
(defun sh--cmd-completion-table-gen (string)
|
||||||
(let ((cmds
|
(append (when (fboundp 'imenu--make-index-alist)
|
||||||
(append (when (fboundp 'imenu--make-index-alist)
|
(mapcar #'car
|
||||||
(mapcar #'car
|
(condition-case nil
|
||||||
(condition-case nil
|
(imenu--make-index-alist)
|
||||||
(imenu--make-index-alist)
|
(imenu-unavailable nil))))
|
||||||
(imenu-unavailable nil))))
|
(mapcar (lambda (v) (concat v "="))
|
||||||
(mapcar (lambda (v) (concat v "="))
|
(sh--vars-before-point))
|
||||||
(sh--vars-before-point))
|
(locate-file-completion-table
|
||||||
(locate-file-completion-table
|
exec-path exec-suffixes string nil t)
|
||||||
exec-path exec-suffixes string pred t)
|
sh--completion-keywords))
|
||||||
sh--completion-keywords)))
|
|
||||||
(complete-with-action action cmds string pred)))
|
|
||||||
|
|
||||||
(defun sh-completion-at-point-function ()
|
(defun sh-completion-at-point-function ()
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
@ -1713,14 +1711,14 @@ This adds rules for comments and assignments."
|
||||||
(list start end (sh--vars-before-point)
|
(list start end (sh--vars-before-point)
|
||||||
:company-kind (lambda (_) 'variable)))
|
:company-kind (lambda (_) 'variable)))
|
||||||
((sh-smie--keyword-p)
|
((sh-smie--keyword-p)
|
||||||
(list start end #'sh--cmd-completion-table
|
(list start end
|
||||||
|
(completion-table-with-cache #'sh--cmd-completion-table-gen)
|
||||||
:company-kind
|
:company-kind
|
||||||
(lambda (s)
|
(lambda (s)
|
||||||
(cond
|
(cond
|
||||||
((member s sh--completion-keywords) 'keyword)
|
((member s sh--completion-keywords) 'keyword)
|
||||||
((string-suffix-p "=" s) 'variable)
|
((string-suffix-p "=" s) 'variable)
|
||||||
(t 'function)))
|
(t 'function)))))))))
|
||||||
))))))
|
|
||||||
|
|
||||||
;;; Indentation and navigation with SMIE.
|
;;; Indentation and navigation with SMIE.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue