aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2011-11-18 09:49:42 -0500
committerStefan Monnier2011-11-18 09:49:42 -0500
commit6dbe3e96cf8420e64b05abc25ec3c8dc2478e0db (patch)
treef0f59e0589e171d511382da029d6a1ae1d4c07e3
parentcbe71af350309f939b8159d31d8288ea9f719b30 (diff)
downloademacs-6dbe3e96cf8420e64b05abc25ec3c8dc2478e0db.tar.gz
emacs-6dbe3e96cf8420e64b05abc25ec3c8dc2478e0db.zip
* lisp/eshell/esh-cmd.el (eshell-do-eval): Handle `setq'.
(eshell-rewrite-for-command): Remove workaround. (eshell-do-pipelines, eshell-do-pipelines-synchronously) (eshell-do-eval, eshell-exec-lisp): Avoid gratuitous setq. * lisp/eshell/esh-util.el (eshell-condition-case, eshell-for): Use declare. Fixes: debbugs:9907
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/eshell/esh-cmd.el110
-rw-r--r--lisp/eshell/esh-util.el7
3 files changed, 62 insertions, 61 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 03fa622031a..654e886a3a4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,11 @@
12011-11-18 Stefan Monnier <monnier@iro.umontreal.ca> 12011-11-18 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * eshell/esh-cmd.el (eshell-do-eval): Handle `setq' (bug#9907).
4 (eshell-rewrite-for-command): Remove workaround.
5 (eshell-do-pipelines, eshell-do-pipelines-synchronously)
6 (eshell-do-eval, eshell-exec-lisp): Avoid gratuitous setq.
7 * eshell/esh-util.el (eshell-condition-case, eshell-for): Use declare.
8
3 * files-x.el (modify-file-local-variable): Obey commenting conventions. 9 * files-x.el (modify-file-local-variable): Obey commenting conventions.
4 10
52011-11-17 Glenn Morris <rgm@gnu.org> 112011-11-17 Glenn Morris <rgm@gnu.org>
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index a7c92084bf9..7b90797eb43 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -480,25 +480,20 @@ implemented via rewriting, rather than as a function."
480 (let ((body (car (last terms)))) 480 (let ((body (car (last terms))))
481 (setcdr (last terms 2) nil) 481 (setcdr (last terms 2) nil)
482 `(let ((for-items 482 `(let ((for-items
483 ;; Apparently, eshell-do-eval only works for immutable 483 (append
484 ;; let-bindings, i.e. we cannot use `setq' on `for-items'. 484 ,@(mapcar
485 ;; Instead we store the list in the car of a cons-cell (which 485 (lambda (elem)
486 ;; acts as a ref-cell) so we can setcar instead of setq. 486 (if (listp elem)
487 (list 487 elem
488 (append 488 `(list ,elem)))
489 ,@(mapcar 489 (cdr (cddr terms)))))
490 (lambda (elem)
491 (if (listp elem)
492 elem
493 `(list ,elem)))
494 (cdr (cddr terms))))))
495 (eshell-command-body '(nil)) 490 (eshell-command-body '(nil))
496 (eshell-test-body '(nil))) 491 (eshell-test-body '(nil)))
497 (while (consp (car for-items)) 492 (while (consp for-items)
498 (let ((,(intern (cadr terms)) (caar for-items))) 493 (let ((,(intern (cadr terms)) (car for-items)))
499 (eshell-protect 494 (eshell-protect
500 ,(eshell-invokify-arg body t))) 495 ,(eshell-invokify-arg body t)))
501 (setcar for-items (cdar for-items))) 496 (setq for-items (cdr for-items)))
502 (eshell-close-handles 497 (eshell-close-handles
503 eshell-last-command-status 498 eshell-last-command-status
504 (list 'quote eshell-last-command-result)))))) 499 (list 'quote eshell-last-command-result))))))
@@ -766,9 +761,8 @@ This macro calls itself recursively, with NOTFIRST non-nil."
766 `(eshell-copy-handles 761 `(eshell-copy-handles
767 (progn 762 (progn
768 ,(when (cdr pipeline) 763 ,(when (cdr pipeline)
769 `(let (nextproc) 764 `(let ((nextproc
770 (setq nextproc 765 (eshell-do-pipelines (quote ,(cdr pipeline)) t)))
771 (eshell-do-pipelines (quote ,(cdr pipeline)) t))
772 (eshell-set-output-handle ,eshell-output-handle 766 (eshell-set-output-handle ,eshell-output-handle
773 'append nextproc) 767 'append nextproc)
774 (eshell-set-output-handle ,eshell-error-handle 768 (eshell-set-output-handle ,eshell-error-handle
@@ -796,10 +790,9 @@ This macro calls itself recursively, with NOTFIRST non-nil."
796Output of each command is passed as input to the next one in the pipeline. 790Output of each command is passed as input to the next one in the pipeline.
797This is used on systems where `start-process' is not supported." 791This is used on systems where `start-process' is not supported."
798 (when (setq pipeline (cadr pipeline)) 792 (when (setq pipeline (cadr pipeline))
799 `(let (result) 793 `(progn
800 ,(when (cdr pipeline) 794 ,(when (cdr pipeline)
801 `(let (output-marker) 795 `(let ((output-marker ,(point-marker)))
802 (setq output-marker ,(point-marker))
803 (eshell-set-output-handle ,eshell-output-handle 796 (eshell-set-output-handle ,eshell-output-handle
804 'append output-marker) 797 'append output-marker)
805 (eshell-set-output-handle ,eshell-error-handle 798 (eshell-set-output-handle ,eshell-error-handle
@@ -811,21 +804,21 @@ This is used on systems where `start-process' is not supported."
811 (when (memq (car head) eshell-deferrable-commands) 804 (when (memq (car head) eshell-deferrable-commands)
812 (ignore 805 (ignore
813 (setcar head 806 (setcar head
814 (intern-soft 807 (intern-soft
815 (concat (symbol-name (car head)) "*")))))) 808 (concat (symbol-name (car head)) "*"))))))
816 ;; The last process in the pipe should get its handles 809 ;; The last process in the pipe should get its handles
817 ;; redirected as we found them before running the pipe. 810 ;; redirected as we found them before running the pipe.
818 ,(if (null (cdr pipeline)) 811 ,(if (null (cdr pipeline))
819 `(progn 812 `(progn
820 (setq eshell-current-handles tail-handles) 813 (setq eshell-current-handles tail-handles)
821 (setq eshell-in-pipeline-p nil))) 814 (setq eshell-in-pipeline-p nil)))
822 (setq result ,(car pipeline)) 815 (let ((result ,(car pipeline)))
823 ;; tailproc gets the result of the last successful process in 816 ;; tailproc gets the result of the last successful process in
824 ;; the pipeline. 817 ;; the pipeline.
825 (setq tailproc (or result tailproc)) 818 (setq tailproc (or result tailproc))
826 ,(if (cdr pipeline) 819 ,(if (cdr pipeline)
827 `(eshell-do-pipelines-synchronously (quote ,(cdr pipeline)))) 820 `(eshell-do-pipelines-synchronously (quote ,(cdr pipeline))))
828 result))) 821 result))))
829 822
830(defalias 'eshell-process-identity 'identity) 823(defalias 'eshell-process-identity 'identity)
831 824
@@ -890,8 +883,7 @@ Returns a string comprising the output from the command."
890 (eshell-print "errors\n")) 883 (eshell-print "errors\n"))
891 (if eshell-debug-command 884 (if eshell-debug-command
892 (eshell-print "commands\n"))) 885 (eshell-print "commands\n")))
893 ((or (string= (car args) "-h") 886 ((member (car args) '("-h" "--help"))
894 (string= (car args) "--help"))
895 (eshell-print "usage: eshell-debug [kinds] 887 (eshell-print "usage: eshell-debug [kinds]
896 888
897This command is used to aid in debugging problems related to Eshell 889This command is used to aid in debugging problems related to Eshell
@@ -1091,6 +1083,11 @@ be finished later after the completion of an asynchronous subprocess."
1091 (eshell-manipulate "handling special form" 1083 (eshell-manipulate "handling special form"
1092 (setcar args `(eshell-do-eval ',(car args) ,synchronous-p)))) 1084 (setcar args `(eshell-do-eval ',(car args) ,synchronous-p))))
1093 (eval form)) 1085 (eval form))
1086 ((eq (car form) 'setq)
1087 (if (cddr args) (error "Unsupported form (setq X1 E1 X2 E2..)"))
1088 (eshell-manipulate "evaluating arguments to setq"
1089 (setcar (cdr args) (eshell-do-eval (cadr args) synchronous-p)))
1090 (list 'quote (eval form)))
1094 (t 1091 (t
1095 (if (and args (not (memq (car form) '(run-hooks)))) 1092 (if (and args (not (memq (car form) '(run-hooks))))
1096 (eshell-manipulate 1093 (eshell-manipulate
@@ -1127,11 +1124,12 @@ be finished later after the completion of an asynchronous subprocess."
1127 ;; Thus, aliases can even contain references to asynchronous 1124 ;; Thus, aliases can even contain references to asynchronous
1128 ;; sub-commands, and things will still work out as they 1125 ;; sub-commands, and things will still work out as they
1129 ;; should. 1126 ;; should.
1130 (let (result new-form) 1127 (let* (result
1131 (if (setq new-form 1128 (new-form
1132 (catch 'eshell-replace-command 1129 (catch 'eshell-replace-command
1133 (ignore 1130 (ignore
1134 (setq result (eval form))))) 1131 (setq result (eval form))))))
1132 (if new-form
1135 (progn 1133 (progn
1136 (eshell-manipulate "substituting replacement form" 1134 (eshell-manipulate "substituting replacement form"
1137 (setcar form (car new-form)) 1135 (setcar form (car new-form))
@@ -1247,25 +1245,23 @@ or an external command."
1247PRINTER and ERRPRINT are functions to use for printing regular 1245PRINTER and ERRPRINT are functions to use for printing regular
1248messages, and errors. FORM-P should be non-nil if FUNC-OR-FORM 1246messages, and errors. FORM-P should be non-nil if FUNC-OR-FORM
1249represent a lisp form; ARGS will be ignored in that case." 1247represent a lisp form; ARGS will be ignored in that case."
1250 (let (result) 1248 (eshell-condition-case err
1251 (eshell-condition-case err 1249 (let ((result
1252 (progn 1250 (save-current-buffer
1253 (setq result 1251 (if form-p
1254 (save-current-buffer 1252 (eval func-or-form)
1255 (if form-p 1253 (apply func-or-form args)))))
1256 (eval func-or-form) 1254 (and result (funcall printer result))
1257 (apply func-or-form args)))) 1255 result)
1258 (and result (funcall printer result)) 1256 (error
1259 result) 1257 (let ((msg (error-message-string err)))
1260 (error 1258 (if (and (not form-p)
1261 (let ((msg (error-message-string err))) 1259 (string-match "^Wrong number of arguments" msg)
1262 (if (and (not form-p) 1260 (fboundp 'eldoc-get-fnsym-args-string))
1263 (string-match "^Wrong number of arguments" msg) 1261 (let ((func-doc (eldoc-get-fnsym-args-string func-or-form)))
1264 (fboundp 'eldoc-get-fnsym-args-string)) 1262 (setq msg (format "usage: %s" func-doc))))
1265 (let ((func-doc (eldoc-get-fnsym-args-string func-or-form))) 1263 (funcall errprint msg))
1266 (setq msg (format "usage: %s" func-doc)))) 1264 nil)))
1267 (funcall errprint msg))
1268 nil))))
1269 1265
1270(defsubst eshell-apply* (printer errprint func args) 1266(defsubst eshell-apply* (printer errprint func args)
1271 "Call FUNC, with ARGS, trapping errors and return them as output. 1267 "Call FUNC, with ARGS, trapping errors and return them as output.
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 424d246a2b6..bbb453be711 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -140,14 +140,13 @@ function `string-to-number'."
140(defmacro eshell-condition-case (tag form &rest handlers) 140(defmacro eshell-condition-case (tag form &rest handlers)
141 "If `eshell-handle-errors' is non-nil, this is `condition-case'. 141 "If `eshell-handle-errors' is non-nil, this is `condition-case'.
142Otherwise, evaluates FORM with no error handling." 142Otherwise, evaluates FORM with no error handling."
143 (declare (indent 2))
143 (if eshell-handle-errors 144 (if eshell-handle-errors
144 `(condition-case ,tag 145 `(condition-case ,tag
145 ,form 146 ,form
146 ,@handlers) 147 ,@handlers)
147 form)) 148 form))
148 149
149(put 'eshell-condition-case 'lisp-indent-function 2)
150
151(defun eshell-find-delimiter 150(defun eshell-find-delimiter
152 (open close &optional bound reverse-p backslash-p) 151 (open close &optional bound reverse-p backslash-p)
153 "From point, find the CLOSE delimiter corresponding to OPEN. 152 "From point, find the CLOSE delimiter corresponding to OPEN.
@@ -275,14 +274,14 @@ Prepend remote identification of `default-directory', if any."
275 text)) 274 text))
276 275
277(defmacro eshell-for (for-var for-list &rest forms) 276(defmacro eshell-for (for-var for-list &rest forms)
278 "Iterate through a list" 277 "Iterate through a list."
278 (declare (indent 2))
279 `(let ((list-iter ,for-list)) 279 `(let ((list-iter ,for-list))
280 (while list-iter 280 (while list-iter
281 (let ((,for-var (car list-iter))) 281 (let ((,for-var (car list-iter)))
282 ,@forms) 282 ,@forms)
283 (setq list-iter (cdr list-iter))))) 283 (setq list-iter (cdr list-iter)))))
284 284
285(put 'eshell-for 'lisp-indent-function 2)
286 285
287(make-obsolete 'eshell-for 'dolist "24.1") 286(make-obsolete 'eshell-for 'dolist "24.1")
288 287