aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorPaul Eggert2011-05-31 19:49:51 -0700
committerPaul Eggert2011-05-31 19:49:51 -0700
commit7e655d386397029b7ce6ac204fc41e5ddc92cf54 (patch)
tree75ffb3cd91672a517cfa643d6f45253c62526e41 /lisp
parentccd9a01aa7b67dd3d71b49e3c30df04dd39b4cae (diff)
parent357e1c676cba36d5fa7b6819425a38cbad0c30cd (diff)
downloademacs-7e655d386397029b7ce6ac204fc41e5ddc92cf54.tar.gz
emacs-7e655d386397029b7ce6ac204fc41e5ddc92cf54.zip
Merge from trunk.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog26
-rw-r--r--lisp/emacs-lisp/debug.el18
-rw-r--r--lisp/gnus/ChangeLog21
-rw-r--r--lisp/gnus/gnus-registry.el15
-rw-r--r--lisp/gnus/gnus-sum.el8
-rw-r--r--lisp/gnus/shr.el32
-rw-r--r--lisp/minibuffer.el99
-rw-r--r--lisp/subr.el7
-rw-r--r--lisp/url/ChangeLog9
-rw-r--r--lisp/url/url-future.el126
-rw-r--r--lisp/url/url-queue.el2
11 files changed, 302 insertions, 61 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 07f700f6987..8f96a838cc5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,31 @@
12011-05-31 Stefan Monnier <monnier@iro.umontreal.ca> 12011-05-31 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * minibuffer.el (complete-with-action): Return nil for the metadata and
4 boundaries of non-functional tables.
5 (completion-table-dynamic): Return nil for the metadata.
6 (completion-table-with-terminator): Add default case, using
7 complete-with-action.
8 (completion--metadata): New function.
9 (completion-all-sorted-completions, minibuffer-completion-help): Use it
10 to try and avoid pathological performance problems.
11 (completion--embedded-envvar-table): Return `category' metadata.
12
132011-05-31 Lars Magne Ingebrigtsen <larsi@gnus.org>
14
15 * subr.el (process-alive-p): New tiny convenience function.
16
172011-05-31 Stefan Monnier <monnier@iro.umontreal.ca>
18
19 * emacs-lisp/debug.el (debug): Save&restore not just the buffer's
20 content but also its previous major mode.
21
222011-05-31 Helmut Eller <eller.helmut@gmail.com>
23
24 * debug.el (debug): Restore the previous content of the
25 *Backtrace* buffer when we exit with C-M-c.
26
272011-05-31 Stefan Monnier <monnier@iro.umontreal.ca>
28
3 * minibuffer.el: Add metadata method to completion tables. 29 * minibuffer.el: Add metadata method to completion tables.
4 (completion-category-overrides): New defcustom. 30 (completion-category-overrides): New defcustom.
5 (completion-metadata, completion--field-metadata) 31 (completion-metadata, completion--field-metadata)
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index 88633eaaa46..28962595ace 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -118,6 +118,10 @@ first will be printed into the backtrace buffer."
118 (let (debugger-value 118 (let (debugger-value
119 (debug-on-error nil) 119 (debug-on-error nil)
120 (debug-on-quit nil) 120 (debug-on-quit nil)
121 (debugger-previous-state
122 (if (get-buffer "*Backtrace*")
123 (with-current-buffer (get-buffer "*Backtrace*")
124 (list major-mode (buffer-string)))))
121 (debugger-buffer (get-buffer-create "*Backtrace*")) 125 (debugger-buffer (get-buffer-create "*Backtrace*"))
122 (debugger-old-buffer (current-buffer)) 126 (debugger-old-buffer (current-buffer))
123 (debugger-step-after-exit nil) 127 (debugger-step-after-exit nil)
@@ -214,8 +218,6 @@ first will be printed into the backtrace buffer."
214 ;; recreate it every time the debugger stops, so instead we'll 218 ;; recreate it every time the debugger stops, so instead we'll
215 ;; erase it (and maybe hide it) but keep it alive. 219 ;; erase it (and maybe hide it) but keep it alive.
216 (with-current-buffer debugger-buffer 220 (with-current-buffer debugger-buffer
217 (erase-buffer)
218 (fundamental-mode)
219 (with-selected-window (get-buffer-window debugger-buffer 0) 221 (with-selected-window (get-buffer-window debugger-buffer 0)
220 (when (and (window-dedicated-p (selected-window)) 222 (when (and (window-dedicated-p (selected-window))
221 (not debugger-will-be-back)) 223 (not debugger-will-be-back))
@@ -232,7 +234,17 @@ first will be printed into the backtrace buffer."
232 ;; to be left at the top-level, still working on how 234 ;; to be left at the top-level, still working on how
233 ;; best to do that. 235 ;; best to do that.
234 (bury-buffer)))) 236 (bury-buffer))))
235 (kill-buffer debugger-buffer)) 237 (unless debugger-previous-state
238 (kill-buffer debugger-buffer)))
239 ;; Restore the previous state of the debugger-buffer, in case we were
240 ;; in a recursive invocation of the debugger.
241 (when (and debugger-previous-state
242 (buffer-live-p debugger-buffer))
243 (with-current-buffer debugger-buffer
244 (let ((inhibit-read-only t))
245 (erase-buffer)
246 (insert (nth 1 debugger-previous-state))
247 (funcall (nth 0 debugger-previous-state)))))
236 (with-timeout-unsuspend debugger-with-timeout-suspend) 248 (with-timeout-unsuspend debugger-with-timeout-suspend)
237 (set-match-data debugger-outer-match-data))) 249 (set-match-data debugger-outer-match-data)))
238 ;; Put into effect the modified values of these variables 250 ;; Put into effect the modified values of these variables
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index dcbc647950f..4cf21f65597 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,24 @@
12011-05-31 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * shr.el (shr-rescale-image): Add an :ascent of 100 to images so that
4 the underline comes at the bottom.
5
62011-05-31 Teodor Zlatanov <tzz@lifelogs.com>
7
8 * gnus-registry.el (gnus-registry-article-marks-to-chars): Rename from
9 `gnus-registry-user-format-function-M' and declare the latter obsolete.
10 (gnus-registry-article-marks-to-names): Rename from
11 `gnus-registry-user-format-function-M2'.
12
132011-05-31 Katsumi Yamaoka <yamaoka@jpl.org>
14
15 * gnus-sum.el (gnus-summary-exit): Make sure to kill article buffer in
16 ephemeral group.
17
182011-05-31 Lars Magne Ingebrigtsen <larsi@gnus.org>
19
20 * shr.el (shr-browse-image): Copy the URL if called interactively.
21
12011-05-30 Lars Magne Ingebrigtsen <larsi@gnus.org> 222011-05-30 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 23
3 * gnus-group.el (gnus-group-mark-article-read): It's possible that we 24 * gnus-group.el (gnus-group-mark-article-read): It's possible that we
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index e0efbaf4f30..f6c0daaaa93 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -62,10 +62,10 @@
62 62
63;; show the marks as single characters (see the :char property in 63;; show the marks as single characters (see the :char property in
64;; `gnus-registry-marks'): 64;; `gnus-registry-marks'):
65;; (defalias 'gnus-user-format-function-M 'gnus-registry-user-format-function-M) 65;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-chars)
66 66
67;; show the marks by name (see `gnus-registry-marks'): 67;; show the marks by name (see `gnus-registry-marks'):
68;; (defalias 'gnus-user-format-function-M 'gnus-registry-user-format-function-M2) 68;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-names)
69 69
70;; TODO: 70;; TODO:
71 71
@@ -897,9 +897,12 @@ Uses `gnus-registry-marks' to find what shortcuts to install."
897 nil 897 nil
898 (cons "Registry Marks" gnus-registry-misc-menus)))))) 898 (cons "Registry Marks" gnus-registry-misc-menus))))))
899 899
900(make-obsolete 'gnus-registry-user-format-function-M
901 'gnus-registry-article-marks-to-chars "24.1") ?
902
900;; use like this: 903;; use like this:
901;; (defalias 'gnus-user-format-function-M 'gnus-registry-user-format-function-M) 904;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-chars)
902(defun gnus-registry-user-format-function-M (headers) 905(defun gnus-registry-article-marks-to-chars (headers)
903 "Show the marks for an article by the :char property" 906 "Show the marks for an article by the :char property"
904 (let* ((id (mail-header-message-id headers)) 907 (let* ((id (mail-header-message-id headers))
905 (marks (when id (gnus-registry-get-id-key id 'mark)))) 908 (marks (when id (gnus-registry-get-id-key id 'mark))))
@@ -911,8 +914,8 @@ Uses `gnus-registry-marks' to find what shortcuts to install."
911 marks ""))) 914 marks "")))
912 915
913;; use like this: 916;; use like this:
914;; (defalias 'gnus-user-format-function-M 'gnus-registry-user-format-function-M2) 917;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-names)
915(defun gnus-registry-user-format-function-M2 (headers) 918(defun gnus-registry-article-marks-to-names (headers)
916 "Show the marks for an article by name" 919 "Show the marks for an article by name"
917 (let* ((id (mail-header-message-id headers)) 920 (let* ((id (mail-header-message-id headers))
918 (marks (when id (gnus-registry-get-id-key id 'mark)))) 921 (marks (when id (gnus-registry-get-id-key id 'mark))))
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 2d75c35158a..1c4382b24a6 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -7194,7 +7194,11 @@ If FORCE (the prefix), also save the .newsrc file(s)."
7194 (article-buffer gnus-article-buffer) 7194 (article-buffer gnus-article-buffer)
7195 (mode major-mode) 7195 (mode major-mode)
7196 (group-point nil) 7196 (group-point nil)
7197 (buf (current-buffer))) 7197 (buf (current-buffer))
7198 ;; `gnus-single-article-buffer' is nil buffer-locally in
7199 ;; ephemeral group of which summary buffer will be killed,
7200 ;; but the global value may be non-nil.
7201 (single-article-buffer gnus-single-article-buffer))
7198 (unless quit-config 7202 (unless quit-config
7199 ;; Do adaptive scoring, and possibly save score files. 7203 ;; Do adaptive scoring, and possibly save score files.
7200 (when gnus-newsgroup-adaptive 7204 (when gnus-newsgroup-adaptive
@@ -7257,7 +7261,7 @@ If FORCE (the prefix), also save the .newsrc file(s)."
7257 (gnus-configure-windows 'group 'force))) 7261 (gnus-configure-windows 'group 'force)))
7258 7262
7259 ;; If we have several article buffers, we kill them at exit. 7263 ;; If we have several article buffers, we kill them at exit.
7260 (unless gnus-single-article-buffer 7264 (unless single-article-buffer
7261 (when (gnus-buffer-live-p article-buffer) 7265 (when (gnus-buffer-live-p article-buffer)
7262 (with-current-buffer article-buffer 7266 (with-current-buffer article-buffer
7263 ;; Don't kill sticky article buffers 7267 ;; Don't kill sticky article buffers
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index ebd854930df..67effc07ee2 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -183,14 +183,23 @@ redirects somewhere else."
183 (message "No image under point") 183 (message "No image under point")
184 (message "%s" text)))) 184 (message "%s" text))))
185 185
186(defun shr-browse-image () 186(defun shr-browse-image (&optional copy-url)
187 "Browse the image under point." 187 "Browse the image under point.
188 (interactive) 188If COPY-URL (the prefix if called interactively) is non-nil, copy
189the URL of the image to the kill buffer instead."
190 (interactive "P")
189 (let ((url (get-text-property (point) 'image-url))) 191 (let ((url (get-text-property (point) 'image-url)))
190 (if (not url) 192 (cond
191 (message "No image under point") 193 ((not url)
194 (message "No image under point"))
195 (copy-url
196 (with-temp-buffer
197 (insert url)
198 (copy-region-as-kill (point-min) (point-max))
199 (message "Copied %s" url)))
200 (t
192 (message "Browsing %s..." url) 201 (message "Browsing %s..." url)
193 (browse-url url)))) 202 (browse-url url)))))
194 203
195(defun shr-insert-image () 204(defun shr-insert-image ()
196 "Insert the image under point into the buffer." 205 "Insert the image under point into the buffer."
@@ -524,8 +533,9 @@ redirects somewhere else."
524(defun shr-rescale-image (data) 533(defun shr-rescale-image (data)
525 (if (or (not (fboundp 'imagemagick-types)) 534 (if (or (not (fboundp 'imagemagick-types))
526 (not (get-buffer-window (current-buffer)))) 535 (not (get-buffer-window (current-buffer))))
527 (create-image data nil t) 536 (create-image data nil t
528 (let* ((image (create-image data nil t)) 537 :ascent 100)
538 (let* ((image (create-image data nil t :ascent 100))
529 (size (image-size image t)) 539 (size (image-size image t))
530 (width (car size)) 540 (width (car size))
531 (height (cdr size)) 541 (height (cdr size))
@@ -544,11 +554,13 @@ redirects somewhere else."
544 (when (> (car size) window-width) 554 (when (> (car size) window-width)
545 (setq image (or 555 (setq image (or
546 (create-image data 'imagemagick t 556 (create-image data 'imagemagick t
547 :width window-width) 557 :width window-width
558 :ascent 100)
548 image))) 559 image)))
549 (when (and (fboundp 'create-animated-image) 560 (when (and (fboundp 'create-animated-image)
550 (eq (image-type data nil t) 'gif)) 561 (eq (image-type data nil t) 'gif))
551 (setq image (create-animated-image data 'gif t))) 562 (setq image (create-animated-image data 'gif t
563 :ascent 100)))
552 image))) 564 image)))
553 565
554;; url-cache-extract autoloads url-cache. 566;; url-cache-extract autoloads url-cache.
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 0f96f7905eb..972c65f62e3 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -26,11 +26,15 @@
26;; internal use only. 26;; internal use only.
27 27
28;; Functional completion tables have an extended calling conventions: 28;; Functional completion tables have an extended calling conventions:
29;; - The `action' can be (additionally to nil, t, and lambda) of the form 29;; The `action' can be (additionally to nil, t, and lambda) of the form
30;; (boundaries . SUFFIX) in which case it should return 30;; - (boundaries . SUFFIX) in which case it should return
31;; (boundaries START . END). See `completion-boundaries'. 31;; (boundaries START . END). See `completion-boundaries'.
32;; Any other return value should be ignored (so we ignore values returned 32;; Any other return value should be ignored (so we ignore values returned
33;; from completion tables that don't know about this new `action' form). 33;; from completion tables that don't know about this new `action' form).
34;; - `metadata' in which case it should return (metadata . ALIST) where
35;; ALIST is the metadata of this table. See `completion-metadata'.
36;; Any other return value should be ignored (so we ignore values returned
37;; from completion tables that don't know about this new `action' form).
34 38
35;;; Bugs: 39;;; Bugs:
36 40
@@ -107,7 +111,8 @@ E.g. for simple completion tables, the result is always (0 . (length SUFFIX))
107and for file names the result is the positions delimited by 111and for file names the result is the positions delimited by
108the closest directory separators." 112the closest directory separators."
109 (let ((boundaries (if (functionp table) 113 (let ((boundaries (if (functionp table)
110 (funcall table string pred (cons 'boundaries suffix))))) 114 (funcall table string pred
115 (cons 'boundaries suffix)))))
111 (if (not (eq (car-safe boundaries) 'boundaries)) 116 (if (not (eq (car-safe boundaries) 'boundaries))
112 (setq boundaries nil)) 117 (setq boundaries nil))
113 (cons (or (cadr boundaries) 0) 118 (cons (or (cadr boundaries) 0)
@@ -125,7 +130,8 @@ This metadata is an alist. Currently understood keys are:
125 Takes one argument (COMPLETIONS) and should return a new list 130 Takes one argument (COMPLETIONS) and should return a new list
126 of completions. Can operate destructively. 131 of completions. Can operate destructively.
127- `cycle-sort-function': function to sort entries when cycling. 132- `cycle-sort-function': function to sort entries when cycling.
128 Works like `display-sort-function'." 133 Works like `display-sort-function'.
134The metadata of a completion table should be constant between two boundaries."
129 (let ((metadata (if (functionp table) 135 (let ((metadata (if (functionp table)
130 (funcall table string pred 'metadata)))) 136 (funcall table string pred 'metadata))))
131 (if (eq (car-safe metadata) 'metadata) 137 (if (eq (car-safe metadata) 'metadata)
@@ -160,8 +166,8 @@ PRED is a completion predicate.
160ACTION can be one of nil, t or `lambda'." 166ACTION can be one of nil, t or `lambda'."
161 (cond 167 (cond
162 ((functionp table) (funcall table string pred action)) 168 ((functionp table) (funcall table string pred action))
163 ((eq (car-safe action) 'boundaries) 169 ((eq (car-safe action) 'boundaries) nil)
164 (cons 'boundaries (completion-boundaries string table pred (cdr action)))) 170 ((eq action 'metadata) nil)
165 (t 171 (t
166 (funcall 172 (funcall
167 (cond 173 (cond
@@ -182,7 +188,7 @@ The result of the `completion-table-dynamic' form is a function
182that can be used as the COLLECTION argument to `try-completion' and 188that can be used as the COLLECTION argument to `try-completion' and
183`all-completions'. See Info node `(elisp)Programmed Completion'." 189`all-completions'. See Info node `(elisp)Programmed Completion'."
184 (lambda (string pred action) 190 (lambda (string pred action)
185 (if (eq (car-safe action) 'boundaries) 191 (if (or (eq (car-safe action) 'boundaries) (eq action 'metadata))
186 ;; `fun' is not supposed to return another function but a plain old 192 ;; `fun' is not supposed to return another function but a plain old
187 ;; completion table, whose boundaries are always trivial. 193 ;; completion table, whose boundaries are always trivial.
188 nil 194 nil
@@ -287,18 +293,18 @@ instead of a string, a function that takes the completion and returns the
287 (funcall terminator comp) 293 (funcall terminator comp)
288 (concat comp terminator)) 294 (concat comp terminator))
289 comp)))) 295 comp))))
290 ((eq action t) 296 ;; completion-table-with-terminator is always used for
297 ;; "sub-completions" so it's only called if the terminator is missing,
298 ;; in which case `test-completion' should return nil.
299 ((eq action 'lambda) nil)
300 (t
291 ;; FIXME: We generally want the `try' and `all' behaviors to be 301 ;; FIXME: We generally want the `try' and `all' behaviors to be
292 ;; consistent so pcm can merge the `all' output to get the `try' output, 302 ;; consistent so pcm can merge the `all' output to get the `try' output,
293 ;; but that sometimes clashes with the need for `all' output to look 303 ;; but that sometimes clashes with the need for `all' output to look
294 ;; good in *Completions*. 304 ;; good in *Completions*.
295 ;; (mapcar (lambda (s) (concat s terminator)) 305 ;; (mapcar (lambda (s) (concat s terminator))
296 ;; (all-completions string table pred)))) 306 ;; (all-completions string table pred))))
297 (all-completions string table pred)) 307 (complete-with-action action table string pred))))
298 ;; completion-table-with-terminator is always used for
299 ;; "sub-completions" so it's only called if the terminator is missing,
300 ;; in which case `test-completion' should return nil.
301 ((eq action 'lambda) nil)))
302 308
303(defun completion-table-with-predicate (table pred1 strict string pred2 action) 309(defun completion-table-with-predicate (table pred1 strict string pred2 action)
304 "Make a completion table equivalent to TABLE but filtered through PRED1. 310 "Make a completion table equivalent to TABLE but filtered through PRED1.
@@ -769,22 +775,33 @@ scroll the window of possible completions."
769 (setq completion-cycling nil) 775 (setq completion-cycling nil)
770 (setq completion-all-sorted-completions nil)) 776 (setq completion-all-sorted-completions nil))
771 777
778(defun completion--metadata (string base md-at-point table pred)
779 ;; Like completion-metadata, but for the specific case of getting the
780 ;; metadata at `base', which tends to trigger pathological behavior for old
781 ;; completion tables which don't understand `metadata'.
782 (let ((bounds (completion-boundaries string table pred "")))
783 (if (eq (car bounds) base) md-at-point
784 (completion-metadata (substring string 0 base) table pred))))
785
772(defun completion-all-sorted-completions () 786(defun completion-all-sorted-completions ()
773 (or completion-all-sorted-completions 787 (or completion-all-sorted-completions
774 (let* ((start (field-beginning)) 788 (let* ((start (field-beginning))
775 (end (field-end)) 789 (end (field-end))
776 (string (buffer-substring start end)) 790 (string (buffer-substring start end))
791 (md (completion--field-metadata start))
777 (all (completion-all-completions 792 (all (completion-all-completions
778 string 793 string
779 minibuffer-completion-table 794 minibuffer-completion-table
780 minibuffer-completion-predicate 795 minibuffer-completion-predicate
781 (- (point) start) 796 (- (point) start)
782 (completion--field-metadata start))) 797 md))
783 (last (last all)) 798 (last (last all))
784 (base-size (or (cdr last) 0)) 799 (base-size (or (cdr last) 0))
785 (all-md (completion-metadata (substring string 0 base-size) 800 (all-md (completion--metadata (buffer-substring-no-properties
786 minibuffer-completion-table 801 start (point))
787 minibuffer-completion-predicate)) 802 base-size md
803 minibuffer-completion-table
804 minibuffer-completion-predicate))
788 (sort-fun (completion-metadata-get all-md 'cycle-sort-function))) 805 (sort-fun (completion-metadata-get all-md 'cycle-sort-function)))
789 (when last 806 (when last
790 (setcdr last nil) 807 (setcdr last nil)
@@ -1272,12 +1289,13 @@ variables.")
1272 (let* ((start (field-beginning)) 1289 (let* ((start (field-beginning))
1273 (end (field-end)) 1290 (end (field-end))
1274 (string (field-string)) 1291 (string (field-string))
1292 (md (completion--field-metadata start))
1275 (completions (completion-all-completions 1293 (completions (completion-all-completions
1276 string 1294 string
1277 minibuffer-completion-table 1295 minibuffer-completion-table
1278 minibuffer-completion-predicate 1296 minibuffer-completion-predicate
1279 (- (point) (field-beginning)) 1297 (- (point) (field-beginning))
1280 (completion--field-metadata start)))) 1298 md)))
1281 (message nil) 1299 (message nil)
1282 (if (or (null completions) 1300 (if (or (null completions)
1283 (and (not (consp (cdr completions))) 1301 (and (not (consp (cdr completions)))
@@ -1293,12 +1311,11 @@ variables.")
1293 (let* ((last (last completions)) 1311 (let* ((last (last completions))
1294 (base-size (cdr last)) 1312 (base-size (cdr last))
1295 (prefix (unless (zerop base-size) (substring string 0 base-size))) 1313 (prefix (unless (zerop base-size) (substring string 0 base-size)))
1296 ;; FIXME: This function is for the output of all-completions, 1314 (all-md (completion--metadata (buffer-substring-no-properties
1297 ;; not completion-all-completions. Often it's the same, but 1315 start (point))
1298 ;; not always. 1316 base-size md
1299 (all-md (completion-metadata (substring string 0 base-size) 1317 minibuffer-completion-table
1300 minibuffer-completion-table 1318 minibuffer-completion-predicate))
1301 minibuffer-completion-predicate))
1302 (afun (or (completion-metadata-get all-md 'annotation-function) 1319 (afun (or (completion-metadata-get all-md 'annotation-function)
1303 (plist-get completion-extra-properties 1320 (plist-get completion-extra-properties
1304 :annotation-function) 1321 :annotation-function)
@@ -1673,8 +1690,8 @@ same as `substitute-in-file-name'."
1673 ;; other table that provides the "main" completion. Let the 1690 ;; other table that provides the "main" completion. Let the
1674 ;; other table handle the test-completion case. 1691 ;; other table handle the test-completion case.
1675 nil) 1692 nil)
1676 ((eq (car-safe action) 'boundaries) 1693 ((or (eq (car-safe action) 'boundaries) (eq action 'metadata))
1677 ;; Only return boundaries if there's something to complete, 1694 ;; Only return boundaries/metadata if there's something to complete,
1678 ;; since otherwise when we're used in 1695 ;; since otherwise when we're used in
1679 ;; completion-table-in-turn, we could return boundaries and 1696 ;; completion-table-in-turn, we could return boundaries and
1680 ;; let some subsequent table return a list of completions. 1697 ;; let some subsequent table return a list of completions.
@@ -1684,11 +1701,13 @@ same as `substitute-in-file-name'."
1684 (when (try-completion (substring string beg) table nil) 1701 (when (try-completion (substring string beg) table nil)
1685 ;; Compute the boundaries of the subfield to which this 1702 ;; Compute the boundaries of the subfield to which this
1686 ;; completion applies. 1703 ;; completion applies.
1687 (let ((suffix (cdr action))) 1704 (if (eq action 'metadata)
1688 (list* 'boundaries 1705 '(metadata (category . environment-variable))
1689 (or (match-beginning 2) (match-beginning 1)) 1706 (let ((suffix (cdr action)))
1690 (when (string-match "[^[:alnum:]_]" suffix) 1707 (list* 'boundaries
1691 (match-beginning 0)))))) 1708 (or (match-beginning 2) (match-beginning 1))
1709 (when (string-match "[^[:alnum:]_]" suffix)
1710 (match-beginning 0)))))))
1692 (t 1711 (t
1693 (if (eq (aref string (1- beg)) ?{) 1712 (if (eq (aref string (1- beg)) ?{)
1694 (setq table (apply-partially 'completion-table-with-terminator 1713 (setq table (apply-partially 'completion-table-with-terminator
@@ -2299,7 +2318,8 @@ PATTERN is as returned by `completion-pcm--string->pattern'."
2299 (case-fold-search completion-ignore-case) 2318 (case-fold-search completion-ignore-case)
2300 (completion-regexp-list (cons regex completion-regexp-list)) 2319 (completion-regexp-list (cons regex completion-regexp-list))
2301 (compl (all-completions 2320 (compl (all-completions
2302 (concat prefix (if (stringp (car pattern)) (car pattern) "")) 2321 (concat prefix
2322 (if (stringp (car pattern)) (car pattern) ""))
2303 table pred))) 2323 table pred)))
2304 (if (not (functionp table)) 2324 (if (not (functionp table))
2305 ;; The internal functions already obeyed completion-regexp-list. 2325 ;; The internal functions already obeyed completion-regexp-list.
@@ -2397,13 +2417,14 @@ filter out additional entries (because TABLE migth not obey PRED)."
2397 (- (length newbeforepoint) 2417 (- (length newbeforepoint)
2398 (car newbounds))))) 2418 (car newbounds)))))
2399 (dolist (submatch suball) 2419 (dolist (submatch suball)
2400 (setq all (nconc (mapcar 2420 (setq all (nconc
2401 (lambda (s) (concat submatch between s)) 2421 (mapcar
2402 (funcall filter 2422 (lambda (s) (concat submatch between s))
2403 (completion-pcm--all-completions 2423 (funcall filter
2404 (concat subprefix submatch between) 2424 (completion-pcm--all-completions
2405 pattern table pred))) 2425 (concat subprefix submatch between)
2406 all))) 2426 pattern table pred)))
2427 all)))
2407 ;; FIXME: This can come in handy for try-completion, 2428 ;; FIXME: This can come in handy for try-completion,
2408 ;; but isn't right for all-completions, since it lists 2429 ;; but isn't right for all-completions, since it lists
2409 ;; invalid completions. 2430 ;; invalid completions.
diff --git a/lisp/subr.el b/lisp/subr.el
index 4fe9987b95b..08099dc1fdd 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1805,6 +1805,13 @@ Signal an error if the program returns with a non-zero exit status."
1805 (forward-line 1)) 1805 (forward-line 1))
1806 (nreverse lines))))) 1806 (nreverse lines)))))
1807 1807
1808(defun process-alive-p (process)
1809 "Returns non-nil if PROCESS is alive.
1810A process is considered alive if its status is `run', `open',
1811`listen', `connect' or `stop'."
1812 (memq (process-status process)
1813 '(run open listen connect stop)))
1814
1808;; compatibility 1815;; compatibility
1809 1816
1810(make-obsolete 1817(make-obsolete
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 37a9fb8ffe2..1f2784fe656 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,12 @@
12011-05-31 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * url-queue.el (url-queue-parallel-processes): Increase the
4 default to 6, since 2 seems too conservative for normal usage.
5
62011-05-31 Teodor Zlatanov <tzz@lifelogs.com>
7
8 * url-future.el: Add general futures facility.
9
12011-05-29 Leo Liu <sdl.web@gmail.com> 102011-05-29 Leo Liu <sdl.web@gmail.com>
2 11
3 * url-cookie.el (url-cookie): Add option :named so that 12 * url-cookie.el (url-cookie): Add option :named so that
diff --git a/lisp/url/url-future.el b/lisp/url/url-future.el
new file mode 100644
index 00000000000..334c4fa9126
--- /dev/null
+++ b/lisp/url/url-future.el
@@ -0,0 +1,126 @@
1;;; url-future.el --- general futures facility for url.el
2
3;; Copyright (C) 2011 Free Software Foundation, Inc.
4
5;; Author: Teodor Zlatanov <tzz@lifelogs.com>
6;; Keywords: data
7
8;; This file is part of GNU Emacs.
9;;
10;; GNU Emacs is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22
23;;; Commentary:
24
25;; Make a url-future (basically a defstruct):
26;; (make-url-future :value (lambda () (calculation goes here))
27;; :callback (lambda (future) (use future on success))
28;; :errorback (lambda (future &rest error) (error handler)))
29
30;; Then either call it with `url-future-call' or cancel it with
31;; `url-future-cancel'. Generally the functions will return the
32;; future itself, not the value it holds. Also the functions will
33;; throw a url-future-already-done error if you try to call or cancel
34;; a future more than once.
35
36;; So, to get the value:
37;; (when (url-future-completed-p future) (url-future-value future))
38
39;; See the ERT tests and the code for futher details.
40
41;;; Code:
42
43(eval-when-compile (require 'cl))
44(eval-when-compile (require 'ert))
45
46(defstruct url-future callback errorback status value)
47
48(defmacro url-future-done-p (url-future)
49 `(url-future-status ,url-future))
50
51(defmacro url-future-completed-p (url-future)
52 `(eq (url-future-status ,url-future) t))
53
54(defmacro url-future-errored-p (url-future)
55 `(eq (url-future-status ,url-future) 'error))
56
57(defmacro url-future-cancelled-p (url-future)
58 `(eq (url-future-status ,url-future) 'cancel))
59
60(defun url-future-finish (url-future &optional status)
61 (if (url-future-done-p url-future)
62 (signal 'error 'url-future-already-done)
63 (setf (url-future-status url-future) (or status t))
64 ;; the status must be such that the future was completed
65 ;; to run the callback
66 (when (url-future-completed-p url-future)
67 (funcall (or (url-future-callback url-future) 'ignore)
68 url-future))
69 url-future))
70
71(defun url-future-errored (url-future errorcons)
72 (if (url-future-done-p url-future)
73 (signal 'error 'url-future-already-done)
74 (setf (url-future-status url-future) 'error)
75 (setf (url-future-value url-future) errorcons)
76 (funcall (or (url-future-errorback url-future) 'ignore)
77 url-future errorcons)))
78
79(defun url-future-call (url-future)
80 (if (url-future-done-p url-future)
81 (signal 'error 'url-future-already-done)
82 (let ((ff (url-future-value url-future)))
83 (when (functionp ff)
84 (condition-case catcher
85 (setf (url-future-value url-future)
86 (funcall ff))
87 (error (url-future-errored url-future catcher)))
88 (url-future-value url-future)))
89 (if (url-future-errored-p url-future)
90 url-future
91 (url-future-finish url-future))))
92
93(defun url-future-cancel (url-future)
94 (if (url-future-done-p url-future)
95 (signal 'error 'url-future-already-done)
96 (url-future-finish url-future 'cancel)))
97
98(ert-deftest url-future-test ()
99 (let* ((text "running future")
100 (good (make-url-future :value (lambda () (format text))
101 :callback (lambda (f) (set 'saver f))))
102 (bad (make-url-future :value (lambda () (/ 1 0))
103 :errorback (lambda (&rest d) (set 'saver d))))
104 (tocancel (make-url-future :value (lambda () (/ 1 0))
105 :callback (lambda (f) (set 'saver f))
106 :errorback (lambda (&rest d)
107 (set 'saver d))))
108 saver)
109 (should (equal good (url-future-call good)))
110 (should (equal good saver))
111 (should (equal text (url-future-value good)))
112 (should (url-future-completed-p good))
113 (should-error (url-future-call good))
114 (setq saver nil)
115 (should (equal bad (url-future-call bad)))
116 (should-error (url-future-call bad))
117 (should (equal saver (list bad '(arith-error))))
118 (should (url-future-errored-p bad))
119 (setq saver nil)
120 (should (equal (url-future-cancel tocancel) tocancel))
121 (should-error (url-future-call tocancel))
122 (should (null saver))
123 (should (url-future-cancelled-p tocancel))))
124
125(provide 'url-future)
126;;; url-future.el ends here
diff --git a/lisp/url/url-queue.el b/lisp/url/url-queue.el
index 08496ad5afb..e6c8537c469 100644
--- a/lisp/url/url-queue.el
+++ b/lisp/url/url-queue.el
@@ -31,7 +31,7 @@
31(eval-when-compile (require 'cl)) 31(eval-when-compile (require 'cl))
32(require 'browse-url) 32(require 'browse-url)
33 33
34(defcustom url-queue-parallel-processes 2 34(defcustom url-queue-parallel-processes 6
35 "The number of concurrent processes." 35 "The number of concurrent processes."
36 :type 'integer 36 :type 'integer
37 :group 'url) 37 :group 'url)