changeset 36030:6ef1520f4852

(delete-key-deletes-forward-mode): Change `let' to `let*' to fix gross bug in last change.
author Richard M. Stallman <rms@gnu.org>
date Sat, 10 Feb 2001 16:34:03 +0000
parents e536d2c83d02
children 2c93976ae48d
files lisp/simple.el
diffstat 1 files changed, 19 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Sat Feb 10 16:33:44 2001 +0000
+++ b/lisp/simple.el	Sat Feb 10 16:34:03 2001 +0000
@@ -230,7 +230,8 @@
 (defun delete-trailing-whitespace ()
   "Delete all the trailing whitespace across the current buffer.
 All whitespace after the last non-whitespace character in a line is deleted.
-This respects narrowing, created by \\[narrow-to-region] and friends."
+This respects narrowing, created by \\[narrow-to-region] and friends.
+A formfeed is not considered whitespace by this function."
   (interactive "*")
   (save-match-data
     (save-excursion
@@ -4069,12 +4070,12 @@
   (cond ((or (memq window-system '(x w32 mac pc))
 	     (memq system-type '(ms-dos windows-nt)))
 	 (let ((bindings 
-		`(([C-delete] [C-backspace] kill-word backward-kill-word)
-		  ([M-delete] [M-backspace] kill-word backward-kill-word)
-		  ([C-M-delete] [C-M-backspace] kill-sexp backward-kill-sexp)
+		`(([C-delete] [C-backspace])
+		  ([M-delete] [M-backspace])
+		  ([C-M-delete] [C-M-backspace])
 		  (,esc-map
-		   [C-delete] [C-backspace]
-		   kill-sexp backward-kill-sexp))))
+		   [C-delete] [C-backspace])))
+	       (old-state (lookup-key function-key-map [delete])))
 
 	   (if delete-key-deletes-forward
 	       (progn
@@ -4085,19 +4086,18 @@
 	     (define-key function-key-map [kp-delete] [?\C-?])
 	     (define-key function-key-map [backspace] [?\C-?]))
 
-	   (dolist (binding bindings)
-	     (let ((map global-map))
-	       (when (keymapp (car binding))
-		 (setq map (car binding) binding (cdr binding)))
-	       (let ((key1 (nth 0 binding))
-		     (key2 (nth 1 binding))
-		     (binding1 (nth 2 binding))
-		     (binding2 (nth 3 binding)))
-		 (unless delete-key-deletes-forward
-		   (let ((temp binding1))
-		     (setq binding1 binding2 binding2 temp)))
-		 (define-key map key1 binding1)
-		 (define-key map key2 binding2))))))
+	   ;; Maybe swap bindings of C-delete and C-backspace, etc.
+	   (unless (equal old-state (lookup-key function-key-map [delete]))
+	     (dolist (binding bindings)
+	       (let ((map global-map))
+		 (when (keymapp (car binding))
+		   (setq map (car binding) binding (cdr binding)))
+		 (let* ((key1 (nth 0 binding))
+			(key2 (nth 1 binding))
+			(binding1 (lookup-key map key1))
+			(binding2 (lookup-key map key2)))
+		   (define-key map key1 binding2)
+		   (define-key map key2 binding1)))))))
 	 (t
 	  (if delete-key-deletes-forward
 	      (progn