Update copyright year to 2015
[emacs.git] / lisp / eshell / em-xtra.el
blobb2af974d9831773d1c0d0282973a1c36aa4c1d05
1 ;;; em-xtra.el --- extra alias functions -*- lexical-binding:t -*-
3 ;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
5 ;; Author: John Wiegley <johnw@gnu.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
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.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 ;;; Commentary:
24 ;;; Code:
26 (require 'esh-util)
27 (eval-when-compile
28 (require 'eshell)
29 (require 'pcomplete))
30 (require 'compile)
32 ;;;###autoload
33 (progn
34 (defgroup eshell-xtra nil
35 "This module defines some extra alias functions which are entirely
36 optional. They can be viewed as samples for how to write Eshell alias
37 functions, or as aliases which make some of Emacs's behavior more
38 naturally accessible within Emacs."
39 :tag "Extra alias functions"
40 :group 'eshell-module))
42 ;;; Functions:
44 (autoload 'eshell-parse-command "esh-cmd")
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
50 (eshell-parse-command "*expr" (eshell-flatten-list args)))
51 ;; to fool the byte-compiler...
52 (let ((func 'calc-eval))
53 (funcall func (eshell-flatten-and-stringify args)))))
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)))
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)))
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)))
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)))
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)))
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)))
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)))
90 (defalias 'eshell/ff 'find-name-dired)
91 (defalias 'eshell/gf 'find-grep-dired)
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)))
117 (pcomplete-opt "3456ABCDEHIKLMNOPRSTUVXabcdefgijklnoptuvwxyz"))))
118 (while (pcomplete-here
119 (pcomplete-dirs-or-entries "\\.[iCc]\\([Pp][Pp]\\)?\\'"))))
121 (defalias 'pcomplete/bcc 'pcomplete/bcc32)
123 (provide 'em-xtra)
125 ;; Local Variables:
126 ;; generated-autoload-file: "esh-groups.el"
127 ;; End:
129 ;;; em-xtra.el ends here