aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2009-10-22 03:24:31 +0000
committerStefan Monnier2009-10-22 03:24:31 +0000
commit3170b794591682ca5915f8229a15edcb40e479dd (patch)
treedf237dce71c7610a2d87efb4ead4936dc502dc55
parente7b94bbb53b7aff75396a5124b9166a4fbb41308 (diff)
downloademacs-3170b794591682ca5915f8229a15edcb40e479dd.tar.gz
emacs-3170b794591682ca5915f8229a15edcb40e479dd.zip
(comint-read-input-ring, comint-write-input-ring)
(comint-substitute-in-file-name) (comint-dynamic-complete-as-filename) (comint-dynamic-simple-complete) (comint-dynamic-list-filename-completions) (comint-dynamic-list-completions) (comint-redirect-results-list-from-process): Minor simplifications.
-rw-r--r--lisp/ChangeLog14
-rw-r--r--lisp/comint.el59
2 files changed, 42 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f780fda7269..acdd6164da5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,7 +1,17 @@
12009-10-22 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * comint.el (comint-read-input-ring, comint-write-input-ring)
4 (comint-substitute-in-file-name)
5 (comint-dynamic-complete-as-filename)
6 (comint-dynamic-simple-complete)
7 (comint-dynamic-list-filename-completions)
8 (comint-dynamic-list-completions)
9 (comint-redirect-results-list-from-process): Minor simplifications.
10
12009-10-21 Kevin Ryde <user42@zip.com.au> 112009-10-21 Kevin Ryde <user42@zip.com.au>
2 12
3 * emacs-lisp/checkdoc.el (checkdoc-file-comments-engine): When 13 * emacs-lisp/checkdoc.el (checkdoc-file-comments-engine):
4 inserting ";;; Code" put it before any ";;;###autoload" cookie on 14 When inserting ";;; Code" put it before any ";;;###autoload" cookie on
5 the first form. And insert a blank line after ";;; Code" since 15 the first form. And insert a blank line after ";;; Code" since
6 that's usual style. (My Bug#4612.) 16 that's usual style. (My Bug#4612.)
7 17
diff --git a/lisp/comint.el b/lisp/comint.el
index 2115475b4b7..1d8deb1f1fb 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -902,8 +902,7 @@ See also `comint-input-ignoredups' and `comint-write-input-ring'."
902 (size comint-input-ring-size) 902 (size comint-input-ring-size)
903 (ring (make-ring size))) 903 (ring (make-ring size)))
904 (unwind-protect 904 (unwind-protect
905 (save-excursion 905 (with-current-buffer history-buf
906 (set-buffer history-buf)
907 (widen) 906 (widen)
908 (erase-buffer) 907 (erase-buffer)
909 (insert-file-contents file) 908 (insert-file-contents file)
@@ -912,17 +911,22 @@ See also `comint-input-ignoredups' and `comint-write-input-ring'."
912 (goto-char (point-max)) 911 (goto-char (point-max))
913 (let (start end history) 912 (let (start end history)
914 (while (and (< count size) 913 (while (and (< count size)
915 (re-search-backward comint-input-ring-separator nil t) 914 (re-search-backward comint-input-ring-separator
915 nil t)
916 (setq end (match-beginning 0))) 916 (setq end (match-beginning 0)))
917 (if (re-search-backward comint-input-ring-separator nil t) 917 (setq start
918 (setq start (match-end 0)) 918 (if (re-search-backward comint-input-ring-separator
919 (setq start (point-min))) 919 nil t)
920 (match-end 0)
921 (point-min)))
920 (setq history (buffer-substring start end)) 922 (setq history (buffer-substring start end))
921 (goto-char start) 923 (goto-char start)
922 (if (and (not (string-match comint-input-history-ignore history)) 924 (if (and (not (string-match comint-input-history-ignore
925 history))
923 (or (null comint-input-ignoredups) 926 (or (null comint-input-ignoredups)
924 (ring-empty-p ring) 927 (ring-empty-p ring)
925 (not (string-equal (ring-ref ring 0) history)))) 928 (not (string-equal (ring-ref ring 0)
929 history))))
926 (progn 930 (progn
927 (ring-insert-at-beginning ring history) 931 (ring-insert-at-beginning ring history)
928 (setq count (1+ count))))))) 932 (setq count (1+ count)))))))
@@ -952,8 +956,7 @@ See also `comint-read-input-ring'."
952 (index (ring-length ring))) 956 (index (ring-length ring)))
953 ;; Write it all out into a buffer first. Much faster, but messier, 957 ;; Write it all out into a buffer first. Much faster, but messier,
954 ;; than writing it one line at a time. 958 ;; than writing it one line at a time.
955 (save-excursion 959 (with-current-buffer history-buf
956 (set-buffer history-buf)
957 (erase-buffer) 960 (erase-buffer)
958 (while (> index 0) 961 (while (> index 0)
959 (setq index (1- index)) 962 (setq index (1- index))
@@ -1737,7 +1740,8 @@ Make backspaces delete the previous character."
1737 (let ((functions comint-preoutput-filter-functions)) 1740 (let ((functions comint-preoutput-filter-functions))
1738 (while (and functions string) 1741 (while (and functions string)
1739 (if (eq (car functions) t) 1742 (if (eq (car functions) t)
1740 (let ((functions (default-value 'comint-preoutput-filter-functions))) 1743 (let ((functions
1744 (default-value 'comint-preoutput-filter-functions)))
1741 (while (and functions string) 1745 (while (and functions string)
1742 (setq string (funcall (car functions) string)) 1746 (setq string (funcall (car functions) string))
1743 (setq functions (cdr functions)))) 1747 (setq functions (cdr functions))))
@@ -2731,11 +2735,8 @@ interpreter (e.g., the percent notation of cmd.exe on NT)."
2731 env-var-val) 2735 env-var-val)
2732 (save-match-data 2736 (save-match-data
2733 (while (string-match "%\\([^\\\\/]*\\)%" name) 2737 (while (string-match "%\\([^\\\\/]*\\)%" name)
2734 (setq env-var-name 2738 (setq env-var-name (match-string 1 name))
2735 (substring name (match-beginning 1) (match-end 1))) 2739 (setq env-var-val (or (getenv env-var-name) ""))
2736 (setq env-var-val (if (getenv env-var-name)
2737 (getenv env-var-name)
2738 ""))
2739 (setq name (replace-match env-var-val t t name)))))) 2740 (setq name (replace-match env-var-val t t name))))))
2740 name)) 2741 name))
2741 2742
@@ -2836,7 +2837,7 @@ See `comint-dynamic-complete-filename'. Returns t if successful."
2836 (completion (file-name-completion filenondir directory))) 2837 (completion (file-name-completion filenondir directory)))
2837 (cond ((null completion) 2838 (cond ((null completion)
2838 (if minibuffer-p 2839 (if minibuffer-p
2839 (minibuffer-message (format " [No completions of %s]" filename)) 2840 (minibuffer-message "No completions of %s" filename)
2840 (message "No completions of %s" filename)) 2841 (message "No completions of %s" filename))
2841 (setq success nil)) 2842 (setq success nil))
2842 ((eq completion t) ; Means already completed "file". 2843 ((eq completion t) ; Means already completed "file".
@@ -2911,7 +2912,7 @@ See also `comint-dynamic-complete-filename'."
2911 (completions (all-completions stub candidates))) 2912 (completions (all-completions stub candidates)))
2912 (cond ((null completions) 2913 (cond ((null completions)
2913 (if minibuffer-p 2914 (if minibuffer-p
2914 (minibuffer-message (format " [No completions of %s]" stub)) 2915 (minibuffer-message "No completions of %s" stub)
2915 (message "No completions of %s" stub)) 2916 (message "No completions of %s" stub))
2916 nil) 2917 nil)
2917 ((= 1 (length completions)) ; Gotcha! 2918 ((= 1 (length completions)) ; Gotcha!
@@ -2962,7 +2963,7 @@ See also `comint-dynamic-complete-filename'."
2962 (completions (file-name-all-completions filenondir directory))) 2963 (completions (file-name-all-completions filenondir directory)))
2963 (if (not completions) 2964 (if (not completions)
2964 (if (window-minibuffer-p (selected-window)) 2965 (if (window-minibuffer-p (selected-window))
2965 (minibuffer-message (format " [No completions of %s]" filename)) 2966 (minibuffer-message "No completions of %s" filename)
2966 (message "No completions of %s" filename)) 2967 (message "No completions of %s" filename))
2967 (comint-dynamic-list-completions 2968 (comint-dynamic-list-completions
2968 (mapcar 'comint-quote-filename completions) 2969 (mapcar 'comint-quote-filename completions)
@@ -3012,7 +3013,7 @@ Typing SPC flushes the help buffer."
3012 (with-output-to-temp-buffer "*Completions*" 3013 (with-output-to-temp-buffer "*Completions*"
3013 (display-completion-list completions common-substring)) 3014 (display-completion-list completions common-substring))
3014 (if (window-minibuffer-p (selected-window)) 3015 (if (window-minibuffer-p (selected-window))
3015 (minibuffer-message " [Type space to flush; repeat completion command to scroll]") 3016 (minibuffer-message "Type space to flush; repeat completion command to scroll")
3016 (message "Type space to flush; repeat completion command to scroll"))) 3017 (message "Type space to flush; repeat completion command to scroll")))
3017 3018
3018 ;; Read the next key, to process SPC. 3019 ;; Read the next key, to process SPC.
@@ -3296,13 +3297,15 @@ This function does not need to be invoked by the end user."
3296 (list comint-redirect-output-buffer))) 3297 (list comint-redirect-output-buffer)))
3297 (filtered-input-string input-string)) 3298 (filtered-input-string input-string))
3298 3299
3299 ;; If there are any filter functions, give them a chance to modify the string 3300 ;; If there are any filter functions, give them a chance to modify
3301 ;; the string.
3300 (let ((functions comint-redirect-filter-functions)) 3302 (let ((functions comint-redirect-filter-functions))
3301 (while (and functions filtered-input-string) 3303 (while (and functions filtered-input-string)
3302 (if (eq (car functions) t) 3304 (if (eq (car functions) t)
3303 ;; If a local value says "use the default value too", 3305 ;; If a local value says "use the default value too",
3304 ;; do that. 3306 ;; do that.
3305 (let ((functions (default-value 'comint-redirect-filter-functions))) 3307 (let ((functions
3308 (default-value 'comint-redirect-filter-functions)))
3306 (while (and functions filtered-input-string) 3309 (while (and functions filtered-input-string)
3307 (setq filtered-input-string 3310 (setq filtered-input-string
3308 (funcall (car functions) filtered-input-string)) 3311 (funcall (car functions) filtered-input-string))
@@ -3422,8 +3425,7 @@ Return a list of expressions in the output which match REGEXP.
3422REGEXP-GROUP is the regular expression group in REGEXP to use." 3425REGEXP-GROUP is the regular expression group in REGEXP to use."
3423 (let ((output-buffer " *Comint Redirect Work Buffer*") 3426 (let ((output-buffer " *Comint Redirect Work Buffer*")
3424 results) 3427 results)
3425 (save-excursion 3428 (with-current-buffer (get-buffer-create output-buffer)
3426 (set-buffer (get-buffer-create output-buffer))
3427 (erase-buffer) 3429 (erase-buffer)
3428 (comint-redirect-send-command-to-process command 3430 (comint-redirect-send-command-to-process command
3429 output-buffer process nil t) 3431 output-buffer process nil t)
@@ -3438,11 +3440,10 @@ REGEXP-GROUP is the regular expression group in REGEXP to use."
3438 (and (looking-at command) 3440 (and (looking-at command)
3439 (forward-line)) 3441 (forward-line))
3440 (while (re-search-forward regexp nil t) 3442 (while (re-search-forward regexp nil t)
3441 (setq results 3443 (push (buffer-substring-no-properties
3442 (cons (buffer-substring-no-properties 3444 (match-beginning regexp-group)
3443 (match-beginning regexp-group) 3445 (match-end regexp-group))
3444 (match-end regexp-group)) 3446 results))
3445 results)))
3446 results))) 3447 results)))
3447 3448
3448(dolist (x '("^Not at command line$" 3449(dolist (x '("^Not at command line$"