Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 82 lines (67 sloc) 2.965 kb
0eb812c @thierryvolpiatto * helm-man.el: new
thierryvolpiatto authored
1 ;;; helm-man.el --- Man and woman UI
2
3 ;; Copyright (C) 2012 Thierry Volpiatto <thierry.volpiatto@gmail.com>
4
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
9
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 ;;; Code:
19
20 (eval-when-compile (require 'cl))
21 (require 'helm)
22
7d8197a @thierryvolpiatto Fix warnings at compilation.
thierryvolpiatto authored
23 (declare-function woman-file-name-all-completions "woman.el" (topic))
24 (declare-function Man-getpage-in-background "man.el" (topic))
25
0eb812c @thierryvolpiatto * helm-man.el: new
thierryvolpiatto authored
26 (defvar helm-c-man-pages nil
27 "All man pages on system.
28 Will be calculated the first time you invoke helm with this
29 source.")
30
31 (defun helm-c-man-default-action (candidate)
32 "Default action for jumping to a woman or man page from helm."
a617ccf @thierryvolpiatto * helm-man.el (helm-c-man-default-action): Fix, use the car of candid…
thierryvolpiatto authored
33 (let ((wfiles (mapcar 'car (woman-file-name-all-completions candidate))))
0eb812c @thierryvolpiatto * helm-man.el: new
thierryvolpiatto authored
34 (condition-case err
35 (if (> (length wfiles) 1)
36 (woman-find-file
37 (helm-comp-read
38 "ManFile: " wfiles :must-match t))
39 (woman candidate))
40 ;; If woman is unable to format correctly
41 ;; use man instead.
42 (error (kill-buffer) ; Kill woman buffer.
8d3a8da @thierryvolpiatto * helm-man.el (helm-c-man-default-action): Don't let-bound Man-notify…
thierryvolpiatto authored
43 (Man-getpage-in-background candidate)))))
0eb812c @thierryvolpiatto * helm-man.el: new
thierryvolpiatto authored
44
45 (defvar helm-c-source-man-pages
46 `((name . "Manual Pages")
47 (candidates . (lambda ()
48 (if helm-c-man-pages
49 helm-c-man-pages
50 ;; XEmacs doesn't have a woman :)
51 (setq helm-c-man-pages
52 (ignore-errors
53 (require 'woman)
54 (woman-file-name "")
55 (sort (mapcar 'car woman-topic-all-completions)
56 'string-lessp))))))
57 (action ("Show with Woman" . helm-c-man-default-action))
58 ;; Woman does not work OS X
59 ;; http://xahlee.org/emacs/modernization_man_page.html
60 (action-transformer . (lambda (actions candidate)
61 (if (eq system-type 'darwin)
62 '(("Show with Man" . man))
63 actions)))
64 (requires-pattern . 2)))
65
66 ;;;###autoload
67 (defun helm-man-woman ()
68 "Preconfigured `helm' for Man and Woman pages."
69 (interactive)
70 (helm-other-buffer 'helm-c-source-man-pages "*Helm man woman*"))
71
72 (provide 'helm-man)
73
37b4201 @thierryvolpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
74 ;; Local Variables:
a7ee65b @thierryvolpiatto Disable compile warnings and add new keyword to helm.
thierryvolpiatto authored
75 ;; byte-compile-warnings: (not cl-functions obsolete)
37b4201 @thierryvolpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
76 ;; coding: utf-8
77 ;; indent-tabs-mode: nil
78 ;; byte-compile-dynamic: t
79 ;; End:
80
0eb812c @thierryvolpiatto * helm-man.el: new
thierryvolpiatto authored
81 ;;; helm-man.el ends here
Something went wrong with that request. Please try again.