comparison lisp/simple.el @ 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 ec395f552d45
children 55e22205ba88
comparison
equal deleted inserted replaced
83447:a78c6255d3be 83448:d2af586aefe4
5367 probably not turn on this mode on a text-only terminal if you don't 5367 probably not turn on this mode on a text-only terminal if you don't
5368 have both Backspace, Delete and F1 keys. 5368 have both Backspace, Delete and F1 keys.
5369 5369
5370 See also `normal-erase-is-backspace'." 5370 See also `normal-erase-is-backspace'."
5371 (interactive "P") 5371 (interactive "P")
5372 (set-terminal-parameter 5372 (let ((enabled (or (and arg (> (prefix-numeric-value arg) 0))
5373 nil 'normal-erase-is-backspace 5373 (and (not arg)
5374 (if (or (and arg (> (prefix-numeric-value arg) 0)) 5374 (not (eq 1 (terminal-parameter
5375 (not (eq 1 (terminal-parameter nil 'normal-erase-is-backspace)))) 5375 nil 'normal-erase-is-backspace)))))))
5376 0 5376 (set-terminal-parameter nil 'normal-erase-is-backspace
5377 1)) 5377 (if enabled 1 0))
5378 5378
5379 (cond ((or (memq window-system '(x w32 mac pc)) 5379 (cond ((or (memq window-system '(x w32 mac pc))
5380 (memq system-type '(ms-dos windows-nt))) 5380 (memq system-type '(ms-dos windows-nt)))
5381 (let* ((bindings 5381 (let* ((bindings
5382 `(([C-delete] [C-backspace]) 5382 `(([C-delete] [C-backspace])
5383 ([M-delete] [M-backspace]) 5383 ([M-delete] [M-backspace])
5384 ([C-M-delete] [C-M-backspace]) 5384 ([C-M-delete] [C-M-backspace])
5385 (,esc-map 5385 (,esc-map
5386 [C-delete] [C-backspace]))) 5386 [C-delete] [C-backspace])))
5387 (old-state (lookup-key local-function-key-map [delete]))) 5387 (old-state (lookup-key local-function-key-map [delete])))
5388 5388
5389 (if (eq 1 (terminal-parameter nil 'normal-erase-is-backspace)) 5389 (if enabled
5390 (progn
5391 (define-key local-function-key-map [delete] [?\C-d])
5392 (define-key local-function-key-map [kp-delete] [?\C-d])
5393 (define-key local-function-key-map [backspace] [?\C-?]))
5394 (define-key local-function-key-map [delete] [?\C-?])
5395 (define-key local-function-key-map [kp-delete] [?\C-?])
5396 (define-key local-function-key-map [backspace] [?\C-?]))
5397
5398 ;; Maybe swap bindings of C-delete and C-backspace, etc.
5399 (unless (equal old-state (lookup-key local-function-key-map [delete]))
5400 (dolist (binding bindings)
5401 (let ((map global-map))
5402 (when (keymapp (car binding))
5403 (setq map (car binding) binding (cdr binding)))
5404 (let* ((key1 (nth 0 binding))
5405 (key2 (nth 1 binding))
5406 (binding1 (lookup-key map key1))
5407 (binding2 (lookup-key map key2)))
5408 (define-key map key1 binding2)
5409 (define-key map key2 binding1)))))))
5410 (t
5411 (if enabled
5390 (progn 5412 (progn
5391 (define-key local-function-key-map [delete] [?\C-d]) 5413 (keyboard-translate ?\C-h ?\C-?)
5392 (define-key local-function-key-map [kp-delete] [?\C-d]) 5414 (keyboard-translate ?\C-? ?\C-d))
5393 (define-key local-function-key-map [backspace] [?\C-?])) 5415 (keyboard-translate ?\C-h ?\C-h)
5394 (define-key local-function-key-map [delete] [?\C-?]) 5416 (keyboard-translate ?\C-? ?\C-?))))
5395 (define-key local-function-key-map [kp-delete] [?\C-?]) 5417
5396 (define-key local-function-key-map [backspace] [?\C-?])) 5418 (run-hooks 'normal-erase-is-backspace-hook)
5397 5419 (if (interactive-p)
5398 ;; Maybe swap bindings of C-delete and C-backspace, etc. 5420 (message "Delete key deletes %s"
5399 (unless (equal old-state (lookup-key local-function-key-map [delete])) 5421 (if (terminal-parameter nil 'normal-erase-is-backspace)
5400 (dolist (binding bindings) 5422 "forward" "backward")))))
5401 (let ((map global-map))
5402 (when (keymapp (car binding))
5403 (setq map (car binding) binding (cdr binding)))
5404 (let* ((key1 (nth 0 binding))
5405 (key2 (nth 1 binding))
5406 (binding1 (lookup-key map key1))
5407 (binding2 (lookup-key map key2)))
5408 (define-key map key1 binding2)
5409 (define-key map key2 binding1)))))))
5410 (t
5411 (if (eq 1 (terminal-parameter nil 'normal-erase-is-backspace))
5412 (progn
5413 (keyboard-translate ?\C-h ?\C-?)
5414 (keyboard-translate ?\C-? ?\C-d))
5415 (keyboard-translate ?\C-h ?\C-h)
5416 (keyboard-translate ?\C-? ?\C-?))))
5417
5418 (run-hooks 'normal-erase-is-backspace-hook)
5419 (if (interactive-p)
5420 (message "Delete key deletes %s"
5421 (if (terminal-parameter nil 'normal-erase-is-backspace)
5422 "forward" "backward"))))
5423 5423
5424 (defvar vis-mode-saved-buffer-invisibility-spec nil 5424 (defvar vis-mode-saved-buffer-invisibility-spec nil
5425 "Saved value of `buffer-invisibility-spec' when Visible mode is on.") 5425 "Saved value of `buffer-invisibility-spec' when Visible mode is on.")
5426 5426
5427 (define-minor-mode visible-mode 5427 (define-minor-mode visible-mode