From xemacs-m  Fri Jan 31 16:47:29 1997
Received: from altair.xemacs.org (steve@xemacs.miranova.com [206.190.83.19])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id QAA15262
	for <xemacs-beta@xemacs.org>; Fri, 31 Jan 1997 16:47:29 -0600 (CST)
Received: (from steve@localhost)
	by altair.xemacs.org (8.8.5/8.8.5) id OAA11419;
	Fri, 31 Jan 1997 14:58:38 -0800
To: repayne@jeeves.net
Cc: xemacs-beta@xemacs.org
Subject: Re: No Meta Key under Linux, other key-mapping, syntax problems
References: <199701311539.JAA17492@apollo.jeeves.net>
X-Url: http://www.miranova.com/%7Esteve/
Mail-Copies-To: never
X-Face: #!T9!#9s-3o8)*uHlX{Ug[xW7E7Wr!*L46-OxqMu\xz23v|R9q}lH?cRS{rCNe^'[`^sr5"
 f8*@r4ipO6Jl!:Ccq<xoV[Qz2u8<8-+Vwf2gzJ44lf_/y9OaQ`@#Q65{U4/TC)i2`~/M&QI$X>p:9I
 OSS'2{-)-4wBnVeg0S\O4Al@)uC[pD|+
X-Attribution: sb
From: Steven L Baur <steve@miranova.com>
In-Reply-To: repayne@jeeves.net's message of Fri, 31 Jan 1997 09:36:42 -0600 (CST)
Mime-Version: 1.0 (generated by tm-edit 7.101)
Content-Type: text/plain; charset=US-ASCII
Date: 31 Jan 1997 14:58:36 -0800
Message-ID: <m2vi8d5u5f.fsf@altair.xemacs.org>
Lines: 280
X-Mailer: Gnus v5.4.8/XEmacs 20.0

I reconstructed a patch for XEmacs from the RMS patch you found.

I recall not integrating this patch because the code looked different
enough and I wasn't entirely sure what was going on.  Please try this
out and make sure nothing breaks.

Index: completion.el
===================================================================
RCS file: /usr/local/xemacs/xemacs-20.0/lisp/packages/completion.el,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 completion.el
--- completion.el	1996/12/18 22:42:54	1.1.1.1
+++ completion.el	1997/01/31 22:14:50
@@ -622,42 +622,36 @@
   "Returns the symbol that the point is currently on.
 But only if it is longer than `completion-min-length'."
   (setq cmpl-saved-syntax (syntax-table))
-  ;; XEmacs change
-  (set-syntax-table cmpl-syntax-table)
-  (cond 
-  ;; Cursor is on following-char and after preceding-char
-    ((memq (char-syntax (following-char)) '(?w ?_))     
-     (setq cmpl-saved-point (point)
-	   cmpl-symbol-start (scan-sexps (1+ cmpl-saved-point) -1)
-	   cmpl-symbol-end (scan-sexps cmpl-saved-point 1))
-     ;; remove chars to ignore at the start
-     (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
-	    (goto-char cmpl-symbol-start)
-	    (forward-word 1)
-	    (setq cmpl-symbol-start (point))
-	    (goto-char cmpl-saved-point)
-	    ))
-     ;; remove chars to ignore at the end
-     (cond ((= (char-syntax (char-after (1- cmpl-symbol-end))) ?w)
-	    (goto-char cmpl-symbol-end)
-	    (forward-word -1)
-	    (setq cmpl-symbol-end (point))
-	    (goto-char cmpl-saved-point)
-	    ))
-     ;; restore state
-     (set-syntax-table cmpl-saved-syntax)
-     ;; Return completion if the length is reasonable
-     (if (and (<= (cmpl-read-time-eval completion-min-length)
-		  (- cmpl-symbol-end cmpl-symbol-start))
-	      (<= (- cmpl-symbol-end cmpl-symbol-start)
-		  (cmpl-read-time-eval completion-max-length)))
-	 (buffer-substring cmpl-symbol-start cmpl-symbol-end))
-     )
-    (t 
-     ;; restore table if no symbol
-     (set-syntax-table cmpl-saved-syntax)
-     nil)
-    ))
+  (unwind-protect
+      (progn
+	(set-syntax-table cmpl-syntax-table)
+	(cond 
+	;; Cursor is on following-char and after preceding-char
+	  ((memq (char-syntax (following-char)) '(?w ?_))     
+	   (setq cmpl-saved-point (point)
+		 cmpl-symbol-start (scan-sexps (1+ cmpl-saved-point) -1)
+		 cmpl-symbol-end (scan-sexps cmpl-saved-point 1))
+	   ;; Remove chars to ignore at the start.
+	   (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
+		  (goto-char cmpl-symbol-start)
+		  (forward-word 1)
+		  (setq cmpl-symbol-start (point))
+		  (goto-char cmpl-saved-point)
+		  ))
+	   ;; Remove chars to ignore at the end.
+	   (cond ((= (char-syntax (char-after (1- cmpl-symbol-end))) ?w)
+		  (goto-char cmpl-symbol-end)
+		  (forward-word -1)
+		  (setq cmpl-symbol-end (point))
+		  (goto-char cmpl-saved-point)
+		  ))
+	   ;; Return completion if the length is reasonable.
+	   (if (and (<= (cmpl-read-time-eval completion-min-length)
+			(- cmpl-symbol-end cmpl-symbol-start))
+		    (<= (- cmpl-symbol-end cmpl-symbol-start)
+			(cmpl-read-time-eval completion-max-length)))
+	       (buffer-substring cmpl-symbol-start cmpl-symbol-end)))))
+    (set-syntax-table cmpl-saved-syntax)))
 
 ;; tests for symbol-under-point
 ;;  `^' indicates cursor pos. where value is returned
@@ -676,58 +670,50 @@
 Returns nil if there isn't one longer than `completion-min-length'."       
   ;; This is called when a word separator is typed so it must be FAST !
   (setq cmpl-saved-syntax (syntax-table))
-  ;; XEmacs change
-  (set-syntax-table cmpl-syntax-table)
-  ;; Cursor is on following-char and after preceding-char
-  (cond ((= (setq cmpl-preceding-syntax (char-syntax (preceding-char))) ?_)
-	 ;; No chars. to ignore at end
-	 (setq cmpl-symbol-end (point)
-	       cmpl-symbol-start (scan-sexps (1+ cmpl-symbol-end) -1)
+  (unwind-protect
+      (progn
+	(set-syntax-table cmpl-syntax-table)
+	;; Cursor is on following-char and after preceding-char
+	(cond ((= (setq cmpl-preceding-syntax (char-syntax (preceding-char))) ?_)
+	       ;; Number of chars to ignore at end.
+	       (setq cmpl-symbol-end (point)
+		     cmpl-symbol-start (scan-sexps cmpl-symbol-end -1)
+		     )
+	       ;; Remove chars to ignore at the start.
+	       (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
+		      (goto-char cmpl-symbol-start)
+		      (forward-word 1)
+		      (setq cmpl-symbol-start (point))
+		      (goto-char cmpl-symbol-end)
+		      ))
+	       ;; Return value if long enough.
+	       (if (>= cmpl-symbol-end
+		       (+ cmpl-symbol-start
+			  (cmpl-read-time-eval completion-min-length)))
+		   (buffer-substring cmpl-symbol-start cmpl-symbol-end))
 	       )
-	 ;; XEmacs change
-	 ;; remove chars to ignore at the start
-	 (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
-		(goto-char cmpl-symbol-start)
-		(forward-word 1)
-		(setq cmpl-symbol-start (point))
-		(goto-char cmpl-symbol-end)
-		))
-	 ;; restore state
-	 (set-syntax-table cmpl-saved-syntax)
-	 ;; return value if long enough
-	 (if (>= cmpl-symbol-end
-		 (+ cmpl-symbol-start
-		    (cmpl-read-time-eval completion-min-length)))
-	     (buffer-substring cmpl-symbol-start cmpl-symbol-end))
-	 )
-	((= cmpl-preceding-syntax ?w)
-	 ;; chars to ignore at end
-	 (setq cmpl-saved-point (point)
-	       cmpl-symbol-start (scan-sexps (1+ cmpl-saved-point) -1))
-	 ;; take off chars. from end
-	 (forward-word -1)
-	 (setq cmpl-symbol-end (point))
-	 ;; remove chars to ignore at the start
-	 (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
-		(goto-char cmpl-symbol-start)
-		(forward-word 1)
-		(setq cmpl-symbol-start (point))
-		))
-	 ;; restore state
-	 (goto-char cmpl-saved-point)
-	 (set-syntax-table cmpl-saved-syntax)
-	 ;; Return completion if the length is reasonable
-	 (if (and (<= (cmpl-read-time-eval completion-min-length)
-		      (- cmpl-symbol-end cmpl-symbol-start))
-		  (<= (- cmpl-symbol-end cmpl-symbol-start)
-		      (cmpl-read-time-eval completion-max-length)))
-	     (buffer-substring cmpl-symbol-start cmpl-symbol-end))
-	 )
-	(t 
-	 ;; restore table if no symbol
-	 (set-syntax-table cmpl-saved-syntax)
-	 nil)
-	))
+	      ((= cmpl-preceding-syntax ?w)
+	       ;; chars to ignore at end
+	       (setq cmpl-saved-point (point)
+		     cmpl-symbol-start (scan-sexps cmpl-saved-point -1))
+	       ;; take off chars. from end
+	       (forward-word -1)
+	       (setq cmpl-symbol-end (point))
+	       ;; remove chars to ignore at the start
+	       (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
+		      (goto-char cmpl-symbol-start)
+		      (forward-word 1)
+		      (setq cmpl-symbol-start (point))
+		      ))
+	       ;; Restore state.
+	       (goto-char cmpl-saved-point)
+	       ;; Return completion if the length is reasonable
+	       (if (and (<= (cmpl-read-time-eval completion-min-length)
+			    (- cmpl-symbol-end cmpl-symbol-start))
+			(<= (- cmpl-symbol-end cmpl-symbol-start)
+			    (cmpl-read-time-eval completion-max-length)))
+		   (buffer-substring cmpl-symbol-start cmpl-symbol-end)))))
+    (set-syntax-table cmpl-saved-syntax)))
 
 ;; tests for symbol-before-point
 ;;  `^' indicates cursor pos. where value is returned
@@ -748,18 +734,17 @@
   ;; copying all the code.
   ;; However, it is only used by the completion string prompter.
   ;; If it comes into common use, it could be rewritten.
-  ;; XEmacs change
-  (setq cmpl-saved-syntax (syntax-table))
-  (set-syntax-table cmpl-syntax-table)
-  (cond ((memq (char-syntax (following-char)) '(?w ?_))
-	 (set-syntax-table cmpl-saved-syntax)
+  (cond ((memq (progn
+		 (setq cmpl-saved-syntax (syntax-table))
+		 (unwind-protect
+		     (progn
+		       (set-syntax-table cmpl-syntax-table)
+		       (char-syntax (following-char)))
+		   (set-syntax-table cmpl-saved-syntax)))
+	       '(?w ?_))
 	 (symbol-under-point))
 	(t
-	 ;; XEmacs change
-	 (set-syntax-table cmpl-saved-syntax)
-	 (symbol-before-point))
-	))
-
+	 (symbol-before-point))))
 
 (defun symbol-before-point-for-complete ()
   ;; "Returns a string of the symbol immediately before point
@@ -767,35 +752,30 @@
   ;; end chars."
   ;; Cursor is on following-char and after preceding-char
   (setq cmpl-saved-syntax (syntax-table))
-  ;; XEmacs change
-  (set-syntax-table cmpl-syntax-table)
-  (cond ((memq (setq cmpl-preceding-syntax (char-syntax (preceding-char)))
-	       '(?_ ?w))
-	 (setq cmpl-symbol-end (point)
-	       cmpl-symbol-start (scan-sexps (1+ cmpl-symbol-end) -1)
-	       )
-	 ;; remove chars to ignore at the start
-	 (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
-		(goto-char cmpl-symbol-start)
-		(forward-word 1)
-		(setq cmpl-symbol-start (point))
-		(goto-char cmpl-symbol-end)
-		))
-	 ;; restore state
-	 (set-syntax-table cmpl-saved-syntax)
-	 ;; Return completion if the length is reasonable
-	 (if (and (<= (cmpl-read-time-eval
-		       completion-prefix-min-length)
-		      (- cmpl-symbol-end cmpl-symbol-start))
-		  (<= (- cmpl-symbol-end cmpl-symbol-start)
-		      (cmpl-read-time-eval completion-max-length)))
-	     (buffer-substring cmpl-symbol-start cmpl-symbol-end))
-	 )
-	(t 
-	 ;; restore table if no symbol
-	 (set-syntax-table cmpl-saved-syntax)
-	 nil)
-	))
+  (unwind-protect
+      (progn
+	(set-syntax-table cmpl-syntax-table)
+	(cond ((memq (setq cmpl-preceding-syntax (char-syntax (preceding-char)))
+		     '(?_ ?w))
+	       (setq cmpl-symbol-end (point)
+		     cmpl-symbol-start (scan-sexps cmpl-symbol-end -1)
+		     )
+	       ;; Remove chars to ignore at the start.
+	       (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)
+		      (goto-char cmpl-symbol-start)
+		      (forward-word 1)
+		      (setq cmpl-symbol-start (point))
+		      (goto-char cmpl-symbol-end)
+		      ))
+	       ;; Return completion if the length is reasonable.
+	       (if (and (<= (cmpl-read-time-eval
+			     completion-prefix-min-length)
+			    (- cmpl-symbol-end cmpl-symbol-start))
+			(<= (- cmpl-symbol-end cmpl-symbol-start)
+			    (cmpl-read-time-eval completion-max-length)))
+		   (buffer-substring cmpl-symbol-start cmpl-symbol-end)))))
+    ;; Restore syntax table.
+    (set-syntax-table cmpl-saved-syntax)))
 
 ;; tests for symbol-before-point-for-complete
 ;;  `^' indicates cursor pos. where value is returned

-- 
steve@miranova.com baur
Unsolicited commercial e-mail will be billed at $250/message.

