1 ;;; pcmpl-linux.el --- functions for dealing with GNU/Linux completions
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
6 ;; This file is part of GNU Emacs.
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
13 ;; GNU Emacs is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
20 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
25 ;; These functions are for use with GNU/Linux. Since they depend on a
26 ;; certain knowledge of the layout of such systems, they probably
27 ;; won't work very well on other operating systems.
31 (provide 'pcmpl-linux
)
35 (defgroup pcmpl-linux nil
36 "Functions for dealing with GNU/Linux completions."
42 (defun pcomplete/kill
()
43 "Completion for GNU/Linux `kill', using /proc filesystem."
44 (if (pcomplete-match "^-\\(.*\\)" 0)
46 (pcomplete-uniqify-list
48 (pcomplete-process-result "kill" "-l")))
49 (pcomplete-match-string 1 0)))
50 (while (pcomplete-here
51 (if (file-directory-p "/proc")
52 (let ((default-directory "/proc/"))
53 (mapcar 'directory-file-name
54 (pcomplete-entries "[0-9]+/$"))))
58 (defun pcomplete/umount
()
59 "Completion for GNU/Linux `umount'."
60 (pcomplete-opt "hVafrnvt(pcmpl-linux-fs-types)")
61 (while (pcomplete-here (pcmpl-linux-mounted-directories)
65 (defun pcomplete/mount
()
66 "Completion for GNU/Linux `mount'."
67 (pcomplete-opt "hVanfFrsvwt(pcmpl-linux-fs-types)o?L?U?")
68 (while (pcomplete-here (pcomplete-entries) nil
'identity
)))
70 (defun pcmpl-linux-fs-types ()
71 "Return a list of available fs modules on GNU/Linux systems."
72 (let ((kernel-ver (pcomplete-process-result "uname" "-r")))
76 (substring fsobj
0 (- (length fsobj
) 2))))
77 (let ((default-directory
78 (concat "/lib/modules/" kernel-ver
"/fs/")))
79 (pcomplete-entries "\\.o$")))))
81 (defun pcmpl-linux-mounted-directories ()
82 "Return a list of mounted directory names."
84 (when (file-readable-p "/etc/mtab")
86 (insert-file-contents-literally "/etc/mtab")
88 (let* ((line (buffer-substring (point) (line-end-position)))
89 (args (split-string line
" ")))
90 (setq points
(cons (nth 1 args
) points
)))
92 (pcomplete-uniqify-list points
))))
94 (defun pcmpl-linux-mountable-directories ()
95 "Return a list of mountable directory names."
97 (when (file-readable-p "/etc/fstab")
99 (insert-file-contents-literally "/etc/fstab")
101 (let* ((line (buffer-substring (point) (line-end-position)))
102 (args (split-string line
"\\s-+")))
103 (setq points
(cons (nth 1 args
) points
)))
106 (pcomplete-uniqify-list points
)
107 (cons "swap" (pcmpl-linux-mounted-directories))))))
109 ;;; arch-tag: bb0961a6-a623-463d-92c6-497c317293b1
110 ;;; pcmpl-linux.el ends here