2013-09-12 16:15:53 -04:00
|
|
|
;;; esh-arg.el --- argument processing -*- lexical-binding:t -*-
|
2000-06-23 05:24:10 +00:00
|
|
|
|
2022-01-01 02:45:51 -05:00
|
|
|
;; Copyright (C) 1999-2022 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:04:00 +00:00
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; Parsing of arguments can be extended by adding functions to the
|
|
|
|
;; hook `eshell-parse-argument-hook'. For a good example of this, see
|
|
|
|
;; `eshell-parse-drive-letter', defined in eshell-dirs.el.
|
|
|
|
|
Eshell: Try to untangle the dependencies; move 'provide's to the end
* lisp/eshell/esh-arg.el: Move defsubst and vars before first use.
Don't require `esh-mode but esh-util instead.
* lisp/eshell/esh-cmd.el: Require esh-module and esh-io.
* lisp/eshell/esh-ext.el: Don't require esh-proc nor esh-cmd.
(eshell-external-command): Require esh-proc for
eshell-gather-process-output.
* lisp/eshell/esh-mode.el: Don't require esh-io nor esh-var, but
require esh-arg.
(eshell-directory-name): Move from eshell.el.
* lisp/eshell/esh-module.el: Don't require eshell.
* lisp/eshell/esh-opt.el: Don't require esh-ext at top-level.
(eshell--do-opts, eshell-show-usage): Require it here instead.
* lisp/eshell/esh-proc.el: Don't require esh-cmd, but require esh-io.
(eshell-reset-after-proc, eshell-record-process-object)
(eshell-gather-process-output, eshell-send-eof-to-process):
Require esh-mode and esh-var here.
* lisp/eshell/esh-var.el: Require esh-module, esh-arg, and esh-io.
* lisp/eshell/eshell.el: Require esh-module, esh-proc, esh-io, and esh-cmd.
But don't require esh-mode.
(eshell-directory-name): Move to esh-mode.
(eshell-return-exits-minibuffer): Don't bind 'return' and 'M-return'
since we already bind RET and M-RET.
2019-04-08 14:28:34 -04:00
|
|
|
;;; Code:
|
2000-06-23 05:24:10 +00:00
|
|
|
|
Eshell: Try to untangle the dependencies; move 'provide's to the end
* lisp/eshell/esh-arg.el: Move defsubst and vars before first use.
Don't require `esh-mode but esh-util instead.
* lisp/eshell/esh-cmd.el: Require esh-module and esh-io.
* lisp/eshell/esh-ext.el: Don't require esh-proc nor esh-cmd.
(eshell-external-command): Require esh-proc for
eshell-gather-process-output.
* lisp/eshell/esh-mode.el: Don't require esh-io nor esh-var, but
require esh-arg.
(eshell-directory-name): Move from eshell.el.
* lisp/eshell/esh-module.el: Don't require eshell.
* lisp/eshell/esh-opt.el: Don't require esh-ext at top-level.
(eshell--do-opts, eshell-show-usage): Require it here instead.
* lisp/eshell/esh-proc.el: Don't require esh-cmd, but require esh-io.
(eshell-reset-after-proc, eshell-record-process-object)
(eshell-gather-process-output, eshell-send-eof-to-process):
Require esh-mode and esh-var here.
* lisp/eshell/esh-var.el: Require esh-module, esh-arg, and esh-io.
* lisp/eshell/eshell.el: Require esh-module, esh-proc, esh-io, and esh-cmd.
But don't require esh-mode.
(eshell-directory-name): Move to esh-mode.
(eshell-return-exits-minibuffer): Don't bind 'return' and 'M-return'
since we already bind RET and M-RET.
2019-04-08 14:28:34 -04:00
|
|
|
(require 'esh-util)
|
2000-06-23 05:24:10 +00:00
|
|
|
|
2022-07-09 16:26:55 -07:00
|
|
|
(eval-when-compile
|
|
|
|
(require 'cl-lib))
|
|
|
|
|
2000-06-23 05:24:10 +00:00
|
|
|
(defgroup eshell-arg nil
|
|
|
|
"Argument parsing involves transforming the arguments passed on the
|
|
|
|
command line into equivalent Lisp forms that, when evaluated, will
|
|
|
|
yield the values intended."
|
|
|
|
:tag "Argument parsing"
|
|
|
|
:group 'eshell)
|
|
|
|
|
Eshell: Try to untangle the dependencies; move 'provide's to the end
* lisp/eshell/esh-arg.el: Move defsubst and vars before first use.
Don't require `esh-mode but esh-util instead.
* lisp/eshell/esh-cmd.el: Require esh-module and esh-io.
* lisp/eshell/esh-ext.el: Don't require esh-proc nor esh-cmd.
(eshell-external-command): Require esh-proc for
eshell-gather-process-output.
* lisp/eshell/esh-mode.el: Don't require esh-io nor esh-var, but
require esh-arg.
(eshell-directory-name): Move from eshell.el.
* lisp/eshell/esh-module.el: Don't require eshell.
* lisp/eshell/esh-opt.el: Don't require esh-ext at top-level.
(eshell--do-opts, eshell-show-usage): Require it here instead.
* lisp/eshell/esh-proc.el: Don't require esh-cmd, but require esh-io.
(eshell-reset-after-proc, eshell-record-process-object)
(eshell-gather-process-output, eshell-send-eof-to-process):
Require esh-mode and esh-var here.
* lisp/eshell/esh-var.el: Require esh-module, esh-arg, and esh-io.
* lisp/eshell/eshell.el: Require esh-module, esh-proc, esh-io, and esh-cmd.
But don't require esh-mode.
(eshell-directory-name): Move to esh-mode.
(eshell-return-exits-minibuffer): Don't bind 'return' and 'M-return'
since we already bind RET and M-RET.
2019-04-08 14:28:34 -04:00
|
|
|
;;; Internal Variables:
|
|
|
|
|
|
|
|
(defvar eshell-current-argument nil)
|
|
|
|
(defvar eshell-current-modifiers nil)
|
|
|
|
(defvar eshell-arg-listified nil)
|
|
|
|
(defvar eshell-nested-argument nil)
|
|
|
|
(defvar eshell-current-quoted nil)
|
|
|
|
(defvar eshell-inside-quote-regexp nil)
|
|
|
|
(defvar eshell-outside-quote-regexp nil)
|
|
|
|
|
|
|
|
;;; User Variables:
|
|
|
|
|
|
|
|
(defcustom eshell-arg-load-hook nil
|
|
|
|
"A hook that gets run when `eshell-arg' is loaded."
|
|
|
|
:version "24.1" ; removed eshell-arg-initialize
|
|
|
|
:type 'hook
|
|
|
|
:group 'eshell-arg)
|
|
|
|
|
|
|
|
(defcustom eshell-delimiter-argument-list '(?\; ?& ?\| ?\> ?\s ?\t ?\n)
|
|
|
|
"List of characters to recognize as argument separators."
|
|
|
|
:type '(repeat character)
|
|
|
|
:group 'eshell-arg)
|
|
|
|
|
|
|
|
(defcustom eshell-special-chars-inside-quoting '(?\\ ?\")
|
|
|
|
"Characters which are still special inside double quotes."
|
|
|
|
:type '(repeat character)
|
|
|
|
:group 'eshell-arg)
|
|
|
|
|
|
|
|
(defcustom eshell-special-chars-outside-quoting
|
|
|
|
(append eshell-delimiter-argument-list '(?# ?! ?\\ ?\" ?\'))
|
|
|
|
"Characters that require escaping outside of double quotes.
|
|
|
|
Without escaping them, they will introduce a change in the argument."
|
|
|
|
:type '(repeat character)
|
|
|
|
:group 'eshell-arg)
|
|
|
|
|
|
|
|
(defsubst eshell-arg-delimiter (&optional pos)
|
|
|
|
"Return non-nil if POS is an argument delimiter.
|
|
|
|
If POS is nil, the location of point is checked."
|
|
|
|
(let ((pos (or pos (point))))
|
|
|
|
(or (= pos (point-max))
|
|
|
|
(memq (char-after pos) eshell-delimiter-argument-list))))
|
|
|
|
|
2000-06-23 05:24:10 +00:00
|
|
|
(defcustom eshell-parse-argument-hook
|
|
|
|
(list
|
|
|
|
;; a term such as #<buffer NAME>, or #<process NAME> is a buffer
|
|
|
|
;; or process reference
|
|
|
|
'eshell-parse-special-reference
|
|
|
|
|
|
|
|
;; numbers convert to numbers if they stand alone
|
2020-11-16 14:43:55 +01:00
|
|
|
(lambda ()
|
|
|
|
(when (and (not eshell-current-argument)
|
|
|
|
(not eshell-current-quoted)
|
|
|
|
(looking-at eshell-number-regexp)
|
|
|
|
(eshell-arg-delimiter (match-end 0)))
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
(let ((str (match-string 0)))
|
|
|
|
(if (> (length str) 0)
|
|
|
|
(add-text-properties 0 (length str) '(number t) str))
|
|
|
|
str)))
|
2000-06-23 05:24:10 +00:00
|
|
|
|
|
|
|
;; parse any non-special characters, based on the current context
|
2020-11-16 14:43:55 +01:00
|
|
|
(lambda ()
|
|
|
|
(unless eshell-inside-quote-regexp
|
|
|
|
(setq eshell-inside-quote-regexp
|
|
|
|
(format "[^%s]+"
|
|
|
|
(apply 'string eshell-special-chars-inside-quoting))))
|
|
|
|
(unless eshell-outside-quote-regexp
|
|
|
|
(setq eshell-outside-quote-regexp
|
|
|
|
(format "[^%s]+"
|
|
|
|
(apply 'string eshell-special-chars-outside-quoting))))
|
|
|
|
(when (looking-at (if eshell-current-quoted
|
|
|
|
eshell-inside-quote-regexp
|
|
|
|
eshell-outside-quote-regexp))
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
(let ((str (match-string 0)))
|
|
|
|
(if str
|
|
|
|
(set-text-properties 0 (length str) nil str))
|
|
|
|
str)))
|
2000-06-23 05:24:10 +00:00
|
|
|
|
|
|
|
;; whitespace or a comment is an argument delimiter
|
2020-11-16 14:43:55 +01:00
|
|
|
(lambda ()
|
|
|
|
(let (comment-p)
|
|
|
|
(when (or (looking-at "[ \t]+")
|
|
|
|
(and (not eshell-current-argument)
|
|
|
|
(looking-at "#\\([^<'].*\\|$\\)")
|
|
|
|
(setq comment-p t)))
|
|
|
|
(if comment-p
|
|
|
|
(add-text-properties (match-beginning 0) (match-end 0)
|
|
|
|
'(comment t)))
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
(eshell-finish-arg))))
|
2000-06-23 05:24:10 +00:00
|
|
|
|
2015-04-08 22:31:51 -04:00
|
|
|
;; parse backslash and the character after
|
2000-06-23 05:24:10 +00:00
|
|
|
'eshell-parse-backslash
|
|
|
|
|
|
|
|
;; text beginning with ' is a literally quoted
|
|
|
|
'eshell-parse-literal-quote
|
|
|
|
|
|
|
|
;; text beginning with " is interpolably quoted
|
|
|
|
'eshell-parse-double-quote
|
|
|
|
|
|
|
|
;; argument delimiter
|
|
|
|
'eshell-parse-delimiter)
|
Typos, doc fixes, etc.
* eshell/esh-arg.el (eshell-quote-backslash): Fix typo in docstring.
(eshell-parse-argument-hook, eshell-special-chars-inside-quoting)
(eshell-arg-load-hook, eshell-special-chars-outside-quoting):
Remove spurious * in defcustom docstrings.
* textmodes/fill.el (fill-paragraph): Fix typo in docstring.
(fill-individual-varying-indent, colon-double-space, enable-kinsoku)
(adaptive-fill-mode, adaptive-fill-first-line-regexp)
(default-justification): Remove spurious * in defcustom docstrings.
* textmodes/rst.el (rst, rst-line-homogeneous-p, rst-mode-abbrev-table)
(rst-font-lock-keywords-function, rst-mode, rst-minor-mode)
(rst-compare-decorations, rst-default-indent, rst-update-section)
(rst-decoration-complete-p, rst-section-tree, rst-toc-insert-node)
(rst-toc-insert-find-delete-contents, rst-toc-count-lines)
(rst-toc-mode-goto-section, rst-faces, rst-level-face-base-color):
Fix typos in docstrings.
(rst-mode-lazy): Fix typo in docstring. Remove spurious *.
(rst-adjust, rst-line-homogeneous-p, rst-suggest-new-decoration)
(rst-get-decorations-around, rst-section-tree-point)
(rst-font-lock-adornment-point): Reflow docstrings.
(rst-get-decoration, rst-get-decoration-match, rst-adjust-decoration):
Doc fixes.
(rst-re-enumerations): Comment out.
2008-07-03 15:18:32 +00:00
|
|
|
"Define how to process Eshell command line arguments.
|
2000-06-23 05:24:10 +00:00
|
|
|
When each function on this hook is called, point will be at the
|
|
|
|
current position within the argument list. The function should either
|
|
|
|
return nil, meaning that it did no argument parsing, or it should
|
|
|
|
return the result of the parse as a sexp. It is also responsible for
|
|
|
|
moving the point forward to reflect the amount of input text that was
|
|
|
|
parsed.
|
|
|
|
|
2022-07-09 10:34:31 -07:00
|
|
|
If the hook determines that it has reached the end of an argument, it
|
|
|
|
should call `eshell-finish-arg' to complete processing of the current
|
|
|
|
argument and proceed to the next.
|
|
|
|
|
2000-06-23 05:24:10 +00:00
|
|
|
If no function handles the current character at point, it will be
|
|
|
|
treated as a literal character."
|
|
|
|
:type 'hook
|
|
|
|
:group 'eshell-arg)
|
|
|
|
|
2021-12-23 19:03:53 +01:00
|
|
|
(defvar-keymap eshell-arg-mode-map
|
|
|
|
"C-c M-b" #'eshell-insert-buffer-name)
|
2019-06-26 13:59:06 -05:00
|
|
|
|
2000-06-23 05:24:10 +00:00
|
|
|
;;; Functions:
|
|
|
|
|
2019-06-26 13:59:06 -05:00
|
|
|
(define-minor-mode eshell-arg-mode
|
|
|
|
"Minor mode for the arg eshell module.
|
|
|
|
|
|
|
|
\\{eshell-arg-mode-map}"
|
|
|
|
:keymap eshell-arg-mode-map)
|
|
|
|
|
2019-04-09 14:57:29 -04:00
|
|
|
(defun eshell-arg-initialize () ;Called from `eshell-mode' via intern-soft!
|
2000-06-23 05:24:10 +00:00
|
|
|
"Initialize the argument parsing code."
|
2019-06-26 13:59:06 -05:00
|
|
|
(eshell-arg-mode)
|
2020-12-04 10:55:50 +01:00
|
|
|
(setq-local eshell-inside-quote-regexp nil)
|
|
|
|
(setq-local eshell-outside-quote-regexp nil))
|
2000-06-23 05:24:10 +00:00
|
|
|
|
|
|
|
(defun eshell-insert-buffer-name (buffer-name)
|
|
|
|
"Insert BUFFER-NAME into the current buffer at point."
|
|
|
|
(interactive "BName of buffer: ")
|
|
|
|
(insert-and-inherit "#<buffer " buffer-name ">"))
|
|
|
|
|
|
|
|
(defsubst eshell-escape-arg (string)
|
|
|
|
"Return STRING with the `escaped' property on it."
|
|
|
|
(if (stringp string)
|
|
|
|
(add-text-properties 0 (length string) '(escaped t) string))
|
|
|
|
string)
|
|
|
|
|
2022-05-02 16:56:49 -07:00
|
|
|
(defun eshell-concat (quoted &rest rest)
|
|
|
|
"Concatenate all the arguments in REST and return the result.
|
|
|
|
If QUOTED is nil, the resulting value(s) may be converted to
|
|
|
|
numbers (see `eshell-concat-1').
|
|
|
|
|
|
|
|
If each argument in REST is a non-list value, the result will be
|
2022-08-03 13:13:57 +02:00
|
|
|
a single value, as if (mapconcat #\\='eshell-stringify REST) had been
|
2022-05-02 16:56:49 -07:00
|
|
|
called, possibly converted to a number.
|
|
|
|
|
|
|
|
If there is at least one (non-nil) list argument, the result will
|
|
|
|
be a list, with \"adjacent\" elements of consecutive arguments
|
|
|
|
concatenated as strings (again, possibly converted to numbers).
|
|
|
|
For example, concatenating \"a\", (\"b\"), and (\"c\" \"d\")
|
|
|
|
would produce (\"abc\" \"d\")."
|
|
|
|
(let (result)
|
|
|
|
(dolist (i rest result)
|
|
|
|
(when i
|
|
|
|
(cond
|
|
|
|
((null result)
|
|
|
|
(setq result i))
|
|
|
|
((listp result)
|
|
|
|
(let (curr-head curr-tail)
|
|
|
|
(if (listp i)
|
|
|
|
(setq curr-head (car i)
|
|
|
|
curr-tail (cdr i))
|
|
|
|
(setq curr-head i
|
|
|
|
curr-tail nil))
|
|
|
|
(setq result
|
|
|
|
(append
|
|
|
|
(butlast result 1)
|
|
|
|
(list (eshell-concat-1 quoted (car (last result))
|
|
|
|
curr-head))
|
|
|
|
curr-tail))))
|
|
|
|
((listp i)
|
|
|
|
(setq result
|
|
|
|
(cons (eshell-concat-1 quoted result (car i))
|
|
|
|
(cdr i))))
|
|
|
|
(t
|
|
|
|
(setq result (eshell-concat-1 quoted result i))))))))
|
|
|
|
|
|
|
|
(defun eshell-concat-1 (quoted first second)
|
|
|
|
"Concatenate FIRST and SECOND.
|
|
|
|
If QUOTED is nil and either FIRST or SECOND are numbers, try to
|
|
|
|
convert the result to a number as well."
|
|
|
|
(let ((result (concat (eshell-stringify first) (eshell-stringify second))))
|
|
|
|
(if (and (not quoted)
|
|
|
|
(or (numberp first) (numberp second)))
|
|
|
|
(eshell-convert-to-number result)
|
|
|
|
result)))
|
|
|
|
|
2000-06-23 05:24:10 +00:00
|
|
|
(defun eshell-resolve-current-argument ()
|
|
|
|
"If there are pending modifications to be made, make them now."
|
|
|
|
(when eshell-current-argument
|
|
|
|
(when eshell-arg-listified
|
2022-05-02 16:56:49 -07:00
|
|
|
(setq eshell-current-argument
|
|
|
|
(append (list 'eshell-concat eshell-current-quoted)
|
|
|
|
eshell-current-argument))
|
2000-06-23 05:24:10 +00:00
|
|
|
(setq eshell-arg-listified nil))
|
|
|
|
(while eshell-current-modifiers
|
|
|
|
(setq eshell-current-argument
|
|
|
|
(list (car eshell-current-modifiers) eshell-current-argument)
|
|
|
|
eshell-current-modifiers (cdr eshell-current-modifiers))))
|
|
|
|
(setq eshell-current-modifiers nil))
|
|
|
|
|
2022-07-09 16:26:55 -07:00
|
|
|
(defun eshell-finish-arg (&rest arguments)
|
|
|
|
"Finish the current argument being processed.
|
|
|
|
If any ARGUMENTS are specified, they will be added to the final
|
|
|
|
argument list in place of the value of the current argument."
|
|
|
|
(when arguments
|
|
|
|
(if (= (length arguments) 1)
|
|
|
|
(setq eshell-current-argument (car arguments))
|
|
|
|
(cl-assert (and (not eshell-arg-listified)
|
|
|
|
(not eshell-current-modifiers)))
|
|
|
|
(setq eshell-current-argument (cons 'eshell-flatten-args arguments))))
|
2000-06-23 05:24:10 +00:00
|
|
|
(throw 'eshell-arg-done t))
|
|
|
|
|
2012-01-28 21:58:46 +08:00
|
|
|
(defun eshell-quote-argument (string)
|
|
|
|
"Return STRING with magic characters quoted.
|
|
|
|
Magic characters are those in `eshell-special-chars-outside-quoting'."
|
|
|
|
(let ((index 0))
|
|
|
|
(mapconcat (lambda (c)
|
|
|
|
(prog1
|
|
|
|
(or (eshell-quote-backslash string index)
|
|
|
|
(char-to-string c))
|
|
|
|
(setq index (1+ index))))
|
|
|
|
string
|
|
|
|
"")))
|
|
|
|
|
2000-06-23 05:24:10 +00:00
|
|
|
;; Argument parsing
|
|
|
|
|
|
|
|
(defun eshell-parse-arguments (beg end)
|
|
|
|
"Parse all of the arguments at point from BEG to END.
|
|
|
|
Returns the list of arguments in their raw form.
|
|
|
|
Point is left at the end of the arguments."
|
|
|
|
(save-excursion
|
|
|
|
(save-restriction
|
|
|
|
(goto-char beg)
|
|
|
|
(narrow-to-region beg end)
|
|
|
|
(let ((inhibit-point-motion-hooks t)
|
|
|
|
(args (list t))
|
|
|
|
delim)
|
2010-11-23 12:36:15 -05:00
|
|
|
(with-silent-modifications
|
|
|
|
(remove-text-properties (point-min) (point-max)
|
|
|
|
'(arg-begin nil arg-end nil))
|
|
|
|
(if (setq
|
|
|
|
delim
|
|
|
|
(catch 'eshell-incomplete
|
|
|
|
(while (not (eobp))
|
|
|
|
(let* ((here (point))
|
|
|
|
(arg (eshell-parse-argument)))
|
|
|
|
(if (= (point) here)
|
Prefer directed to neutral quotes
Prefer directed to neutral quotes in docstings and diagnostics.
In docstrings, escape apostrophes that would otherwise be translated
to curved quotes using the newer, simpler rules.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-lang.el (math-read-giac-subscr)
(math-read-math-subscr):
* lisp/calc/calc-misc.el (report-calc-bug):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/dabbrev.el (dabbrev-expand):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/elint.el (elint-get-top-forms):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emulation/viper-cmd.el (viper-toggle-search-style):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-arg.el (eshell-parse-arguments):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/files-x.el (modify-file-local-variable):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer)
(filesets-update-pre010505):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/gnus/auth-source.el (auth-source-netrc-parse-entries):
* lisp/gnus/gnus-agent.el (gnus-agent-check-overview-buffer)
(gnus-agent-fetch-headers):
* lisp/gnus/gnus-int.el (gnus-start-news-server):
* lisp/gnus/gnus-registry.el:
(gnus-registry--split-fancy-with-parent-internal):
* lisp/gnus/gnus-score.el (gnus-summary-increase-score):
* lisp/gnus/gnus-start.el (gnus-convert-old-newsrc):
* lisp/gnus/gnus-topic.el (gnus-topic-rename):
* lisp/gnus/legacy-gnus-agent.el (gnus-agent-unlist-expire-days):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/gnus/spam.el (spam-check-blackholes):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/tramp-cache.el:
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-bibtex.el (org-bibtex-fields):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/play/dunnet.el (dun-score, dun-help, dun-endgame-question)
(dun-rooms, dun-endgame-questions):
* lisp/progmodes/ada-mode.el (ada-goto-matching-start):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/antlr-mode.el (antlr-options-alists):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/server.el (server-get-auth-key):
* lisp/subr.el (version-to-list):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/vc/ediff-diff.el (ediff-same-contents):
* lisp/vc/vc-cvs.el (vc-cvs-mode-line-string):
* test/automated/tramp-tests.el (tramp-test33-asynchronous-requests):
Use directed rather than neutral quotes in diagnostics.
2015-08-24 23:39:33 -07:00
|
|
|
(error "Failed to parse argument `%s'"
|
2010-11-23 12:36:15 -05:00
|
|
|
(buffer-substring here (point-max))))
|
2022-07-09 16:26:55 -07:00
|
|
|
(when arg
|
|
|
|
(nconc args
|
|
|
|
(if (eq (car-safe arg) 'eshell-flatten-args)
|
|
|
|
(cdr arg)
|
|
|
|
(list arg))))))))
|
2010-11-23 12:36:15 -05:00
|
|
|
(throw 'eshell-incomplete (if (listp delim)
|
|
|
|
delim
|
|
|
|
(list delim (point) (cdr args)))))
|
|
|
|
(cdr args))))))
|
2000-06-23 05:24:10 +00:00
|
|
|
|
|
|
|
(defun eshell-parse-argument ()
|
|
|
|
"Get the next argument. Leave point after it."
|
|
|
|
(let* ((outer (null eshell-nested-argument))
|
|
|
|
(arg-begin (and outer (point)))
|
|
|
|
(eshell-nested-argument t)
|
|
|
|
eshell-current-argument
|
|
|
|
eshell-current-modifiers
|
|
|
|
eshell-arg-listified)
|
|
|
|
(catch 'eshell-arg-done
|
|
|
|
(while (not (eobp))
|
|
|
|
(let ((result
|
|
|
|
(or (run-hook-with-args-until-success
|
|
|
|
'eshell-parse-argument-hook)
|
|
|
|
(prog1
|
|
|
|
(char-to-string (char-after))
|
|
|
|
(forward-char)))))
|
|
|
|
(if (not eshell-current-argument)
|
|
|
|
(setq eshell-current-argument result)
|
|
|
|
(unless eshell-arg-listified
|
|
|
|
(setq eshell-current-argument
|
|
|
|
(list eshell-current-argument)
|
|
|
|
eshell-arg-listified t))
|
|
|
|
(nconc eshell-current-argument (list result))))))
|
|
|
|
(when (and outer eshell-current-argument)
|
|
|
|
(add-text-properties arg-begin (1+ arg-begin)
|
|
|
|
'(arg-begin t rear-nonsticky
|
|
|
|
(arg-begin arg-end)))
|
|
|
|
(add-text-properties (1- (point)) (point)
|
|
|
|
'(arg-end t rear-nonsticky
|
|
|
|
(arg-end arg-begin))))
|
|
|
|
(eshell-resolve-current-argument)
|
|
|
|
eshell-current-argument))
|
|
|
|
|
Cleanup Eshell to rely less on dynamic scoping.
* lisp/eshell/esh-opt.el (eshell-eval-using-options): Don't bind usage-msg,
last-value, and ext-command here. Bind `args' closer to `body'.
(temp-args, last-value, usage-msg, ext-command, args): Don't defvar.
(eshell--args): Declare new dynamic var.
(eshell-do-opt): Add argument `args'. Bind our own usage-msg,
last-value, and ext-command. Pass `args' to `body'.
(eshell-process-args): Bind eshell--args.
(eshell-set-option): Use eshell--args.
* lisp/eshell/eshell.el (eshell): Use derived-mode-p.
* lisp/eshell/esh-var.el (eshell-parse-variable): Use backquote.
(eshell-parse-variable-ref): Remove unused vars `end' and `err'.
(eshell-glob-function): Declare.
* lisp/eshell/esh-util.el: Require cl-lib.
(eshell-read-hosts-file): Avoid add-to-list.
* lisp/eshell/esh-cmd.el (eshell-parse-lisp-argument): Remove unused var
`err'.
* lisp/eshell/em-unix.el (compilation-scroll-output, locate-history-list):
Declare.
(eshell/diff): Remove unused var `err'.
* lisp/eshell/em-rebind.el (eshell-delete-backward-char): Remove unused arg
`killflag'.
* lisp/eshell/em-pred.el (eshell-parse-modifiers): Remove unused var `err'.
* lisp/eshell/em-ls.el (eshell-ls-highlight-alist): Move defvars before
first use.
* lisp/eshell/em-glob.el (eshell-glob-matches, message-shown):
Move declaration before first use.
* lisp/eshell/em-alias.el (eshell-maybe-replace-by-alias): Use backquotes.
* autorevert.el (auto-revert-notify-handler): Use `cl-dolist' since we
rely on cl-return.
2013-09-12 01:20:07 -04:00
|
|
|
(defsubst eshell-operator (&rest _args)
|
2000-06-23 05:24:10 +00:00
|
|
|
"A stub function that generates an error if a floating operator is found."
|
|
|
|
(error "Unhandled operator in input text"))
|
|
|
|
|
|
|
|
(defsubst eshell-looking-at-backslash-return (pos)
|
|
|
|
"Test whether a backslash-return sequence occurs at POS."
|
|
|
|
(and (eq (char-after pos) ?\\)
|
|
|
|
(or (= (1+ pos) (point-max))
|
|
|
|
(and (eq (char-after (1+ pos)) ?\n)
|
|
|
|
(= (+ pos 2) (point-max))))))
|
|
|
|
|
|
|
|
(defun eshell-quote-backslash (string &optional index)
|
Typos, doc fixes, etc.
* eshell/esh-arg.el (eshell-quote-backslash): Fix typo in docstring.
(eshell-parse-argument-hook, eshell-special-chars-inside-quoting)
(eshell-arg-load-hook, eshell-special-chars-outside-quoting):
Remove spurious * in defcustom docstrings.
* textmodes/fill.el (fill-paragraph): Fix typo in docstring.
(fill-individual-varying-indent, colon-double-space, enable-kinsoku)
(adaptive-fill-mode, adaptive-fill-first-line-regexp)
(default-justification): Remove spurious * in defcustom docstrings.
* textmodes/rst.el (rst, rst-line-homogeneous-p, rst-mode-abbrev-table)
(rst-font-lock-keywords-function, rst-mode, rst-minor-mode)
(rst-compare-decorations, rst-default-indent, rst-update-section)
(rst-decoration-complete-p, rst-section-tree, rst-toc-insert-node)
(rst-toc-insert-find-delete-contents, rst-toc-count-lines)
(rst-toc-mode-goto-section, rst-faces, rst-level-face-base-color):
Fix typos in docstrings.
(rst-mode-lazy): Fix typo in docstring. Remove spurious *.
(rst-adjust, rst-line-homogeneous-p, rst-suggest-new-decoration)
(rst-get-decorations-around, rst-section-tree-point)
(rst-font-lock-adornment-point): Reflow docstrings.
(rst-get-decoration, rst-get-decoration-match, rst-adjust-decoration):
Doc fixes.
(rst-re-enumerations): Comment out.
2008-07-03 15:18:32 +00:00
|
|
|
"Intelligently backslash the character occurring in STRING at INDEX.
|
2000-06-23 05:24:10 +00:00
|
|
|
If the character is itself a backslash, it needs no escaping."
|
|
|
|
(let ((char (aref string index)))
|
2019-10-18 23:26:46 +02:00
|
|
|
(if (eq char ?\\)
|
2000-06-23 05:24:10 +00:00
|
|
|
(char-to-string char)
|
|
|
|
(if (memq char eshell-special-chars-outside-quoting)
|
|
|
|
(string ?\\ char)))))
|
|
|
|
|
|
|
|
(defun eshell-parse-backslash ()
|
2015-04-08 22:31:51 -04:00
|
|
|
"Parse a single backslash (\\) character and the character after.
|
|
|
|
If the character after the backslash is special, always ignore
|
|
|
|
the backslash and return the escaped character.
|
|
|
|
|
|
|
|
Otherwise, if the backslash is not in quoted string, the
|
|
|
|
backslash is ignored and the character after is returned. If the
|
|
|
|
backslash is in a quoted string, the backslash and the character
|
|
|
|
after are both returned."
|
2000-06-23 05:24:10 +00:00
|
|
|
(when (eq (char-after) ?\\)
|
2015-04-08 22:31:51 -04:00
|
|
|
(when (eshell-looking-at-backslash-return (point))
|
|
|
|
(throw 'eshell-incomplete ?\\))
|
|
|
|
(forward-char 2) ; Move one char past the backslash.
|
|
|
|
;; If the char is in a quote, backslash only has special meaning
|
|
|
|
;; if it is escaping a special char.
|
|
|
|
(if eshell-current-quoted
|
|
|
|
(if (memq (char-before) eshell-special-chars-inside-quoting)
|
|
|
|
(list 'eshell-escape-arg (char-to-string (char-before)))
|
|
|
|
(concat "\\" (char-to-string (char-before))))
|
|
|
|
(if (memq (char-before) eshell-special-chars-outside-quoting)
|
|
|
|
(list 'eshell-escape-arg (char-to-string (char-before)))
|
|
|
|
(char-to-string (char-before))))))
|
2000-06-23 05:24:10 +00:00
|
|
|
|
|
|
|
(defun eshell-parse-literal-quote ()
|
|
|
|
"Parse a literally quoted string. Nothing has special meaning!"
|
|
|
|
(if (eq (char-after) ?\')
|
|
|
|
(let ((end (eshell-find-delimiter ?\' ?\')))
|
|
|
|
(if (not end)
|
|
|
|
(throw 'eshell-incomplete ?\')
|
|
|
|
(let ((string (buffer-substring-no-properties (1+ (point)) end)))
|
|
|
|
(goto-char (1+ end))
|
|
|
|
(while (string-match "''" string)
|
|
|
|
(setq string (replace-match "'" t t string)))
|
|
|
|
(list 'eshell-escape-arg string))))))
|
|
|
|
|
|
|
|
(defun eshell-parse-double-quote ()
|
|
|
|
"Parse a double quoted string, which allows for variable interpolation."
|
|
|
|
(when (eq (char-after) ?\")
|
|
|
|
(let* ((end (eshell-find-delimiter ?\" ?\" nil nil t))
|
|
|
|
(eshell-current-quoted t))
|
|
|
|
(if (not end)
|
|
|
|
(throw 'eshell-incomplete ?\")
|
|
|
|
(prog1
|
|
|
|
(save-restriction
|
2000-10-13 09:02:39 +00:00
|
|
|
(forward-char)
|
2000-06-23 05:24:10 +00:00
|
|
|
(narrow-to-region (point) end)
|
2005-08-26 22:35:48 +00:00
|
|
|
(let ((arg (eshell-parse-argument)))
|
|
|
|
(if (eq arg nil)
|
|
|
|
""
|
|
|
|
(list 'eshell-escape-arg arg))))
|
2000-06-23 05:24:10 +00:00
|
|
|
(goto-char (1+ end)))))))
|
|
|
|
|
2022-03-03 09:37:25 -08:00
|
|
|
(defun eshell-unescape-inner-double-quote (bound)
|
|
|
|
"Unescape escaped characters inside a double-quoted string.
|
2022-02-27 21:04:30 -08:00
|
|
|
The string to parse starts at point and ends at BOUND.
|
|
|
|
|
|
|
|
If Eshell is currently parsing a quoted string and there are any
|
|
|
|
backslash-escaped characters, this will return the unescaped
|
|
|
|
string, updating point to BOUND. Otherwise, this returns nil and
|
|
|
|
leaves point where it was."
|
|
|
|
(when eshell-current-quoted
|
|
|
|
(let (strings
|
|
|
|
(start (point))
|
|
|
|
(special-char
|
|
|
|
(rx-to-string
|
|
|
|
`(seq "\\" (group (any ,@eshell-special-chars-inside-quoting))))))
|
|
|
|
(while (re-search-forward special-char bound t)
|
|
|
|
(push (concat (buffer-substring start (match-beginning 0))
|
|
|
|
(match-string 1))
|
|
|
|
strings)
|
|
|
|
(setq start (match-end 0)))
|
|
|
|
(when strings
|
|
|
|
(push (buffer-substring start bound) strings)
|
|
|
|
(goto-char bound)
|
|
|
|
(apply #'concat (nreverse strings))))))
|
|
|
|
|
2000-06-23 05:24:10 +00:00
|
|
|
(defun eshell-parse-special-reference ()
|
Prefer directed to neutral quotes
Prefer directed to neutral quotes in docstings and diagnostics.
In docstrings, escape apostrophes that would otherwise be translated
to curved quotes using the newer, simpler rules.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-lang.el (math-read-giac-subscr)
(math-read-math-subscr):
* lisp/calc/calc-misc.el (report-calc-bug):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/dabbrev.el (dabbrev-expand):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/elint.el (elint-get-top-forms):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emulation/viper-cmd.el (viper-toggle-search-style):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-arg.el (eshell-parse-arguments):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/files-x.el (modify-file-local-variable):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer)
(filesets-update-pre010505):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/gnus/auth-source.el (auth-source-netrc-parse-entries):
* lisp/gnus/gnus-agent.el (gnus-agent-check-overview-buffer)
(gnus-agent-fetch-headers):
* lisp/gnus/gnus-int.el (gnus-start-news-server):
* lisp/gnus/gnus-registry.el:
(gnus-registry--split-fancy-with-parent-internal):
* lisp/gnus/gnus-score.el (gnus-summary-increase-score):
* lisp/gnus/gnus-start.el (gnus-convert-old-newsrc):
* lisp/gnus/gnus-topic.el (gnus-topic-rename):
* lisp/gnus/legacy-gnus-agent.el (gnus-agent-unlist-expire-days):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/gnus/spam.el (spam-check-blackholes):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/tramp-cache.el:
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-bibtex.el (org-bibtex-fields):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/play/dunnet.el (dun-score, dun-help, dun-endgame-question)
(dun-rooms, dun-endgame-questions):
* lisp/progmodes/ada-mode.el (ada-goto-matching-start):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/antlr-mode.el (antlr-options-alists):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/server.el (server-get-auth-key):
* lisp/subr.el (version-to-list):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/vc/ediff-diff.el (ediff-same-contents):
* lisp/vc/vc-cvs.el (vc-cvs-mode-line-string):
* test/automated/tramp-tests.el (tramp-test33-asynchronous-requests):
Use directed rather than neutral quotes in diagnostics.
2015-08-24 23:39:33 -07:00
|
|
|
"Parse a special syntax reference, of the form `#<args>'.
|
2015-05-15 19:42:00 -07:00
|
|
|
|
|
|
|
args := `type' `whitespace' `arbitrary-args' | `arbitrary-args'
|
|
|
|
type := \"buffer\" or \"process\"
|
|
|
|
arbitrary-args := any string of characters.
|
|
|
|
|
Prefer directed to neutral quotes
Prefer directed to neutral quotes in docstings and diagnostics.
In docstrings, escape apostrophes that would otherwise be translated
to curved quotes using the newer, simpler rules.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-lang.el (math-read-giac-subscr)
(math-read-math-subscr):
* lisp/calc/calc-misc.el (report-calc-bug):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/dabbrev.el (dabbrev-expand):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/elint.el (elint-get-top-forms):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emulation/viper-cmd.el (viper-toggle-search-style):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-arg.el (eshell-parse-arguments):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/files-x.el (modify-file-local-variable):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer)
(filesets-update-pre010505):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/gnus/auth-source.el (auth-source-netrc-parse-entries):
* lisp/gnus/gnus-agent.el (gnus-agent-check-overview-buffer)
(gnus-agent-fetch-headers):
* lisp/gnus/gnus-int.el (gnus-start-news-server):
* lisp/gnus/gnus-registry.el:
(gnus-registry--split-fancy-with-parent-internal):
* lisp/gnus/gnus-score.el (gnus-summary-increase-score):
* lisp/gnus/gnus-start.el (gnus-convert-old-newsrc):
* lisp/gnus/gnus-topic.el (gnus-topic-rename):
* lisp/gnus/legacy-gnus-agent.el (gnus-agent-unlist-expire-days):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/gnus/spam.el (spam-check-blackholes):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/tramp-cache.el:
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-bibtex.el (org-bibtex-fields):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/play/dunnet.el (dun-score, dun-help, dun-endgame-question)
(dun-rooms, dun-endgame-questions):
* lisp/progmodes/ada-mode.el (ada-goto-matching-start):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/antlr-mode.el (antlr-options-alists):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/server.el (server-get-auth-key):
* lisp/subr.el (version-to-list):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/vc/ediff-diff.el (ediff-same-contents):
* lisp/vc/vc-cvs.el (vc-cvs-mode-line-string):
* test/automated/tramp-tests.el (tramp-test33-asynchronous-requests):
Use directed rather than neutral quotes in diagnostics.
2015-08-24 23:39:33 -07:00
|
|
|
If the form has no `type', the syntax is parsed as if `type' were
|
2015-05-15 19:42:00 -07:00
|
|
|
\"buffer\"."
|
|
|
|
(when (and (not eshell-current-argument)
|
|
|
|
(not eshell-current-quoted)
|
|
|
|
(looking-at "#<\\(\\(buffer\\|process\\)\\s-\\)?"))
|
|
|
|
(let ((here (point)))
|
|
|
|
(goto-char (match-end 0)) ;; Go to the end of the match.
|
|
|
|
(let ((buffer-p (if (match-string 1)
|
|
|
|
(string= (match-string 2) "buffer")
|
|
|
|
t)) ;; buffer-p is non-nil by default.
|
|
|
|
(end (eshell-find-delimiter ?\< ?\>)))
|
|
|
|
(when (not end)
|
|
|
|
(throw 'eshell-incomplete ?\<))
|
|
|
|
(if (eshell-arg-delimiter (1+ end))
|
|
|
|
(prog1
|
|
|
|
(list (if buffer-p 'get-buffer-create 'get-process)
|
2022-04-26 21:53:00 -07:00
|
|
|
(replace-regexp-in-string
|
|
|
|
(rx "\\" (group (or "\\" "<" ">"))) "\\1"
|
|
|
|
(buffer-substring-no-properties (point) end)))
|
2015-05-15 19:42:00 -07:00
|
|
|
(goto-char (1+ end)))
|
|
|
|
(ignore (goto-char here)))))))
|
2000-06-23 05:24:10 +00:00
|
|
|
|
|
|
|
(defun eshell-parse-delimiter ()
|
|
|
|
"Parse an argument delimiter, which is essentially a command operator."
|
|
|
|
;; this `eshell-operator' keyword gets parsed out by
|
|
|
|
;; `eshell-separate-commands'. Right now the only possibility for
|
|
|
|
;; error is an incorrect output redirection specifier.
|
|
|
|
(when (looking-at "[&|;\n]\\s-*")
|
|
|
|
(let ((end (match-end 0)))
|
|
|
|
(if eshell-current-argument
|
|
|
|
(eshell-finish-arg)
|
|
|
|
(eshell-finish-arg
|
|
|
|
(prog1
|
|
|
|
(list 'eshell-operator
|
|
|
|
(cond
|
|
|
|
((eq (char-after end) ?\&)
|
|
|
|
(setq end (1+ end)) "&&")
|
|
|
|
((eq (char-after end) ?\|)
|
|
|
|
(setq end (1+ end)) "||")
|
|
|
|
((eq (char-after) ?\n) ";")
|
|
|
|
(t
|
|
|
|
(char-to-string (char-after)))))
|
|
|
|
(goto-char end)))))))
|
|
|
|
|
Eshell: Try to untangle the dependencies; move 'provide's to the end
* lisp/eshell/esh-arg.el: Move defsubst and vars before first use.
Don't require `esh-mode but esh-util instead.
* lisp/eshell/esh-cmd.el: Require esh-module and esh-io.
* lisp/eshell/esh-ext.el: Don't require esh-proc nor esh-cmd.
(eshell-external-command): Require esh-proc for
eshell-gather-process-output.
* lisp/eshell/esh-mode.el: Don't require esh-io nor esh-var, but
require esh-arg.
(eshell-directory-name): Move from eshell.el.
* lisp/eshell/esh-module.el: Don't require eshell.
* lisp/eshell/esh-opt.el: Don't require esh-ext at top-level.
(eshell--do-opts, eshell-show-usage): Require it here instead.
* lisp/eshell/esh-proc.el: Don't require esh-cmd, but require esh-io.
(eshell-reset-after-proc, eshell-record-process-object)
(eshell-gather-process-output, eshell-send-eof-to-process):
Require esh-mode and esh-var here.
* lisp/eshell/esh-var.el: Require esh-module, esh-arg, and esh-io.
* lisp/eshell/eshell.el: Require esh-module, esh-proc, esh-io, and esh-cmd.
But don't require esh-mode.
(eshell-directory-name): Move to esh-mode.
(eshell-return-exits-minibuffer): Don't bind 'return' and 'M-return'
since we already bind RET and M-RET.
2019-04-08 14:28:34 -04:00
|
|
|
(provide 'esh-arg)
|
2000-06-23 05:24:10 +00:00
|
|
|
;;; esh-arg.el ends here
|