Complete the "env" directive in firejail-mode.el
This commit is contained in:
parent
c49caf7a25
commit
af17d6e0dc
@ -508,6 +508,21 @@ With NO-ABSOLUTE, don't complete absolute file names."
|
|||||||
(append (seq-take (nth ,index ,args) 2)
|
(append (seq-take (nth ,index ,args) 2)
|
||||||
(list (seq-difference ,evaled-vals ,present)))))))
|
(list (seq-difference ,evaled-vals ,present)))))))
|
||||||
|
|
||||||
|
(defun firejail--get-all-env-keys ()
|
||||||
|
"Return the name of every current environment variable."
|
||||||
|
(mapcar (lambda (elt)
|
||||||
|
(if-let ((sep (cl-position ?= elt)))
|
||||||
|
(substring elt 0 sep)
|
||||||
|
elt))
|
||||||
|
process-environment))
|
||||||
|
|
||||||
|
(defun firejail--complete-env (index args _directive)
|
||||||
|
"Complete the arg numbered INDEX in ARGS for an \"env\" directive."
|
||||||
|
(cl-destructuring-bind (start _end text) (nth index args)
|
||||||
|
(let ((sep-pos (or (cl-position ?= text) (length text))))
|
||||||
|
(when (<= (point) (+ start sep-pos))
|
||||||
|
(list start (+ start sep-pos) (firejail--get-all-env-keys))))))
|
||||||
|
|
||||||
(defconst firejail-profile--keyword-handlers
|
(defconst firejail-profile--keyword-handlers
|
||||||
(let ((ht (make-hash-table :test 'equal)))
|
(let ((ht (make-hash-table :test 'equal)))
|
||||||
(cl-flet* ((complete (args fun dirs)
|
(cl-flet* ((complete (args fun dirs)
|
||||||
@ -583,7 +598,8 @@ With NO-ABSOLUTE, don't complete absolute file names."
|
|||||||
(complete-all (firejail--complete-many-from-set
|
(complete-all (firejail--complete-many-from-set
|
||||||
'(mapcar 'number-to-string
|
'(mapcar 'number-to-string
|
||||||
(number-sequence 0 (firejail--get-num-cpus))))
|
(number-sequence 0 (firejail--get-num-cpus))))
|
||||||
"cpu"))
|
"cpu")
|
||||||
|
(complete 1 #'firejail--complete-env "env"))
|
||||||
ht)
|
ht)
|
||||||
"Hash table mapping firejail profile directives to their handler.
|
"Hash table mapping firejail profile directives to their handler.
|
||||||
Each handler is a function of three arguments. The first is the index of the
|
Each handler is a function of three arguments. The first is the index of the
|
||||||
|
Loading…
Reference in New Issue
Block a user