Only handle ".." and '..' quoting in shell-mode.
[bpt/emacs.git] / lisp / comint.el
index 8103db0..db0f5b8 100644 (file)
@@ -1076,10 +1076,10 @@ See also `comint-read-input-ring'."
 (defun comint-search-arg (arg)
   ;; First make sure there is a ring and that we are after the process mark
   (cond ((not (comint-after-pmark-p))
-        (error "Not at command line"))
+        (user-error "Not at command line"))
        ((or (null comint-input-ring)
             (ring-empty-p comint-input-ring))
-        (error "Empty input ring"))
+        (user-error "Empty input ring"))
        ((zerop arg)
         ;; arg of zero resets search from beginning, and uses arg of 1
         (setq comint-input-ring-index nil)
@@ -1146,7 +1146,7 @@ Moves relative to `comint-input-ring-index'."
 Moves relative to START, or `comint-input-ring-index'."
   (if (or (not (ring-p comint-input-ring))
          (ring-empty-p comint-input-ring))
-      (error "No history"))
+      (user-error "No history"))
   (let* ((len (ring-length comint-input-ring))
         (motion (if (> arg 0) 1 -1))
         (n (mod (- (or start (comint-search-start arg)) motion) len))
@@ -1186,7 +1186,7 @@ If N is negative, find the next or Nth next match."
   (let ((pos (comint-previous-matching-input-string-position regexp n)))
     ;; Has a match been found?
     (if (null pos)
-       (error "Not found")
+       (user-error "Not found")
       ;; If leaving the edit line, save partial input
       (if (null comint-input-ring-index)       ;not yet on ring
          (setq comint-stored-incomplete-input
@@ -1372,7 +1372,7 @@ actual side-effect."
                 (goto-char (match-beginning 0))
                 (if (not (search-forward old pos t))
                     (or silent
-                        (error "Not found"))
+                        (user-error "Not found"))
                   (replace-match new t t)
                   (message "History item: substituted"))))
              (t
@@ -1777,7 +1777,7 @@ Similarly for Soar, Scheme, etc."
   (interactive)
   ;; Note that the input string does not include its terminal newline.
   (let ((proc (get-buffer-process (current-buffer))))
-    (if (not proc) (error "Current buffer has no process")
+    (if (not proc) (user-error "Current buffer has no process")
       (widen)
       (let* ((pmark (process-mark proc))
              (intxt (if (>= (point) (marker-position pmark))
@@ -2201,7 +2201,7 @@ Calls `comint-get-old-input' to get old input."
   (let ((input (funcall comint-get-old-input))
        (process (get-buffer-process (current-buffer))))
     (if (not process)
-       (error "Current buffer has no process")
+       (user-error "Current buffer has no process")
       (goto-char (process-mark process))
       (insert input))))
 
@@ -2508,7 +2508,7 @@ If N is negative, find the next or Nth next match."
            (save-excursion
              (while (/= n 0)
                (unless (re-search-backward regexp nil t dir)
-                 (error "Not found"))
+                 (user-error "Not found"))
                (unless (get-char-property (point) 'field)
                  (setq n (- n dir))))
              (field-beginning))))
@@ -2968,19 +2968,20 @@ This is a good thing to set in mode hooks.")
   "Return the word of WORD-CHARS at point, or nil if none is found.
 Word constituents are considered to be those in WORD-CHARS, which is like the
 inside of a \"[...]\" (see `skip-chars-forward'), plus all non-ASCII characters."
+  ;; FIXME: Need to handle "..." and '...' quoting in shell.el!
+  ;; This should be combined with pomplete-parsing somehow.
   (save-excursion
     (let ((here (point))
          giveup)
       (while (not giveup)
        (let ((startpoint (point)))
          (skip-chars-backward (concat "\\\\" word-chars))
-         ;; Fixme: This isn't consistent with Bash, at least -- not
-         ;; all non-ASCII chars should be word constituents.
-         (if (and (> (- (point) 2) (point-min))
-                  (= (char-after (- (point) 2)) ?\\))
+         (if (and comint-file-name-quote-list
+                  (eq (char-before (1- (point))) ?\\))
              (forward-char -2))
-         (if (and (> (- (point) 1) (point-min))
-                  (>= (char-after (- (point) 1)) 128))
+         ;; FIXME: This isn't consistent with Bash, at least -- not
+         ;; all non-ASCII chars should be word constituents.
+         (if (and (not (bobp)) (>= (char-before) 128))
              (forward-char -1))
          (if (= (point) startpoint)
              (setq giveup t))))
@@ -3012,14 +3013,14 @@ See `comint-word'."
 (defun comint--unquote&requote-argument (qstr &optional upos)
   (unless upos (setq upos 0))
   (let* ((qpos 0)
-         (dquotes nil)
          (ustrs '())
          (re (concat
-              "[\"']\\|\\\\\\(.\\)"
-              "\\|\\$\\(?:\\([[:alpha:]][[:alnum:]]*\\)"
-              "\\|{\\(?2:[^{}]+\\)}\\)"
+              "\\$\\(?:\\([[:alpha:]][[:alnum:]]*\\)"
+              "\\|{\\(?1:[^{}]+\\)}\\)"
               (when (memq system-type '(ms-dos windows-nt))
-                "\\|%\\(?2:[^\\\\/]*\\)%")))
+                "\\|%\\(?1:[^\\\\/]*\\)%")
+              (when comint-file-name-quote-list
+                "\\|\\\\\\(.\\)")))
          (qupos nil)
          (push (lambda (str end)
                  (push str ustrs)
@@ -3030,18 +3031,9 @@ See `comint-word'."
     (while (setq match (string-match re qstr qpos))
       (funcall push (substring qstr qpos match) match)
       (cond
-       ((match-beginning 1) (funcall push (match-string 1 qstr) (match-end 0)))
-       ((match-beginning 2) (funcall push (getenv (match-string 2 qstr))
+       ((match-beginning 2) (funcall push (match-string 2 qstr) (match-end 0)))
+       ((match-beginning 1) (funcall push (getenv (match-string 1 qstr))
                                      (- (match-end 0))))
-       ((eq (aref qstr match) ?\") (setq dquotes (not dquotes)))
-       ((eq (aref qstr match) ?\')
-        (cond
-         (dquotes (funcall push "'" (match-end 0)))
-         ((< match (1+ (length qstr)))
-          (let ((end (string-match "'" qstr (1+ match))))
-            (funcall push (substring qstr (1+ match) end)
-                     (or end (length qstr)))))
-         (t nil)))
        (t (error "Unexpected case in comint--unquote&requote-argument!")))
       (setq qpos (match-end 0)))
     (funcall push (substring qstr qpos) (length qstr))
@@ -3140,7 +3132,7 @@ Returns t if successful."
 See `completion-table-with-quoting' and `comint-requote-function'.")
 (defvar comint-requote-function #'comint--requote-argument
   "Function to use for completion of quoted data.
-See `completion-table-with-quoting' and `comint-requote-function'.")
+See `completion-table-with-quoting' and `comint-unquote-function'.")
 
 (defun comint--complete-file-name-data ()
   "Return the completion data for file name at point."
@@ -3364,7 +3356,7 @@ The process mark separates output, and input already sent,
 from input that has not yet been sent."
   (interactive)
   (let ((proc (or (get-buffer-process (current-buffer))
-                 (error "Current buffer has no process"))))
+                 (user-error "Current buffer has no process"))))
     (goto-char (process-mark proc))
     (when (called-interactively-p 'interactive)
       (message "Point is now at the process mark"))))
@@ -3389,7 +3381,7 @@ the process mark is at the beginning of the accumulated input."
   "Set the process mark at point."
   (interactive)
   (let ((proc (or (get-buffer-process (current-buffer))
-                 (error "Current buffer has no process"))))
+                 (user-error "Current buffer has no process"))))
     (set-marker (process-mark proc) (point))
     (message "Process mark set")))
 
@@ -3741,14 +3733,6 @@ REGEXP-GROUP is the regular expression group in REGEXP to use."
                (match-end regexp-group))
               results))
       results)))
-
-(dolist (x '("^Not at command line$"
-             "^Empty input ring$"
-             "^No history$"
-             "^Not found$"                     ; Too common?
-             "^Current buffer has no process$"))
-  (add-to-list 'debug-ignored-errors x))
-
 \f
 ;; Converting process modes to use comint mode
 ;; ===========================================================================