On Sun, Oct 23 2005, Ben Wing wrote:

>>>>>>>>"Reiner" == Reiner Steib <[EMAIL PROTECTED]> writes:
>>>    > Arne Jørgensen wrote improved completing support for inserting
>>>    > stuff like "\usepackage[bar,baz,zab]{foo}" in AUCTeX.  The
>>>    > function needs `completing-read-multiple' from `crm.el'[1] which
>>>    > is available in Emacs 21 and Emacs 22 (CVS[2]), but not in
>>>    > XEmacs.
>>>
>>>    > We found that `riece.el'[3] which is available as an XEmacs
>>>    > package seems to duplicate some code from `crm.el' for XEmacs.
>>>
>>>    > Wouldn't it make much more sense to include `crm.el' in
>>>    > `xemacs-base', some utility package or distribute it as a
>>>    > separate package instead of duplicating it's code in several
>>>    > packages?
[...]
> i think this sounds great.  probably crm.el should go in edit-utils.  
> does this need to be ported or does it work already under xemacs?

Thank you for your response.  I've done some testing with XEmacs
21.4.15:

`crm.el' from Emacs 21 (21.3 or 21.4) works without any modifications
in XEmacs.  The version from Emacs 22 (CVS) uses the function
`minibuffer-prompt-end' (a `diff -w -u' of those versions is
attached), a built-in function in Emacs 22, not present in XEmacs.

AfAICS, it would be sufficient if you'd include the Emacs 21 version
of `crm.el' in edit-utils.  [My understanding is, that XEmacs users
(regardless whether they use a recent XEmacs 21.4 or XEmacs 21.5)
would then just need to upgrade the edit-utils package to get this.
Please CMIIW.]

It would be great if you could include `crm.el' in the next packages
updates.  TIA.


In case you consider to use the Emacs 22 version, here's some
additional information.  I don't know if XEmacs has similar functions
that could be used:

,----[ <f1> f minibuffer-prompt-end RET ]
| minibuffer-prompt-end is a built-in function in `C source code'.
| (minibuffer-prompt-end)
| 
| Return the buffer position of the end of the minibuffer prompt.
| Return (point-min) if current buffer is not a minibuffer.
`----

In Emacs 21, `minibuffer-prompt-end' is defined in `simple.el':

,----
| (defun minibuffer-prompt-end ()
|   "Return the buffer position of the end of the minibuffer prompt.
| Return (point-min) if current buffer is not a mini-buffer."
|   (field-beginning (point-max)))
`----

,----[ <f1> f field-beginning RET ]
| field-beginning is a built-in function.
| (field-beginning &optional POS ESCAPE-FROM-EDGE)
| 
| Return the beginning of the field surrounding POS.
| A field is a region of text with the same `field' property.
| If POS is nil, the value of point is used for POS.
| If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its
| field, then the beginning of the *previous* field is returned.
`----

HTH.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/
--- emacs/21.3/lisp/emacs-lisp/crm.el	2000-04-27 21:00:09.000000000 +0200
+++ emacs/22.0.50/lisp/emacs-lisp/crm.el	2005-08-25 14:38:38.000000000 +0200
@@ -1,7 +1,7 @@
 ;;; crm.el --- read multiple strings with completion
 
-;; Copyright (C) 1985, 1986, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
-;;       Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+;;   2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Sen Nagata <[EMAIL PROTECTED]>
 ;; Keywords: completion, minibuffer, multiple elements
@@ -20,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -41,7 +41,7 @@
 ;; `crm-default-separator' (comma).  The separator character may be
 ;; changed by modifying the value of `crm-separator'.
 
-;; Continguous strings of non-separator-characters are referred to as
+;; Contiguous strings of non-separator-characters are referred to as
 ;; 'elements'.  In the aforementioned example, the elements are:
 ;; 'alice', 'bob', and 'eve'.
 
@@ -197,9 +197,10 @@
    respectively,
 
 and return t."
-  (let* ((minibuffer-string (buffer-string))
-	 (end-index (or (string-match "," minibuffer-string (1- (point)))
-			(1- (point-max))))
+  (let* ((prompt-end (minibuffer-prompt-end))
+	 (minibuffer-string (buffer-substring prompt-end (point-max)))
+	 (end-index (or (string-match "," minibuffer-string (- (point) prompt-end))
+			(- (point-max) prompt-end)))
 	 (target-string (substring minibuffer-string 0 end-index))
 	 (index (or (string-match
 		     (concat crm-separator "\\([^" crm-separator "]*\\)$")
@@ -213,9 +214,10 @@
       (progn
 	;; 
 	(setq crm-beginning-of-element (match-beginning 1))
-	(setq crm-end-of-element end-index)
+	(setq crm-end-of-element (+ end-index prompt-end))
 	;; string to the left of the current element
-	(setq crm-left-of-element (substring target-string 0 (match-beginning 1)))
+	(setq crm-left-of-element
+	      (substring target-string 0 (match-beginning 1)))
 	;; the current element
 	(setq crm-current-element (match-string 1 target-string))
 	;; string to the right of the current element
@@ -287,7 +289,7 @@
 	
 	(if completedp
 	    (progn
-	      (erase-buffer)
+	      (delete-region (minibuffer-prompt-end) (point-max))
 	      (insert crm-left-of-element completion)
 	      ;;		(if crm-complete-up-to-point
 	      ;;		    (insert crm-separator))
@@ -480,7 +482,7 @@
       (setq result
 	    (catch 'crm-exit
 	      
-	      (if (eq (point-min) (point-max))
+	      (if (eq (minibuffer-prompt-end) (point-max))
 		  (throw 'crm-exit t))
 	      
 	      ;; TODO: this test is suspect?
@@ -506,7 +508,8 @@
 	  nil
 	(if (equal result "check")
 	    (let ((check-strings
-		   (crm-strings-completed-p (buffer-string))))
+		   (crm-strings-completed-p
+		    (buffer-substring (minibuffer-prompt-end) (point-max)))))
 	      ;; check all of minibuffer
 	      (if (eq check-strings t)
 		  (throw 'exit nil)
@@ -529,7 +532,7 @@
 The only difference is that TAB is bound to `crm-minibuffer-complete' in
 the inheriting keymap.
 
-If REQUIRE-MACTH is non-nil, the keymap `crm-local-must-match-map' is used.
+If REQUIRE-MATCH is non-nil, the keymap `crm-local-must-match-map' is used.
 This keymap inherits from the keymap named `minibuffer-local-must-match-map'.
 The inheriting keymap binds RET to `crm-minibuffer-complete-and-exit'
 and TAB to `crm-minibuffer-complete'."
@@ -574,7 +577,7 @@
 `crm-default-separator' (comma).  The separator character may be
 changed by modifying the value of `crm-separator'.
 
-Continguous strings of non-separator-characters are referred to as
+Contiguous strings of non-separator-characters are referred to as
 'elements'.  In the aforementioned example, the elements are: 'alice',
 'bob', and 'eve'.
 
@@ -590,9 +593,8 @@
   (let ((minibuffer-completion-table (function crm-collection-fn))
 	(minibuffer-completion-predicate predicate)
 	;; see completing_read in src/minibuf.c
-	(minibuffer-completion-confirm (if (eq require-match t)
-					   nil
-					 t))
+	(minibuffer-completion-confirm
+	 (unless (eq require-match t) require-match))
 	(crm-completion-table table)
 	crm-last-exact-completion
 	crm-current-element
@@ -600,30 +602,27 @@
 	crm-right-of-element
 	crm-beginning-of-element
 	crm-end-of-element
-	map)
-    (if require-match
-	;; use `crm-local-must-match-map'
-	(setq map crm-local-must-match-map)
-      ;; use `minibuffer-local-completion-map'
-      (setq map minibuffer-local-completion-map))
+	(map (if require-match
+		 crm-local-must-match-map
+	       crm-local-completion-map)))
     (split-string (read-from-minibuffer
 		   prompt initial-input map
 		   nil hist def inherit-input-method)
 		  crm-separator)))
 
 ;; testing and debugging
-;;; (defun crm-init-test-environ ()
-;;;   "Set up some variables for testing."
-;;;   (interactive)
-;;;   (setq my-prompt "Prompt: ")
-;;;   (setq my-table
-;;; 	'(("hi") ("there") ("man") ("may") ("mouth") ("ma")
-;;; 	  ("a") ("ab") ("abc") ("abd") ("abf") ("zab") ("acb")
-;;; 	  ("da") ("dab") ("dabc") ("dabd") ("dabf") ("dzab") ("dacb")
-;;; 	  ("fda") ("fdab") ("fdabc") ("fdabd") ("fdabf") ("fdzab") ("fdacb")
-;;; 	  ("gda") ("gdab") ("gdabc") ("gdabd") ("gdabf") ("gdzab") ("gdacb")
-;;; 	  ))
-;;;   (setq my-separator ","))
+;; (defun crm-init-test-environ ()
+;;   "Set up some variables for testing."
+;;   (interactive)
+;;   (setq my-prompt "Prompt: ")
+;;   (setq my-table
+;; 	'(("hi") ("there") ("man") ("may") ("mouth") ("ma")
+;; 	  ("a") ("ab") ("abc") ("abd") ("abf") ("zab") ("acb")
+;; 	  ("da") ("dab") ("dabc") ("dabd") ("dabf") ("dzab") ("dacb")
+;; 	  ("fda") ("fdab") ("fdabc") ("fdabd") ("fdabf") ("fdzab") ("fdacb")
+;; 	  ("gda") ("gdab") ("gdabc") ("gdabd") ("gdabf") ("gdzab") ("gdacb")
+;; 	  ))
+;;   (setq my-separator ","))
 
 ;(completing-read-multiple my-prompt my-table)
 ;(completing-read-multiple my-prompt my-table nil t)
@@ -633,4 +632,5 @@
 
 (provide 'crm)
 
+;;; arch-tag: db1911d9-86c6-4a42-b32a-4910701b15a6
 ;;; crm.el ends here
_______________________________________________
auctex-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to