em-xtra.el 4.4 KB

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