annotate lisp/pcmpl-linux.el @ 81497:6c3d4c79d6e1

*** empty log message ***
author Nick Roberts <nickrob@snap.net.nz>
date Wed, 20 Jun 2007 10:06:04 +0000
parents e3694f1cb928
children 9355f9b7bbff 95d0cdf160ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 34718
diff changeset
1 ;;; pcmpl-linux.el --- functions for dealing with GNU/Linux completions
29959
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
74442
b2e5081b9320 Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68651
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 74442
diff changeset
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
29959
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; This file is part of GNU Emacs.
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; any later version.
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; GNU Emacs is distributed in the hope that it will be useful,
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; GNU General Public License for more details.
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
20 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
21 ;; Boston, MA 02110-1301, USA.
29959
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;;; Commentary:
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;; These functions are for use with GNU/Linux. Since they depend on a
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;; certain knowledge of the layout of such systems, they probably
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;; won't work very well on other operating systems.
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;;; Code:
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 (provide 'pcmpl-linux)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 (require 'pcomplete)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 (defgroup pcmpl-linux nil
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 "Functions for dealing with GNU/Linux completions."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 :group 'pcomplete)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; Functions:
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;;;###autoload
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 (defun pcomplete/kill ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 "Completion for GNU/Linux `kill', using /proc filesystem."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 (if (pcomplete-match "^-\\(.*\\)" 0)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 (pcomplete-here
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 (pcomplete-uniqify-list
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 (split-string
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 (pcomplete-process-result "kill" "-l")))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 (pcomplete-match-string 1 0)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 (while (pcomplete-here
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 (if (file-directory-p "/proc")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 (let ((default-directory "/proc/"))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 (mapcar 'directory-file-name
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 (pcomplete-entries "[0-9]+/$"))))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 nil 'identity)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 ;;;###autoload
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 (defun pcomplete/umount ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 "Completion for GNU/Linux `umount'."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 (pcomplete-opt "hVafrnvt(pcmpl-linux-fs-types)")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 (while (pcomplete-here (pcmpl-linux-mounted-directories)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 nil 'identity)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 ;;;###autoload
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 (defun pcomplete/mount ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 "Completion for GNU/Linux `mount'."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 (pcomplete-opt "hVanfFrsvwt(pcmpl-linux-fs-types)o?L?U?")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 (while (pcomplete-here (pcomplete-entries) nil 'identity)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 (defun pcmpl-linux-fs-types ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 "Return a list of available fs modules on GNU/Linux systems."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 (let ((kernel-ver (pcomplete-process-result "uname" "-r")))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 (mapcar
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 (function
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 (lambda (fsobj)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 (substring fsobj 0 (- (length fsobj) 2))))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 (let ((default-directory
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 (concat "/lib/modules/" kernel-ver "/fs/")))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 (pcomplete-entries "\\.o$")))))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 (defun pcmpl-linux-mounted-directories ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 "Return a list of mounted directory names."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 (let (points)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 (when (file-readable-p "/etc/mtab")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 (with-temp-buffer
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 (insert-file-contents-literally "/etc/mtab")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 (while (not (eobp))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 (let* ((line (buffer-substring (point) (line-end-position)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 (args (split-string line " ")))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 (setq points (cons (nth 1 args) points)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 (forward-line)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 (pcomplete-uniqify-list points))))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 (defun pcmpl-linux-mountable-directories ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 "Return a list of mountable directory names."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 (let (points)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 (when (file-readable-p "/etc/fstab")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 (with-temp-buffer
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 (insert-file-contents-literally "/etc/fstab")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 (while (not (eobp))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 (let* ((line (buffer-substring (point) (line-end-position)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 (args (split-string line "\\s-+")))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 (setq points (cons (nth 1 args) points)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (forward-line)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 (pcomplete-pare-list
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 (pcomplete-uniqify-list points)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 (cons "swap" (pcmpl-linux-mounted-directories))))))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 38414
diff changeset
109 ;;; arch-tag: bb0961a6-a623-463d-92c6-497c317293b1
29959
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 ;;; pcmpl-linux.el ends here