diff options
| author | Stefan Monnier | 2008-05-23 01:58:15 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-05-23 01:58:15 +0000 |
| commit | f838180339b8d2cfb11919366a358f204cf0ca8f (patch) | |
| tree | 3909821aa3e1fbb28de41a07021da89c50648f30 | |
| parent | 019e13ef750fcf6532da1e9a019036eea94e38a8 (diff) | |
| download | emacs-f838180339b8d2cfb11919366a358f204cf0ca8f.tar.gz emacs-f838180339b8d2cfb11919366a358f204cf0ca8f.zip | |
* minibuffer.el (completion-boundaries): Change calling convention, so
`string' has the same semantics as in try-completion and all-completions.
(completion-table-with-context, completion--embedded-envvar-table)
(completion--file-name-table, completion-pcm--find-all-completions):
Adjust code accordingly.
* vc-bzr.el (vc-bzr-annotate-time): Reduce memory allocation.
(vc-bzr-revision-completion-table): Handle `boundaries' argument.
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 91 | ||||
| -rw-r--r-- | lisp/vc-bzr.el | 22 |
3 files changed, 74 insertions, 50 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 86781502425..e2657926e99 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2008-05-23 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * vc-bzr.el (vc-bzr-annotate-time): Reduce memory allocation. | ||
| 4 | (vc-bzr-revision-completion-table): Handle `boundaries' argument. | ||
| 5 | |||
| 6 | * minibuffer.el (completion-boundaries): Change calling convention, so | ||
| 7 | `string' has the same semantics as in try-completion and all-completions. | ||
| 8 | (completion-table-with-context, completion--embedded-envvar-table) | ||
| 9 | (completion--file-name-table, completion-pcm--find-all-completions): | ||
| 10 | Adjust code accordingly. | ||
| 11 | |||
| 1 | 2008-05-22 Chong Yidong <cyd@stupidchicken.com> | 12 | 2008-05-22 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 13 | ||
| 3 | * image-mode.el (image-mode-winprops): Add argument CLEANUP to | 14 | * image-mode.el (image-mode-winprops): Add argument CLEANUP to |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index f8d7a15a69f..f24d1b068be 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -28,7 +28,8 @@ | |||
| 28 | ;; - If completion-all-completions-with-base-size is set, then all-completions | 28 | ;; - If completion-all-completions-with-base-size is set, then all-completions |
| 29 | ;; should return the base-size in the last cdr. | 29 | ;; should return the base-size in the last cdr. |
| 30 | ;; - The `action' can be (additionally to nil, t, and lambda) of the form | 30 | ;; - The `action' can be (additionally to nil, t, and lambda) of the form |
| 31 | ;; (boundaries . POS) in which case it should return (boundaries START . END). | 31 | ;; (boundaries . SUFFIX) in which case it should return |
| 32 | ;; (boundaries START . END). See `completion-boundaries'. | ||
| 32 | ;; Any other return value should be ignored (so we ignore values returned | 33 | ;; 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). | 34 | ;; from completion tables that don't know about this new `action' form). |
| 34 | ;; See `completion-boundaries'. | 35 | ;; See `completion-boundaries'. |
| @@ -64,23 +65,23 @@ element in the returned list of completions. See `completion-base-size'.") | |||
| 64 | ;;; Completion table manipulation | 65 | ;;; Completion table manipulation |
| 65 | 66 | ||
| 66 | ;; New completion-table operation. | 67 | ;; New completion-table operation. |
| 67 | (defun completion-boundaries (string table pred pos) | 68 | (defun completion-boundaries (string table pred suffix) |
| 68 | "Return the boundaries of the completions returned by TABLE at POS. | 69 | "Return the boundaries of the completions returned by TABLE for STRING. |
| 69 | STRING is the string on which completion will be performed. | 70 | STRING is the string on which completion will be performed. |
| 70 | The result is of the form (START . END) and gives the start and end position | 71 | SUFFIX is the string after point. |
| 71 | corresponding to the substring of STRING that can be completed by one | 72 | The result is of the form (START . END) where START is the position |
| 72 | of the elements returned by | 73 | in STRING of the beginning of the completion field and END is the position |
| 73 | \(all-completions (substring STRING 0 POS) TABLE PRED). | 74 | in SUFFIX of the end of the completion field. |
| 74 | I.e. START is the same as the `completion-base-size'. | 75 | I.e. START is the same as the `completion-base-size'. |
| 75 | E.g. for simple completion tables, the result is always (0 . (length STRING)) | 76 | E.g. for simple completion tables, the result is always (0 . (length SUFFIX)) |
| 76 | and for file names the result is the substring around POS delimited by | 77 | and for file names the result is the positions delimited by |
| 77 | the closest directory separators." | 78 | the closest directory separators." |
| 78 | (let ((boundaries (if (functionp table) | 79 | (let ((boundaries (if (functionp table) |
| 79 | (funcall table string pred (cons 'boundaries pos))))) | 80 | (funcall table string pred (cons 'boundaries suffix))))) |
| 80 | (if (not (eq (car-safe boundaries) 'boundaries)) | 81 | (if (not (eq (car-safe boundaries) 'boundaries)) |
| 81 | (setq boundaries nil)) | 82 | (setq boundaries nil)) |
| 82 | (cons (or (cadr boundaries) 0) | 83 | (cons (or (cadr boundaries) 0) |
| 83 | (or (cddr boundaries) (length string))))) | 84 | (or (cddr boundaries) (length suffix))))) |
| 84 | 85 | ||
| 85 | (defun completion--some (fun xs) | 86 | (defun completion--some (fun xs) |
| 86 | "Apply FUN to each element of XS in turn. | 87 | "Apply FUN to each element of XS in turn. |
| @@ -177,9 +178,8 @@ You should give VAR a non-nil `risky-local-variable' property." | |||
| 177 | (funcall pred (concat prefix (if (consp s) (car s) s))))))))) | 178 | (funcall pred (concat prefix (if (consp s) (car s) s))))))))) |
| 178 | (if (eq (car-safe action) 'boundaries) | 179 | (if (eq (car-safe action) 'boundaries) |
| 179 | (let* ((len (length prefix)) | 180 | (let* ((len (length prefix)) |
| 180 | (bound (completion-boundaries string table pred | 181 | (bound (completion-boundaries string table pred (cdr action)))) |
| 181 | (- (cdr action) len)))) | 182 | (list* 'boundaries (+ (car bound) len) (cdr bound))) |
| 182 | (list* 'boundaries (+ (car bound) len) (+ (cdr bound) len))) | ||
| 183 | (let ((comp (complete-with-action action table string pred))) | 183 | (let ((comp (complete-with-action action table string pred))) |
| 184 | (cond | 184 | (cond |
| 185 | ;; In case of try-completion, add the prefix. | 185 | ;; In case of try-completion, add the prefix. |
| @@ -951,13 +951,12 @@ specified by COMMON-SUBSTRING." | |||
| 951 | (if (eq (car-safe action) 'boundaries) | 951 | (if (eq (car-safe action) 'boundaries) |
| 952 | ;; Compute the boundaries of the subfield to which this | 952 | ;; Compute the boundaries of the subfield to which this |
| 953 | ;; completion applies. | 953 | ;; completion applies. |
| 954 | (let* ((pos (cdr action)) | 954 | (let ((suffix (cdr action))) |
| 955 | (suffix (substring string pos))) | 955 | (if (string-match completion--embedded-envvar-re string) |
| 956 | (if (string-match completion--embedded-envvar-re | 956 | (list* 'boundaries |
| 957 | (substring string 0 pos)) | 957 | (or (match-beginning 2) (match-beginning 1)) |
| 958 | (list* 'boundaries (or (match-beginning 2) (match-beginning 1)) | ||
| 959 | (when (string-match "[^[:alnum:]_]" suffix) | 958 | (when (string-match "[^[:alnum:]_]" suffix) |
| 960 | (+ pos (match-beginning 0)))))) | 959 | (match-beginning 0))))) |
| 961 | (when (string-match completion--embedded-envvar-re string) | 960 | (when (string-match completion--embedded-envvar-re string) |
| 962 | (let* ((beg (or (match-beginning 2) (match-beginning 1))) | 961 | (let* ((beg (or (match-beginning 2) (match-beginning 1))) |
| 963 | (table (completion--make-envvar-table)) | 962 | (table (completion--make-envvar-table)) |
| @@ -976,9 +975,8 @@ specified by COMMON-SUBSTRING." | |||
| 976 | ((eq (car-safe action) 'boundaries) | 975 | ((eq (car-safe action) 'boundaries) |
| 977 | ;; FIXME: Actually, this is not always right in the presence of | 976 | ;; FIXME: Actually, this is not always right in the presence of |
| 978 | ;; envvars, but there's not much we can do, I think. | 977 | ;; envvars, but there's not much we can do, I think. |
| 979 | (let ((start (length (file-name-directory | 978 | (let ((start (length (file-name-directory string))) |
| 980 | (substring string 0 (cdr action))))) | 979 | (end (string-match "/" (cdr action)))) |
| 981 | (end (string-match "/" string (cdr action)))) | ||
| 982 | (list* 'boundaries start end))) | 980 | (list* 'boundaries start end))) |
| 983 | 981 | ||
| 984 | (t | 982 | (t |
| @@ -1414,14 +1412,15 @@ PATTERN is as returned by `completion-pcm--string->pattern'." | |||
| 1414 | base-size)))) | 1412 | base-size)))) |
| 1415 | 1413 | ||
| 1416 | (defun completion-pcm--find-all-completions (string table pred point) | 1414 | (defun completion-pcm--find-all-completions (string table pred point) |
| 1417 | (let* ((bounds (completion-boundaries string table pred point)) | 1415 | (let* ((beforepoint (substring string 0 point)) |
| 1418 | (prefix (substring string 0 (car bounds))) | 1416 | (afterpoint (substring string point)) |
| 1419 | (suffix (substring string (cdr bounds))) | 1417 | (bounds (completion-boundaries beforepoint table pred afterpoint)) |
| 1420 | (origstring string) | 1418 | (prefix (substring beforepoint 0 (car bounds))) |
| 1419 | (suffix (substring afterpoint (cdr bounds))) | ||
| 1421 | firsterror) | 1420 | firsterror) |
| 1422 | (setq string (substring string (car bounds) (cdr bounds))) | 1421 | (setq string (substring string (car bounds) (+ point (cdr bounds)))) |
| 1423 | (let* ((pattern (completion-pcm--string->pattern | 1422 | (let* ((relpoint (- point (car bounds))) |
| 1424 | string (- point (car bounds)))) | 1423 | (pattern (completion-pcm--string->pattern string relpoint)) |
| 1425 | (all (condition-case err | 1424 | (all (condition-case err |
| 1426 | (completion-pcm--all-completions prefix pattern table pred) | 1425 | (completion-pcm--all-completions prefix pattern table pred) |
| 1427 | (error (unless firsterror (setq firsterror err)) nil)))) | 1426 | (error (unless firsterror (setq firsterror err)) nil)))) |
| @@ -1446,28 +1445,30 @@ PATTERN is as returned by `completion-pcm--string->pattern'." | |||
| 1446 | ;; Update the boundaries and corresponding pattern. | 1445 | ;; Update the boundaries and corresponding pattern. |
| 1447 | ;; We assume that all submatches result in the same boundaries | 1446 | ;; We assume that all submatches result in the same boundaries |
| 1448 | ;; since we wouldn't know how to merge them otherwise anyway. | 1447 | ;; since we wouldn't know how to merge them otherwise anyway. |
| 1449 | (let* ((newstring (concat subprefix (car suball) string suffix)) | 1448 | ;; FIXME: COMPLETE REWRITE!!! |
| 1450 | (newpoint (+ point (- (length newstring) | 1449 | (let* ((newbeforepoint |
| 1451 | (length origstring)))) | 1450 | (concat subprefix (car suball) |
| 1451 | (substring string 0 relpoint))) | ||
| 1452 | (leftbound (+ (length subprefix) (length (car suball)))) | ||
| 1452 | (newbounds (completion-boundaries | 1453 | (newbounds (completion-boundaries |
| 1453 | newstring table pred newpoint)) | 1454 | newbeforepoint table pred afterpoint))) |
| 1454 | (newsubstring | 1455 | (unless (or (and (eq (cdr bounds) (cdr newbounds)) |
| 1455 | (substring newstring (car newbounds) (cdr newbounds)))) | 1456 | (eq (car newbounds) leftbound)) |
| 1456 | (unless (or (equal newsubstring string) | ||
| 1457 | ;; Refuse new boundaries if they step over | 1457 | ;; Refuse new boundaries if they step over |
| 1458 | ;; the submatch. | 1458 | ;; the submatch. |
| 1459 | (< (car newbounds) | 1459 | (< (car newbounds) leftbound)) |
| 1460 | (+ (length subprefix) (length (car suball))))) | ||
| 1461 | ;; The new completed prefix does change the boundaries | 1460 | ;; The new completed prefix does change the boundaries |
| 1462 | ;; of the completed substring. | 1461 | ;; of the completed substring. |
| 1463 | (setq suffix (substring newstring (cdr newbounds))) | 1462 | (setq suffix (substring afterpoint (cdr newbounds))) |
| 1464 | (setq string newsubstring) | 1463 | (setq string |
| 1465 | (setq between (substring newstring | 1464 | (concat (substring newbeforepoint (car newbounds)) |
| 1466 | (+ (length subprefix) | 1465 | (substring afterpoint 0 (cdr newbounds)))) |
| 1467 | (length (car suball))) | 1466 | (setq between (substring newbeforepoint leftbound |
| 1468 | (car newbounds))) | 1467 | (car newbounds))) |
| 1469 | (setq pattern (completion-pcm--string->pattern | 1468 | (setq pattern (completion-pcm--string->pattern |
| 1470 | string (- newpoint (car bounds))))) | 1469 | string |
| 1470 | (- (length newbeforepoint) | ||
| 1471 | (car newbounds))))) | ||
| 1471 | (dolist (submatch suball) | 1472 | (dolist (submatch suball) |
| 1472 | (setq all (nconc (mapcar | 1473 | (setq all (nconc (mapcar |
| 1473 | (lambda (s) (concat submatch between s)) | 1474 | (lambda (s) (concat submatch between s)) |
diff --git a/lisp/vc-bzr.el b/lisp/vc-bzr.el index d9f8a127f3a..a54cd7319f4 100644 --- a/lisp/vc-bzr.el +++ b/lisp/vc-bzr.el | |||
| @@ -538,12 +538,12 @@ property containing author and date information." | |||
| 538 | (when (re-search-forward "^ *[0-9.]+ +|" nil t) | 538 | (when (re-search-forward "^ *[0-9.]+ +|" nil t) |
| 539 | (let ((prop (get-text-property (line-beginning-position) 'help-echo))) | 539 | (let ((prop (get-text-property (line-beginning-position) 'help-echo))) |
| 540 | (string-match "[0-9]+\\'" prop) | 540 | (string-match "[0-9]+\\'" prop) |
| 541 | (let ((str (match-string-no-properties 0 prop))) | ||
| 541 | (vc-annotate-convert-time | 542 | (vc-annotate-convert-time |
| 542 | (encode-time 0 0 0 | 543 | (encode-time 0 0 0 |
| 543 | (string-to-number (substring (match-string 0 prop) 6 8)) | 544 | (string-to-number (substring str 6 8)) |
| 544 | (string-to-number (substring (match-string 0 prop) 4 6)) | 545 | (string-to-number (substring str 4 6)) |
| 545 | (string-to-number (substring (match-string 0 prop) 0 4)) | 546 | (string-to-number (substring str 0 4)))))))) |
| 546 | ))))) | ||
| 547 | 547 | ||
| 548 | (defun vc-bzr-annotate-extract-revision-at-line () | 548 | (defun vc-bzr-annotate-extract-revision-at-line () |
| 549 | "Return revision for current line of annoation buffer, or nil. | 549 | "Return revision for current line of annoation buffer, or nil. |
| @@ -580,8 +580,11 @@ stream. Standard error output is discarded." | |||
| 580 | (" M" . edited) | 580 | (" M" . edited) |
| 581 | ;; XXX: what about ignored files? | 581 | ;; XXX: what about ignored files? |
| 582 | (" D" . missing) | 582 | (" D" . missing) |
| 583 | ;; For conflicts, should we list the .THIS/.BASE/.OTHER? | ||
| 583 | ("C " . conflict) | 584 | ("C " . conflict) |
| 584 | ("? " . unregistered))) | 585 | ("? " . unregistered) |
| 586 | ;; Ignore "P " and "P." for pending patches. | ||
| 587 | )) | ||
| 585 | (translated nil) | 588 | (translated nil) |
| 586 | (result nil)) | 589 | (result nil)) |
| 587 | (goto-char (point-min)) | 590 | (goto-char (point-min)) |
| @@ -625,6 +628,8 @@ stream. Standard error output is discarded." | |||
| 625 | ((string-match "\\`\\(ancestor\\|branch\\|\\(revno:\\)?[-0-9]+:\\):" | 628 | ((string-match "\\`\\(ancestor\\|branch\\|\\(revno:\\)?[-0-9]+:\\):" |
| 626 | string) | 629 | string) |
| 627 | (completion-table-with-context (substring string 0 (match-end 0)) | 630 | (completion-table-with-context (substring string 0 (match-end 0)) |
| 631 | ;; FIXME: only allow directories. | ||
| 632 | ;; FIXME: don't allow envvars. | ||
| 628 | 'read-file-name-internal | 633 | 'read-file-name-internal |
| 629 | (substring string (match-end 0)) | 634 | (substring string (match-end 0)) |
| 630 | ;; Dropping `pred'. Maybe we should | 635 | ;; Dropping `pred'. Maybe we should |
| @@ -655,7 +660,14 @@ stream. Standard error output is discarded." | |||
| 655 | ((string-match "\\`\\(revid\\):" string) | 660 | ((string-match "\\`\\(revid\\):" string) |
| 656 | ;; FIXME: How can I get a list of revision ids? | 661 | ;; FIXME: How can I get a list of revision ids? |
| 657 | ) | 662 | ) |
| 663 | ((eq (car-safe action) 'boundaries) | ||
| 664 | (list* 'boundaries | ||
| 665 | (if (string-match ":" string) (1+ (match-beginning 0))) | ||
| 666 | (string-match ":" (cdr action)))) | ||
| 658 | (t | 667 | (t |
| 668 | ;; Could use completion-table-with-terminator, except that it | ||
| 669 | ;; currently doesn't work right w.r.t pcm and doesn't give | ||
| 670 | ;; the *Completions* output we want. | ||
| 659 | (complete-with-action action '("revno:" "revid:" "last:" "before:" | 671 | (complete-with-action action '("revno:" "revid:" "last:" "before:" |
| 660 | "tag:" "date:" "ancestor:" "branch:" | 672 | "tag:" "date:" "ancestor:" "branch:" |
| 661 | "submit:") | 673 | "submit:") |