1 ;;; pcmpl-linux.el --- functions for dealing with GNU/Linux completions
3 ;; Copyright (C) 1999, 2000 Free Software Foundation
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
24 ;; These functions are for use with GNU/Linux. Since they depend on a
25 ;; certain knowledge of the layout of such systems, they probably
26 ;; won't work very well on other operating systems.
30 (provide 'pcmpl-linux
)
34 (defgroup pcmpl-linux nil
35 "Functions for dealing with GNU/Linux completions."
41 (defun pcomplete/kill
()
42 "Completion for GNU/Linux `kill', using /proc filesystem."
43 (if (pcomplete-match "^-\\(.*\\)" 0)
45 (pcomplete-uniqify-list
47 (pcomplete-process-result "kill" "-l")))
48 (pcomplete-match-string 1 0)))
49 (while (pcomplete-here
50 (if (file-directory-p "/proc")
51 (let ((default-directory "/proc/"))
52 (mapcar 'directory-file-name
53 (pcomplete-entries "[0-9]+/$"))))
57 (defun pcomplete/umount
()
58 "Completion for GNU/Linux `umount'."
59 (pcomplete-opt "hVafrnvt(pcmpl-linux-fs-types)")
60 (while (pcomplete-here (pcmpl-linux-mounted-directories)
64 (defun pcomplete/mount
()
65 "Completion for GNU/Linux `mount'."
66 (pcomplete-opt "hVanfFrsvwt(pcmpl-linux-fs-types)o?L?U?")
67 (while (pcomplete-here (pcomplete-entries) nil
'identity
)))
69 (defun pcmpl-linux-fs-types ()
70 "Return a list of available fs modules on GNU/Linux systems."
71 (let ((kernel-ver (pcomplete-process-result "uname" "-r")))
75 (substring fsobj
0 (- (length fsobj
) 2))))
76 (let ((default-directory
77 (concat "/lib/modules/" kernel-ver
"/fs/")))
78 (pcomplete-entries "\\.o$")))))
80 (defun pcmpl-linux-mounted-directories ()
81 "Return a list of mounted directory names."
83 (when (file-readable-p "/etc/mtab")
85 (insert-file-contents-literally "/etc/mtab")
87 (let* ((line (buffer-substring (point) (line-end-position)))
88 (args (split-string line
" ")))
89 (setq points
(cons (nth 1 args
) points
)))
91 (pcomplete-uniqify-list points
))))
93 (defun pcmpl-linux-mountable-directories ()
94 "Return a list of mountable directory names."
96 (when (file-readable-p "/etc/fstab")
98 (insert-file-contents-literally "/etc/fstab")
100 (let* ((line (buffer-substring (point) (line-end-position)))
101 (args (split-string line
"\\s-+")))
102 (setq points
(cons (nth 1 args
) points
)))
105 (pcomplete-uniqify-list points
)
106 (cons "swap" (pcmpl-linux-mounted-directories))))))
108 ;;; pcmpl-linux.el ends here