changeset 83448:d2af586aefe4

Fix Delete keys under X (for good, this time). * lisp/simple.el (normal-erase-is-backspace-mode): Fix enabled/disabled logic. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-488
author Karoly Lorentey <lorentey@elte.hu>
date Tue, 03 Jan 2006 01:22:02 +0000
parents a78c6255d3be
children ff74a86c2b16
files lisp/simple.el
diffstat 1 files changed, 50 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Mon Jan 02 09:07:22 2006 +0000
+++ b/lisp/simple.el	Tue Jan 03 01:22:02 2006 +0000
@@ -5369,57 +5369,57 @@
 
 See also `normal-erase-is-backspace'."
   (interactive "P")
-  (set-terminal-parameter
-   nil 'normal-erase-is-backspace
-   (if (or (and arg (> (prefix-numeric-value arg) 0))
-	   (not (eq 1 (terminal-parameter nil 'normal-erase-is-backspace))))
-       0
-     1))
-
-  (cond ((or (memq window-system '(x w32 mac pc))
-	     (memq system-type '(ms-dos windows-nt)))
-	 (let* ((bindings
-		 `(([C-delete] [C-backspace])
-		   ([M-delete] [M-backspace])
-		   ([C-M-delete] [C-M-backspace])
-		   (,esc-map
-		    [C-delete] [C-backspace])))
-		(old-state (lookup-key local-function-key-map [delete])))
-
-	   (if (eq 1 (terminal-parameter nil 'normal-erase-is-backspace))
+  (let ((enabled (or (and arg (> (prefix-numeric-value arg) 0))
+		     (and (not arg)
+			  (not (eq 1 (terminal-parameter
+				      nil 'normal-erase-is-backspace)))))))
+    (set-terminal-parameter nil 'normal-erase-is-backspace
+			    (if enabled 1 0))
+
+    (cond ((or (memq window-system '(x w32 mac pc))
+	       (memq system-type '(ms-dos windows-nt)))
+	   (let* ((bindings
+		   `(([C-delete] [C-backspace])
+		     ([M-delete] [M-backspace])
+		     ([C-M-delete] [C-M-backspace])
+		     (,esc-map
+		      [C-delete] [C-backspace])))
+		  (old-state (lookup-key local-function-key-map [delete])))
+
+	     (if enabled
+		 (progn
+		   (define-key local-function-key-map [delete] [?\C-d])
+		   (define-key local-function-key-map [kp-delete] [?\C-d])
+		   (define-key local-function-key-map [backspace] [?\C-?]))
+	       (define-key local-function-key-map [delete] [?\C-?])
+	       (define-key local-function-key-map [kp-delete] [?\C-?])
+	       (define-key local-function-key-map [backspace] [?\C-?]))
+
+	     ;; Maybe swap bindings of C-delete and C-backspace, etc.
+	     (unless (equal old-state (lookup-key local-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 enabled
 	       (progn
-		 (define-key local-function-key-map [delete] [?\C-d])
-		 (define-key local-function-key-map [kp-delete] [?\C-d])
-		 (define-key local-function-key-map [backspace] [?\C-?]))
-	     (define-key local-function-key-map [delete] [?\C-?])
-	     (define-key local-function-key-map [kp-delete] [?\C-?])
-	     (define-key local-function-key-map [backspace] [?\C-?]))
-
-	   ;; Maybe swap bindings of C-delete and C-backspace, etc.
-	   (unless (equal old-state (lookup-key local-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 (eq 1 (terminal-parameter nil 'normal-erase-is-backspace))
-	      (progn
-		(keyboard-translate ?\C-h ?\C-?)
-		(keyboard-translate ?\C-? ?\C-d))
-	    (keyboard-translate ?\C-h ?\C-h)
-	    (keyboard-translate ?\C-? ?\C-?))))
-
-  (run-hooks 'normal-erase-is-backspace-hook)
-  (if (interactive-p)
-      (message "Delete key deletes %s"
-	       (if (terminal-parameter nil 'normal-erase-is-backspace)
-		   "forward" "backward"))))
+		 (keyboard-translate ?\C-h ?\C-?)
+		 (keyboard-translate ?\C-? ?\C-d))
+	     (keyboard-translate ?\C-h ?\C-h)
+	     (keyboard-translate ?\C-? ?\C-?))))
+
+    (run-hooks 'normal-erase-is-backspace-hook)
+    (if (interactive-p)
+	(message "Delete key deletes %s"
+		 (if (terminal-parameter nil 'normal-erase-is-backspace)
+		     "forward" "backward")))))
 
 (defvar vis-mode-saved-buffer-invisibility-spec nil
   "Saved value of `buffer-invisibility-spec' when Visible mode is on.")