summaryrefslogtreecommitdiff
path: root/lisp/pcmpl-linux.el
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2020-09-02 05:02:18 +0200
committerStefan Kangas <stefankangas@gmail.com>2020-09-02 12:53:02 +0200
commita50b8397f476b794f06aafb2b755e011566fbc2b (patch)
tree9da6f6bdf7d1f571a1ca9fc4670bcbce60a00a26 /lisp/pcmpl-linux.el
parent2e3ec402938be0d61c19831c12e69a10672dd681 (diff)
downloademacs-a50b8397f476b794f06aafb2b755e011566fbc2b.tar.gz
Use lexical-binding in pcmpl-linux.el and add tests
* lisp/pcmpl-linux.el: Use lexical-binding. (pcmpl-linux-fs-modules-path-format) (pcmpl-linux-mtab-file): New constants. (pcmpl-linux-fs-types, pcmpl-linux-mounted-directories): Use above new constants. * test/lisp/pcmpl-linux-resources/fs/ext4/.keep: * test/lisp/pcmpl-linux-resources/mtab: * test/lisp/pcmpl-linux-tests.el: New files.
Diffstat (limited to 'lisp/pcmpl-linux.el')
-rw-r--r--lisp/pcmpl-linux.el12
1 files changed, 8 insertions, 4 deletions
diff --git a/lisp/pcmpl-linux.el b/lisp/pcmpl-linux.el
index 6e036434ef2..df9d24507a0 100644
--- a/lisp/pcmpl-linux.el
+++ b/lisp/pcmpl-linux.el
@@ -1,4 +1,4 @@
-;;; pcmpl-linux.el --- functions for dealing with GNU/Linux completions
+;;; pcmpl-linux.el --- functions for dealing with GNU/Linux completions -*- lexical-binding: t -*-
;; Copyright (C) 1999-2020 Free Software Foundation, Inc.
@@ -65,18 +65,22 @@
(pcomplete-opt "hVanfFrsvwt(pcmpl-linux-fs-types)o?L?U?")
(while (pcomplete-here (pcomplete-entries) nil 'identity)))
+(defconst pcmpl-linux-fs-modules-path-format "/lib/modules/%s/kernel/fs/")
+
(defun pcmpl-linux-fs-types ()
"Return a list of available fs modules on GNU/Linux systems."
(let ((kernel-ver (pcomplete-process-result "uname" "-r")))
(directory-files
- (concat "/lib/modules/" kernel-ver "/kernel/fs/"))))
+ (format pcmpl-linux-fs-modules-path-format kernel-ver))))
+
+(defconst pcmpl-linux-mtab-file "/etc/mtab")
(defun pcmpl-linux-mounted-directories ()
"Return a list of mounted directory names."
(let (points)
- (when (file-readable-p "/etc/mtab")
+ (when (file-readable-p pcmpl-linux-mtab-file)
(with-temp-buffer
- (insert-file-contents-literally "/etc/mtab")
+ (insert-file-contents-literally pcmpl-linux-mtab-file)
(while (not (eobp))
(let* ((line (buffer-substring (point) (line-end-position)))
(args (split-string line " ")))