Merge from emacs-24; up to 2014-06-02T11:35:40Z!michael.albinus@gmx.de
[bpt/emacs.git] / lisp / eshell / em-xtra.el
CommitLineData
ae5e4c48 1;;; em-xtra.el --- extra alias functions -*- lexical-binding:t -*-
affbf647 2
ba318903 3;; Copyright (C) 1999-2014 Free Software Foundation, Inc.
affbf647 4
7de5b421
GM
5;; Author: John Wiegley <johnw@gnu.org>
6
affbf647
GM
7;; This file is part of GNU Emacs.
8
4ee57b2a 9;; GNU Emacs is free software: you can redistribute it and/or modify
affbf647 10;; it under the terms of the GNU General Public License as published by
4ee57b2a
GM
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
affbf647
GM
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
4ee57b2a 20;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
affbf647 21
dbba8a04
GM
22;;; Commentary:
23
24;;; Code:
affbf647 25
f87b1284 26(require 'esh-util)
dbba8a04
GM
27(eval-when-compile
28 (require 'eshell)
29 (require 'pcomplete))
30(require 'compile)
affbf647 31
3146b070 32;;;###autoload
35ff222c
GM
33(progn
34(defgroup eshell-xtra nil
affbf647
GM
35 "This module defines some extra alias functions which are entirely
36optional. They can be viewed as samples for how to write Eshell alias
44e97401 37functions, or as aliases which make some of Emacs's behavior more
affbf647
GM
38naturally accessible within Emacs."
39 :tag "Extra alias functions"
35ff222c 40 :group 'eshell-module))
affbf647 41
affbf647
GM
42;;; Functions:
43
f87b1284
GM
44(autoload 'eshell-parse-command "esh-cmd")
45
affbf647
GM
46(defun eshell/expr (&rest args)
47 "Implementation of expr, using the calc package."
48 (if (not (fboundp 'calc-eval))
49 (throw 'eshell-replace-command
ca7aae91 50 (eshell-parse-command "*expr" (eshell-flatten-list args)))
affbf647
GM
51 ;; to fool the byte-compiler...
52 (let ((func 'calc-eval))
53 (funcall func (eshell-flatten-and-stringify args)))))
54
55(defun eshell/substitute (&rest args)
56 "Easy front-end to `intersection', for comparing lists of strings."
57 (apply 'substitute (car args) (cadr args) :test 'equal
58 (cddr args)))
59
60(defun eshell/count (&rest args)
61 "Easy front-end to `intersection', for comparing lists of strings."
62 (apply 'count (car args) (cadr args) :test 'equal
63 (cddr args)))
64
65(defun eshell/mismatch (&rest args)
66 "Easy front-end to `intersection', for comparing lists of strings."
67 (apply 'mismatch (car args) (cadr args) :test 'equal
68 (cddr args)))
69
70(defun eshell/union (&rest args)
71 "Easy front-end to `intersection', for comparing lists of strings."
72 (apply 'union (car args) (cadr args) :test 'equal
73 (cddr args)))
74
75(defun eshell/intersection (&rest args)
76 "Easy front-end to `intersection', for comparing lists of strings."
77 (apply 'intersection (car args) (cadr args) :test 'equal
78 (cddr args)))
79
80(defun eshell/set-difference (&rest args)
81 "Easy front-end to `intersection', for comparing lists of strings."
82 (apply 'set-difference (car args) (cadr args) :test 'equal
83 (cddr args)))
84
85(defun eshell/set-exclusive-or (&rest args)
86 "Easy front-end to `intersection', for comparing lists of strings."
87 (apply 'set-exclusive-or (car args) (cadr args) :test 'equal
88 (cddr args)))
89
90(defalias 'eshell/ff 'find-name-dired)
91(defalias 'eshell/gf 'find-grep-dired)
92
93(defun pcomplete/bcc32 ()
94 "Completion function for Borland's C++ compiler."
95 (let ((cur (pcomplete-arg 0)))
96 (cond
97 ((string-match "\\`-w\\([^;]+;\\)*\\([^;]*\\)\\'" cur)
98 (pcomplete-here
99 '("ali" "amb" "amp" "asc" "asm" "aus" "bbf" "bei" "big" "ccc"
100 "cln" "cod" "com" "cpt" "csu" "def" "dig" "dpu" "dsz" "dup"
101 "eas" "eff" "ext" "hch" "hid" "ias" "ibc" "ifr" "ill" "nil"
102 "lin" "lvc" "mcs" "mes" "mpc" "mpd" "msg" "nak" "ncf" "nci"
103 "ncl" "nfd" "ngu" "nin" "nma" "nmu" "nod" "nop" "npp" "nsf"
104 "nst" "ntd" "nto" "nvf" "obi" "obs" "ofp" "osh" "ovf" "par"
105 "pch" "pck" "pia" "pin" "pow" "prc" "pre" "pro" "rch" "ret"
106 "rng" "rpt" "rvl" "sig" "spa" "stl" "stu" "stv" "sus" "tai"
107 "tes" "thr" "ucp" "use" "voi" "zdi") (match-string 2 cur)))
108 ((string-match "\\`-[LIn]\\([^;]+;\\)*\\([^;]*\\)\\'" cur)
109 (pcomplete-here (pcomplete-dirs) (match-string 2 cur)))
110 ((string-match "\\`-[Ee]\\(.*\\)\\'" cur)
111 (pcomplete-here (pcomplete-dirs-or-entries "\\.[Ee][Xx][Ee]\\'")
112 (match-string 1 cur)))
113 ((string-match "\\`-o\\(.*\\)\\'" cur)
114 (pcomplete-here (pcomplete-dirs-or-entries "\\.[Oo][Bb][Jj]\\'")
115 (match-string 1 cur)))
116 (t
117 (pcomplete-opt "3456ABCDEHIKLMNOPRSTUVXabcdefgijklnoptuvwxyz"))))
118 (while (pcomplete-here
119 (pcomplete-dirs-or-entries "\\.[iCc]\\([Pp][Pp]\\)?\\'"))))
120
121(defalias 'pcomplete/bcc 'pcomplete/bcc32)
122
dbba8a04 123(provide 'em-xtra)
affbf647 124
3146b070
GM
125;; Local Variables:
126;; generated-autoload-file: "esh-groups.el"
127;; End:
128
affbf647 129;;; em-xtra.el ends here