Document reserved keys
[emacs.git] / lisp / eshell / em-xtra.el
blobce73474fb7371dff3ff22a520d197f1ea1802561
1 ;;; em-xtra.el --- extra alias functions -*- lexical-binding:t -*-
3 ;; Copyright (C) 1999-2018 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 <https://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 ;; There are no items in this custom group, but eshell modules (ab)use
33 ;; custom groups.
34 ;;;###autoload
35 (progn
36 (defgroup eshell-xtra nil
37 "This module defines some extra alias functions which are entirely
38 optional. They can be viewed as samples for how to write Eshell alias
39 functions, or as aliases which make some of Emacs's behavior more
40 naturally accessible within Emacs."
41 :tag "Extra alias functions"
42 :group 'eshell-module))
44 ;;; Functions:
46 (autoload 'eshell-parse-command "esh-cmd")
48 (defun eshell/expr (&rest args)
49 "Implementation of expr, using the calc package."
50 (if (not (fboundp 'calc-eval))
51 (throw 'eshell-replace-command
52 (eshell-parse-command "*expr" (eshell-flatten-list args)))
53 ;; to fool the byte-compiler...
54 (let ((func 'calc-eval))
55 (funcall func (eshell-flatten-and-stringify args)))))
57 (defun eshell/substitute (&rest args)
58 "Easy front-end to `intersection', for comparing lists of strings."
59 (apply 'substitute (car args) (cadr args) :test 'equal
60 (cddr args)))
62 (defun eshell/count (&rest args)
63 "Easy front-end to `intersection', for comparing lists of strings."
64 (apply 'count (car args) (cadr args) :test 'equal
65 (cddr args)))
67 (defun eshell/mismatch (&rest args)
68 "Easy front-end to `intersection', for comparing lists of strings."
69 (apply 'mismatch (car args) (cadr args) :test 'equal
70 (cddr args)))
72 (defun eshell/union (&rest args)
73 "Easy front-end to `intersection', for comparing lists of strings."
74 (apply 'union (car args) (cadr args) :test 'equal
75 (cddr args)))
77 (defun eshell/intersection (&rest args)
78 "Easy front-end to `intersection', for comparing lists of strings."
79 (apply 'intersection (car args) (cadr args) :test 'equal
80 (cddr args)))
82 (defun eshell/set-difference (&rest args)
83 "Easy front-end to `intersection', for comparing lists of strings."
84 (apply 'set-difference (car args) (cadr args) :test 'equal
85 (cddr args)))
87 (defun eshell/set-exclusive-or (&rest args)
88 "Easy front-end to `intersection', for comparing lists of strings."
89 (apply 'set-exclusive-or (car args) (cadr args) :test 'equal
90 (cddr args)))
92 (defalias 'eshell/ff 'find-name-dired)
93 (defalias 'eshell/gf 'find-grep-dired)
95 (defun pcomplete/bcc32 ()
96 "Completion function for Borland's C++ compiler."
97 (let ((cur (pcomplete-arg 0)))
98 (cond
99 ((string-match "\\`-w\\([^;]+;\\)*\\([^;]*\\)\\'" cur)
100 (pcomplete-here
101 '("ali" "amb" "amp" "asc" "asm" "aus" "bbf" "bei" "big" "ccc"
102 "cln" "cod" "com" "cpt" "csu" "def" "dig" "dpu" "dsz" "dup"
103 "eas" "eff" "ext" "hch" "hid" "ias" "ibc" "ifr" "ill" "nil"
104 "lin" "lvc" "mcs" "mes" "mpc" "mpd" "msg" "nak" "ncf" "nci"
105 "ncl" "nfd" "ngu" "nin" "nma" "nmu" "nod" "nop" "npp" "nsf"
106 "nst" "ntd" "nto" "nvf" "obi" "obs" "ofp" "osh" "ovf" "par"
107 "pch" "pck" "pia" "pin" "pow" "prc" "pre" "pro" "rch" "ret"
108 "rng" "rpt" "rvl" "sig" "spa" "stl" "stu" "stv" "sus" "tai"
109 "tes" "thr" "ucp" "use" "voi" "zdi") (match-string 2 cur)))
110 ((string-match "\\`-[LIn]\\([^;]+;\\)*\\([^;]*\\)\\'" cur)
111 (pcomplete-here (pcomplete-dirs) (match-string 2 cur)))
112 ((string-match "\\`-[Ee]\\(.*\\)\\'" cur)
113 (pcomplete-here (pcomplete-dirs-or-entries "\\.[Ee][Xx][Ee]\\'")
114 (match-string 1 cur)))
115 ((string-match "\\`-o\\(.*\\)\\'" cur)
116 (pcomplete-here (pcomplete-dirs-or-entries "\\.[Oo][Bb][Jj]\\'")
117 (match-string 1 cur)))
119 (pcomplete-opt "3456ABCDEHIKLMNOPRSTUVXabcdefgijklnoptuvwxyz"))))
120 (while (pcomplete-here
121 (pcomplete-dirs-or-entries "\\.[iCc]\\([Pp][Pp]\\)?\\'"))))
123 (defalias 'pcomplete/bcc 'pcomplete/bcc32)
125 (provide 'em-xtra)
127 ;; Local Variables:
128 ;; generated-autoload-file: "esh-groups.el"
129 ;; End:
131 ;;; em-xtra.el ends here