Mercurial > emacs
annotate lisp/pcmpl-linux.el @ 82888:35543e5c37a8
Change `fr-drdref' to `fr-dired-ref'.
author | Michaël Cadilhac <michael.cadilhac@lrde.org> |
---|---|
date | Sun, 26 Aug 2007 21:18:05 +0000 |
parents | 9355f9b7bbff |
children | 73661ddc7ac7 f55f9811f5d7 |
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 | 2 |
74442 | 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, |
75347 | 4 ;; 2005, 2006, 2007 Free Software Foundation, Inc. |
29959 | 5 |
6 ;; This file is part of GNU Emacs. | |
7 | |
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 | |
78236
9355f9b7bbff
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75347
diff
changeset
|
10 ;; the Free Software Foundation; either version 3, or (at your option) |
29959 | 11 ;; any later version. |
12 | |
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. | |
17 | |
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 | |
64091 | 20 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 ;; Boston, MA 02110-1301, USA. | |
29959 | 22 |
23 ;;; Commentary: | |
24 | |
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. | |
28 | |
29 ;;; Code: | |
30 | |
31 (provide 'pcmpl-linux) | |
32 | |
33 (require 'pcomplete) | |
34 | |
35 (defgroup pcmpl-linux nil | |
36 "Functions for dealing with GNU/Linux completions." | |
37 :group 'pcomplete) | |
38 | |
39 ;; Functions: | |
40 | |
41 ;;;###autoload | |
42 (defun pcomplete/kill () | |
43 "Completion for GNU/Linux `kill', using /proc filesystem." | |
44 (if (pcomplete-match "^-\\(.*\\)" 0) | |
45 (pcomplete-here | |
46 (pcomplete-uniqify-list | |
47 (split-string | |
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]+/$")))) | |
55 nil 'identity))) | |
56 | |
57 ;;;###autoload | |
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) | |
62 nil 'identity))) | |
63 | |
64 ;;;###autoload | |
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))) | |
69 | |
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"))) | |
73 (mapcar | |
74 (function | |
75 (lambda (fsobj) | |
76 (substring fsobj 0 (- (length fsobj) 2)))) | |
77 (let ((default-directory | |
78 (concat "/lib/modules/" kernel-ver "/fs/"))) | |
79 (pcomplete-entries "\\.o$"))))) | |
80 | |
81 (defun pcmpl-linux-mounted-directories () | |
82 "Return a list of mounted directory names." | |
83 (let (points) | |
84 (when (file-readable-p "/etc/mtab") | |
85 (with-temp-buffer | |
86 (insert-file-contents-literally "/etc/mtab") | |
87 (while (not (eobp)) | |
88 (let* ((line (buffer-substring (point) (line-end-position))) | |
89 (args (split-string line " "))) | |
90 (setq points (cons (nth 1 args) points))) | |
91 (forward-line))) | |
92 (pcomplete-uniqify-list points)))) | |
93 | |
94 (defun pcmpl-linux-mountable-directories () | |
95 "Return a list of mountable directory names." | |
96 (let (points) | |
97 (when (file-readable-p "/etc/fstab") | |
98 (with-temp-buffer | |
99 (insert-file-contents-literally "/etc/fstab") | |
100 (while (not (eobp)) | |
101 (let* ((line (buffer-substring (point) (line-end-position))) | |
102 (args (split-string line "\\s-+"))) | |
103 (setq points (cons (nth 1 args) points))) | |
104 (forward-line))) | |
105 (pcomplete-pare-list | |
106 (pcomplete-uniqify-list points) | |
107 (cons "swap" (pcmpl-linux-mounted-directories)))))) | |
108 | |
52401 | 109 ;;; arch-tag: bb0961a6-a623-463d-92c6-497c317293b1 |
29959 | 110 ;;; pcmpl-linux.el ends here |