2013-09-12 16:15:53 -04:00
|
|
|
;;; em-xtra.el --- extra alias functions -*- lexical-binding:t -*-
|
2000-06-23 05:24:10 +00:00
|
|
|
|
2020-01-01 00:19:43 +00:00
|
|
|
;; Copyright (C) 1999-2020 Free Software Foundation, Inc.
|
2000-06-23 05:24:10 +00:00
|
|
|
|
2000-10-16 12:27:09 +00:00
|
|
|
;; Author: John Wiegley <johnw@gnu.org>
|
|
|
|
|
2000-06-23 05:24:10 +00:00
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 03:36:21 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2000-06-23 05:24:10 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:36:21 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2000-06-23 05:24:10 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2000-06-23 05:24:10 +00:00
|
|
|
|
2007-12-05 07:03:18 +00:00
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;; Code:
|
2000-06-23 05:24:10 +00:00
|
|
|
|
Silence many eshell compilation warnings
* lisp/eshell/em-tramp.el: Adjust requires.
(eshell-parse-command): Autoload.
* lisp/eshell/em-xtra.el: Adjust requires.
(eshell-parse-command): Autoload.
* lisp/eshell/esh-ext.el: Adjust requires.
(eshell-parse-command, eshell-close-handles): Autoload.
* lisp/eshell/esh-io.el: Adjust requires.
(eshell-output-filter): Autoload.
* lisp/eshell/esh-util.el: No need to load tramp when compiling.
(tramp-file-name-structure, ange-ftp-ls, ange-ftp-file-modtime): Declare.
(eshell-parse-ange-ls): Require ange-ftp and tramp.
* lisp/eshell/em-alias.el, lisp/eshell/em-banner.el, lisp/eshell/em-basic.el:
* lisp/eshell/em-cmpl.el, lisp/eshell/em-glob.el, lisp/eshell/em-pred.el:
* lisp/eshell/em-prompt.el, lisp/eshell/em-rebind.el, lisp/eshell/em-smart.el:
* lisp/eshell/em-term.el, lisp/eshell/esh-arg.el, lisp/eshell/esh-mode.el:
* lisp/eshell/esh-opt.el, lisp/eshell/esh-proc.el:
* lisp/eshell/esh-var.el: Adjust requires.
* lisp/eshell/eshell.el: Do not require esh-util twice.
(eshell-add-input-to-history): Declare.
(eshell-command): Check history module is active before using it.
2013-05-22 21:57:27 -07:00
|
|
|
(require 'esh-util)
|
2007-12-05 07:03:18 +00:00
|
|
|
(eval-when-compile
|
2018-03-05 14:26:50 -05:00
|
|
|
(require 'eshell))
|
|
|
|
;; Strictly speaking, should only be needed at compile time.
|
|
|
|
;; Require at run-time too to silence compiler.
|
|
|
|
(require 'pcomplete)
|
2007-12-05 07:03:18 +00:00
|
|
|
(require 'compile)
|
2000-06-23 05:24:10 +00:00
|
|
|
|
2017-12-14 21:01:08 -05:00
|
|
|
;; There are no items in this custom group, but eshell modules (ab)use
|
|
|
|
;; custom groups.
|
2008-05-21 03:51:08 +00:00
|
|
|
;;;###autoload
|
Replace eshell-defgroup with plain defgroup
Borrowing a trick from vc-sccs.el, wrap the defgroup in a progn
so that the whole thing ends up in the generated autoload file,
esh-groups.el.
* em-alias.el, em-banner.el, em-basic.el, em-cmpl.el, em-dirs.el:
* em-glob.el, em-hist.el, em-ls.el, em-pred.el, em-prompt.el:
* em-rebind.el, em-script.el, em-smart.el, em-term.el, em-unix.el:
* em-xtra.el: Replace eshell-defgroup with (progn (defgroup.
* eshell.el (eshell-defgroup): Remove alias.
2012-06-27 00:08:06 -07:00
|
|
|
(progn
|
|
|
|
(defgroup eshell-xtra nil
|
2000-06-23 05:24:10 +00:00
|
|
|
"This module defines some extra alias functions which are entirely
|
|
|
|
optional. They can be viewed as samples for how to write Eshell alias
|
2012-02-28 00:17:21 -08:00
|
|
|
functions, or as aliases which make some of Emacs's behavior more
|
2000-06-23 05:24:10 +00:00
|
|
|
naturally accessible within Emacs."
|
|
|
|
:tag "Extra alias functions"
|
Replace eshell-defgroup with plain defgroup
Borrowing a trick from vc-sccs.el, wrap the defgroup in a progn
so that the whole thing ends up in the generated autoload file,
esh-groups.el.
* em-alias.el, em-banner.el, em-basic.el, em-cmpl.el, em-dirs.el:
* em-glob.el, em-hist.el, em-ls.el, em-pred.el, em-prompt.el:
* em-rebind.el, em-script.el, em-smart.el, em-term.el, em-unix.el:
* em-xtra.el: Replace eshell-defgroup with (progn (defgroup.
* eshell.el (eshell-defgroup): Remove alias.
2012-06-27 00:08:06 -07:00
|
|
|
:group 'eshell-module))
|
2000-06-23 05:24:10 +00:00
|
|
|
|
|
|
|
;;; Functions:
|
|
|
|
|
Silence many eshell compilation warnings
* lisp/eshell/em-tramp.el: Adjust requires.
(eshell-parse-command): Autoload.
* lisp/eshell/em-xtra.el: Adjust requires.
(eshell-parse-command): Autoload.
* lisp/eshell/esh-ext.el: Adjust requires.
(eshell-parse-command, eshell-close-handles): Autoload.
* lisp/eshell/esh-io.el: Adjust requires.
(eshell-output-filter): Autoload.
* lisp/eshell/esh-util.el: No need to load tramp when compiling.
(tramp-file-name-structure, ange-ftp-ls, ange-ftp-file-modtime): Declare.
(eshell-parse-ange-ls): Require ange-ftp and tramp.
* lisp/eshell/em-alias.el, lisp/eshell/em-banner.el, lisp/eshell/em-basic.el:
* lisp/eshell/em-cmpl.el, lisp/eshell/em-glob.el, lisp/eshell/em-pred.el:
* lisp/eshell/em-prompt.el, lisp/eshell/em-rebind.el, lisp/eshell/em-smart.el:
* lisp/eshell/em-term.el, lisp/eshell/esh-arg.el, lisp/eshell/esh-mode.el:
* lisp/eshell/esh-opt.el, lisp/eshell/esh-proc.el:
* lisp/eshell/esh-var.el: Adjust requires.
* lisp/eshell/eshell.el: Do not require esh-util twice.
(eshell-add-input-to-history): Declare.
(eshell-command): Check history module is active before using it.
2013-05-22 21:57:27 -07:00
|
|
|
(autoload 'eshell-parse-command "esh-cmd")
|
|
|
|
|
2000-06-23 05:24:10 +00:00
|
|
|
(defun eshell/expr (&rest args)
|
|
|
|
"Implementation of expr, using the calc package."
|
|
|
|
(if (not (fboundp 'calc-eval))
|
|
|
|
(throw 'eshell-replace-command
|
New function flatten-tree
Co-authored-by: Basil L. Contovounesios <contovob@tcd.ie>
* doc/lispref/lists.texi: Document `flatten-tree'.
* lisp/progmodes/js.el (js--maybe-join):
* lisp/printing.el (pr-switches):
* lisp/lpr.el (lpr-print-region):
* lisp/gnus/nnimap.el (nnimap-find-wanted-parts):
* lisp/gnus/message.el (message-talkative-question):
* lisp/gnus/gnus-sum.el (gnus-remove-thread)
(gnus-thread-highest-number, gnus-thread-latest-date):
* lisp/eshell/esh-util.el (eshell-flatten-and-stringify):
* lisp/eshell/esh-opt.el (eshell-eval-using-options):
* lisp/eshell/esh-ext.el (eshell-external-command):
* lisp/eshell/em-xtra.el (eshell/expr):
* lisp/eshell/em-unix.el (eshell/rm, eshell-mvcpln-template)
(eshell/cat, eshell/make, eshell-poor-mans-grep, eshell-grep)
(eshell/du, eshell/time, eshell/diff, eshell/locate):
* lisp/eshell/em-tramp.el (eshell/su, eshell/sudo):
* lisp/eshell/em-term.el (eshell-exec-visual):
* lisp/eshell/em-dirs.el (eshell-dirs-substitute-cd, eshell/cd):
* lisp/eshell/em-basic.el (eshell/printnl):
Use new flatten-tree.
* lisp/progmodes/js.el (js--flatten-list):
* lisp/lpr.el (lpr-flatten-list):
* lisp/gnus/message.el (message-flatten-list):
* lisp/eshell/esh-util.el (eshell-flatten-list):
Obsolete in favor of Emacs-wide `flatten-tree'.
* lisp/subr.el (flatten-list): Alias to `flatten-tree' for
discoverability.
* lisp/subr.el (flatten-tree): New defun.
* test/lisp/subr-tests.el (subr-tests-flatten-tree): New test.
2018-12-17 12:15:09 +01:00
|
|
|
(eshell-parse-command "*expr" (flatten-tree args)))
|
2000-06-23 05:24:10 +00:00
|
|
|
;; to fool the byte-compiler...
|
|
|
|
(let ((func 'calc-eval))
|
|
|
|
(funcall func (eshell-flatten-and-stringify args)))))
|
|
|
|
|
|
|
|
(defun eshell/substitute (&rest args)
|
|
|
|
"Easy front-end to `intersection', for comparing lists of strings."
|
|
|
|
(apply 'substitute (car args) (cadr args) :test 'equal
|
|
|
|
(cddr args)))
|
|
|
|
|
|
|
|
(defun eshell/count (&rest args)
|
|
|
|
"Easy front-end to `intersection', for comparing lists of strings."
|
|
|
|
(apply 'count (car args) (cadr args) :test 'equal
|
|
|
|
(cddr args)))
|
|
|
|
|
|
|
|
(defun eshell/mismatch (&rest args)
|
|
|
|
"Easy front-end to `intersection', for comparing lists of strings."
|
|
|
|
(apply 'mismatch (car args) (cadr args) :test 'equal
|
|
|
|
(cddr args)))
|
|
|
|
|
|
|
|
(defun eshell/union (&rest args)
|
|
|
|
"Easy front-end to `intersection', for comparing lists of strings."
|
|
|
|
(apply 'union (car args) (cadr args) :test 'equal
|
|
|
|
(cddr args)))
|
|
|
|
|
|
|
|
(defun eshell/intersection (&rest args)
|
|
|
|
"Easy front-end to `intersection', for comparing lists of strings."
|
|
|
|
(apply 'intersection (car args) (cadr args) :test 'equal
|
|
|
|
(cddr args)))
|
|
|
|
|
|
|
|
(defun eshell/set-difference (&rest args)
|
|
|
|
"Easy front-end to `intersection', for comparing lists of strings."
|
|
|
|
(apply 'set-difference (car args) (cadr args) :test 'equal
|
|
|
|
(cddr args)))
|
|
|
|
|
|
|
|
(defun eshell/set-exclusive-or (&rest args)
|
|
|
|
"Easy front-end to `intersection', for comparing lists of strings."
|
|
|
|
(apply 'set-exclusive-or (car args) (cadr args) :test 'equal
|
|
|
|
(cddr args)))
|
|
|
|
|
|
|
|
(defalias 'eshell/ff 'find-name-dired)
|
|
|
|
(defalias 'eshell/gf 'find-grep-dired)
|
|
|
|
|
2007-12-05 07:03:18 +00:00
|
|
|
(provide 'em-xtra)
|
2000-06-23 05:24:10 +00:00
|
|
|
|
2008-05-21 03:51:08 +00:00
|
|
|
;; Local Variables:
|
|
|
|
;; generated-autoload-file: "esh-groups.el"
|
|
|
|
;; End:
|
|
|
|
|
2000-06-23 05:24:10 +00:00
|
|
|
;;; em-xtra.el ends here
|