85 |
;; -tip: use M-f and M-b for ease of navigation among elements. |
;; -tip: use M-f and M-b for ease of navigation among elements. |
86 |
|
|
87 |
;;; History: |
;;; History: |
88 |
;; |
;; |
89 |
;; 2000-04-10: |
;; 2000-04-10: |
90 |
;; |
;; |
91 |
;; first revamped version |
;; first revamped version |
211 |
;; no candidate found |
;; no candidate found |
212 |
nil |
nil |
213 |
(progn |
(progn |
214 |
;; |
;; |
215 |
(setq crm-beginning-of-element (match-beginning 1)) |
(setq crm-beginning-of-element (match-beginning 1)) |
216 |
(setq crm-end-of-element end-index) |
(setq crm-end-of-element end-index) |
217 |
;; string to the left of the current element |
;; string to the left of the current element |
226 |
"Return t if CANDIDATE is an exact match for a valid completion." |
"Return t if CANDIDATE is an exact match for a valid completion." |
227 |
(let ((completions |
(let ((completions |
228 |
;; TODO: verify whether the arguments are appropriate |
;; TODO: verify whether the arguments are appropriate |
229 |
(all-completions |
(all-completions |
230 |
candidate crm-completion-table minibuffer-completion-predicate))) |
candidate crm-completion-table minibuffer-completion-predicate))) |
231 |
(if (member candidate completions) |
(if (member candidate completions) |
232 |
t |
t |
271 |
minibuffer-completion-predicate)) |
minibuffer-completion-predicate)) |
272 |
(setq last crm-last-exact-completion) |
(setq last crm-last-exact-completion) |
273 |
(setq crm-last-exact-completion nil) |
(setq crm-last-exact-completion nil) |
274 |
|
|
275 |
(catch 'crm-exit |
(catch 'crm-exit |
276 |
|
|
277 |
(if (null completion) ; no possible completion |
(if (null completion) ; no possible completion |
278 |
(progn |
(progn |
279 |
(crm-temp-echo-area-glyphs " [No match]") |
(crm-temp-echo-area-glyphs " [No match]") |
280 |
(throw 'crm-exit 0))) |
(throw 'crm-exit 0))) |
281 |
|
|
282 |
(if (eq completion t) ; was already an exact and unique completion |
(if (eq completion t) ; was already an exact and unique completion |
283 |
(throw 'crm-exit 1)) |
(throw 'crm-exit 1)) |
284 |
|
|
285 |
(setq completedp |
(setq completedp |
286 |
(null (string-equal completion crm-current-element))) |
(null (string-equal completion crm-current-element))) |
287 |
|
|
288 |
(if completedp |
(if completedp |
289 |
(progn |
(progn |
290 |
(erase-buffer) |
(erase-buffer) |
295 |
(backward-char (length crm-right-of-element)) |
(backward-char (length crm-right-of-element)) |
296 |
;; TODO: is this correct? |
;; TODO: is this correct? |
297 |
(setq crm-current-element completion))) |
(setq crm-current-element completion))) |
298 |
|
|
299 |
(if (null (crm-test-completion crm-current-element)) |
(if (null (crm-test-completion crm-current-element)) |
300 |
(progn |
(progn |
301 |
(if completedp ; some completion happened |
(if completedp ; some completion happened |
306 |
(throw 'crm-exit 6)) |
(throw 'crm-exit 6)) |
307 |
(if completedp |
(if completedp |
308 |
(throw 'crm-exit 4))) |
(throw 'crm-exit 4))) |
309 |
|
|
310 |
(setq crm-last-exact-completion completion) |
(setq crm-last-exact-completion completion) |
311 |
(if (not (null last)) |
(if (not (null last)) |
312 |
(progn |
(progn |
313 |
(if (not (null (equal crm-current-element last))) |
(if (not (null (equal crm-current-element last))) |
314 |
(crm-minibuffer-completion-help)))) |
(crm-minibuffer-completion-help)))) |
315 |
|
|
316 |
;; returning -- was already an exact completion |
;; returning -- was already an exact completion |
317 |
(throw 'crm-exit 3))))) |
(throw 'crm-exit 3))))) |
318 |
|
|
472 |
|
|
473 |
This function is modeled after `minibuffer_complete_and_exit' in src/minibuf.c" |
This function is modeled after `minibuffer_complete_and_exit' in src/minibuf.c" |
474 |
(interactive) |
(interactive) |
475 |
|
|
476 |
(if (not (crm-find-current-element)) |
(if (not (crm-find-current-element)) |
477 |
nil |
nil |
478 |
(let (result) |
(let (result) |
479 |
|
|
480 |
(setq result |
(setq result |
481 |
(catch 'crm-exit |
(catch 'crm-exit |
482 |
|
|
483 |
(if (eq (point-min) (point-max)) |
(if (eq (point-min) (point-max)) |
484 |
(throw 'crm-exit t)) |
(throw 'crm-exit t)) |
485 |
|
|
486 |
;; TODO: this test is suspect? |
;; TODO: this test is suspect? |
487 |
(if (not (null (crm-test-completion crm-current-element))) |
(if (not (null (crm-test-completion crm-current-element))) |
488 |
(throw 'crm-exit "check")) |
(throw 'crm-exit "check")) |
489 |
|
|
490 |
;; TODO: determine how to detect errors |
;; TODO: determine how to detect errors |
491 |
(let ((result (crm-do-completion))) |
(let ((result (crm-do-completion))) |
492 |
|
|
493 |
(cond |
(cond |
494 |
((or (eq 1 result) |
((or (eq 1 result) |
495 |
(eq 3 result)) |
(eq 3 result)) |
501 |
nil) |
nil) |
502 |
(throw 'crm-exit "check"))) |
(throw 'crm-exit "check"))) |
503 |
(nil))))) |
(nil))))) |
504 |
|
|
505 |
(if (null result) |
(if (null result) |
506 |
nil |
nil |
507 |
(if (equal result "check") |
(if (equal result "check") |
541 |
(define-key crm-local-completion-map |
(define-key crm-local-completion-map |
542 |
(kbd "TAB") |
(kbd "TAB") |
543 |
(function crm-minibuffer-complete))) |
(function crm-minibuffer-complete))) |
544 |
|
|
545 |
(unless crm-local-must-match-map |
(unless crm-local-must-match-map |
546 |
(setq crm-local-must-match-map (make-sparse-keymap)) |
(setq crm-local-must-match-map (make-sparse-keymap)) |
547 |
(set-keymap-parent crm-local-must-match-map |
(set-keymap-parent crm-local-must-match-map |