Mercurial > emacs
annotate lisp/pcmpl-linux.el @ 70539:b270f677c979
(battery-linux-proc-acpi): Also try `/proc/acpi/thermal_zone/THR2/temperature'.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Tue, 09 May 2006 22:43:35 +0000 |
parents | 3bd95f4f2941 |
children | b2e5081b9320 c5406394f567 |
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 |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64091
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2002, 2003, 2004, |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64762
diff
changeset
|
4 ;; 2005, 2006 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 | |
10 ;; the Free Software Foundation; either version 2, or (at your option) | |
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 |