annotate lisp/pcmpl-linux.el @ 40987:d9b11436ac12

(Fminibuffer_complete_word): Reindent. (Fminibuffer_complete_and_exit): Likewise. (Fminibuffer_completion_help): Likewise. (Fminibuffer_message): Likewise.
author Pavel Janík <Pavel@Janik.cz>
date Tue, 13 Nov 2001 07:03:31 +0000
parents 67b464da13ec
children 695cf19ef79e d7ddb3e565de
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
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1999, 2000 Free Software Foundation
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; This file is part of GNU Emacs.
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; 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
9 ;; the Free Software Foundation; either version 2, or (at your option)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; any later version.
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is distributed in the hope that it will be useful,
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU General Public License for more details.
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; Boston, MA 02111-1307, USA.
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;;; Commentary:
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 ;; 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
25 ;; certain knowledge of the layout of such systems, they probably
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;; won't work very well on other operating systems.
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;;; Code:
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 (provide 'pcmpl-linux)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 (require 'pcomplete)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 (defgroup pcmpl-linux nil
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 "Functions for dealing with GNU/Linux completions."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 :group 'pcomplete)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;; Functions:
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;;;###autoload
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 (defun pcomplete/kill ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 "Completion for GNU/Linux `kill', using /proc filesystem."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 (if (pcomplete-match "^-\\(.*\\)" 0)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 (pcomplete-here
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 (pcomplete-uniqify-list
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 (split-string
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 (pcomplete-process-result "kill" "-l")))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 (pcomplete-match-string 1 0)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 (while (pcomplete-here
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 (if (file-directory-p "/proc")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 (let ((default-directory "/proc/"))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 (mapcar 'directory-file-name
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 (pcomplete-entries "[0-9]+/$"))))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 nil 'identity)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 ;;;###autoload
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 (defun pcomplete/umount ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 "Completion for GNU/Linux `umount'."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 (pcomplete-opt "hVafrnvt(pcmpl-linux-fs-types)")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 (while (pcomplete-here (pcmpl-linux-mounted-directories)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 nil 'identity)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 ;;;###autoload
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 (defun pcomplete/mount ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 "Completion for GNU/Linux `mount'."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 (pcomplete-opt "hVanfFrsvwt(pcmpl-linux-fs-types)o?L?U?")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 (while (pcomplete-here (pcomplete-entries) nil 'identity)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 (defun pcmpl-linux-fs-types ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 "Return a list of available fs modules on GNU/Linux systems."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 (let ((kernel-ver (pcomplete-process-result "uname" "-r")))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 (mapcar
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 (function
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 (lambda (fsobj)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 (substring fsobj 0 (- (length fsobj) 2))))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 (let ((default-directory
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 (concat "/lib/modules/" kernel-ver "/fs/")))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 (pcomplete-entries "\\.o$")))))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 (defun pcmpl-linux-mounted-directories ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 "Return a list of mounted directory names."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 (let (points)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 (when (file-readable-p "/etc/mtab")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 (with-temp-buffer
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 (insert-file-contents-literally "/etc/mtab")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 (while (not (eobp))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 (let* ((line (buffer-substring (point) (line-end-position)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 (args (split-string line " ")))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 (setq points (cons (nth 1 args) points)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 (forward-line)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 (pcomplete-uniqify-list points))))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 (defun pcmpl-linux-mountable-directories ()
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 "Return a list of mountable directory names."
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 (let (points)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 (when (file-readable-p "/etc/fstab")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 (with-temp-buffer
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 (insert-file-contents-literally "/etc/fstab")
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 (while (not (eobp))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 (let* ((line (buffer-substring (point) (line-end-position)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 (args (split-string line "\\s-+")))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 (setq points (cons (nth 1 args) points)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 (forward-line)))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (pcomplete-pare-list
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 (pcomplete-uniqify-list points)
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 (cons "swap" (pcmpl-linux-mounted-directories))))))
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107
d4e54e70814f *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 ;;; pcmpl-linux.el ends here