[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/lisp/emacs-lisp crm.el
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] emacs/lisp/emacs-lisp crm.el |
Date: |
Mon, 16 Mar 2009 00:44:03 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Chong Yidong <cyd> 09/03/16 00:44:03
Modified files:
lisp/emacs-lisp: crm.el
Log message:
(crm--choose-completion-string): New function.
(completing-read-multiple): Set and restore
choose-completion-string-functions (Bug#1080).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/emacs-lisp/crm.el?cvsroot=emacs&r1=1.21&r2=1.22
Patches:
Index: crm.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/crm.el,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- crm.el 5 Jan 2009 03:20:56 -0000 1.21
+++ crm.el 16 Mar 2009 00:44:02 -0000 1.22
@@ -228,6 +228,22 @@
(forward-char 1))
(if doexit (exit-minibuffer))))
+(defun crm--choose-completion-string (choice buffer mini-p base-size)
+ "Completion string chooser for `completing-read-multiple'.
+This is called from `choose-completion-string-functions'.
+It replaces the string that is currently being completed, without
+exiting the minibuffer."
+ (let ((ol (crm--select-current-element)))
+ (if base-size
+ (delete-region (+ base-size (field-beginning)) (point))
+ (choose-completion-delete-max-match choice))
+ (insert choice)
+ (remove-text-properties (- (point) (length choice)) (point)
+ '(mouse-face nil))
+ ;; Update point in the window that BUFFER is showing in.
+ (let ((window (get-buffer-window buffer t)))
+ (set-window-point window (point)))))
+
;; superemulates behavior of completing_read in src/minibuf.c
;;;###autoload
(defun completing-read-multiple
@@ -259,6 +275,10 @@
See the documentation for `completing-read' for details on the arguments:
PROMPT, TABLE, PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST, DEF, and
INHERIT-INPUT-METHOD."
+ (unwind-protect
+ (progn
+ (add-hook 'choose-completion-string-functions
+ 'crm--choose-completion-string)
(let* ((minibuffer-completion-table #'crm--collection-fn)
(minibuffer-completion-predicate predicate)
;; see completing_read in src/minibuf.c
@@ -275,6 +295,8 @@
nil hist def inherit-input-method)))
(and def (string-equal input "") (setq input def))
(split-string input crm-separator)))
+ (remove-hook 'choose-completion-string-functions
+ 'crm--choose-completion-string)))
(define-obsolete-function-alias 'crm-minibuffer-complete 'crm-complete "23.1")
(define-obsolete-function-alias
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs/lisp/emacs-lisp crm.el,
Chong Yidong <=