aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaroly Lorentey2005-10-23 22:11:22 +0000
committerKaroly Lorentey2005-10-23 22:11:22 +0000
commit30a2fded2e53d85ae1701257170fb814d4523894 (patch)
treefc681de197ce1a9c878cd4347561165e167ea932
parent1072671b5b0f1fda9f91ea99da4bf0bd275ce6eb (diff)
downloademacs-30a2fded2e53d85ae1701257170fb814d4523894.tar.gz
emacs-30a2fded2e53d85ae1701257170fb814d4523894.zip
Fix Delete key on X by adapting normal-erase-is-backspace-mode for multi-tty. (Reported by Dan Waber and Dan Nicolaescu.)
* lisp/frame.el (terminal-parameter-p): New function. (terminal-parameter): Use it. * lisp/simple.el (normal-erase-is-backspace): Add 'maybe option, set it as default. (normal-erase-is-backspace-mode): Rewrite for multiple display support. (normal-erase-is-backspace-setup-frame): New function. * lisp/frame.el (make-frame): Call it. * lisp/startup.el (command-line): Call it. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-427
-rw-r--r--README.multi-tty14
-rw-r--r--lisp/frame.el13
-rw-r--r--lisp/simple.el130
-rw-r--r--lisp/startup.el3
4 files changed, 101 insertions, 59 deletions
diff --git a/README.multi-tty b/README.multi-tty
index ab77a707ede..75d9554f74f 100644
--- a/README.multi-tty
+++ b/README.multi-tty
@@ -391,6 +391,9 @@ THINGS TO DO
391** Report GTK multi-display problems to GTK maintainers. For extra 391** Report GTK multi-display problems to GTK maintainers. For extra
392 credit, fix them. 392 credit, fix them.
393 393
394** Possibly turn off the double C-g feature when there is an X frame.
395 C.f. (emacs)Emergency Escape.
396
394** frames-on-display-list should also accept frames. 397** frames-on-display-list should also accept frames.
395 398
396** I smell something funny around pop_kboard's "deleted kboard" case. 399** I smell something funny around pop_kboard's "deleted kboard" case.
@@ -483,6 +486,8 @@ THINGS TO DO
483 `last-command', but SELECTED_FRAME()->display->kboard to get the 486 `last-command', but SELECTED_FRAME()->display->kboard to get the
484 value of `function-key-map'. 487 value of `function-key-map'.
485 488
489** I think keyboard-translate-table should be made terminal-local.
490
486** The single-keyboard mode of MULTI_KBOARD is extremely confusing 491** The single-keyboard mode of MULTI_KBOARD is extremely confusing
487 sometimes; Emacs does not respond to stimuli from other keyboards. 492 sometimes; Emacs does not respond to stimuli from other keyboards.
488 At least a beep or a message would be important, if the single-mode 493 At least a beep or a message would be important, if the single-mode
@@ -533,9 +538,6 @@ THINGS TO DO
533 538
534 See if xsmfns.c should be updated. 539 See if xsmfns.c should be updated.
535 540
536** normal-erase-is-backspace-mode in simple.el needs to be updated for
537 multi-tty (rep. by Dan Waber).
538
539** Hunt down display-related functions in frame.el and extend them all 541** Hunt down display-related functions in frame.el and extend them all
540 to accept display ids. 542 to accept display ids.
541 543
@@ -1249,5 +1251,11 @@ DIARY OF CHANGES
1249 1251
1250 (Fixed in patch-414 after detailed analysis by Kalle Olavi Niemitalo.) 1252 (Fixed in patch-414 after detailed analysis by Kalle Olavi Niemitalo.)
1251 1253
1254-- normal-erase-is-backspace-mode in simple.el needs to be updated for
1255 multi-tty (rep. by Dan Waber). (The Delete key is broken on X
1256 because of this.)
1257
1258 (Fixed in patch-427.)
1259
1252;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d 1260;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d
1253 1261
diff --git a/lisp/frame.el b/lisp/frame.el
index 68dd7ddaf90..c8085762d2a 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -676,6 +676,7 @@ setup is for focus to follow the pointer."
676 (error "Don't know how to create a frame on window system %s" w)) 676 (error "Don't know how to create a frame on window system %s" w))
677 (run-hooks 'before-make-frame-hook) 677 (run-hooks 'before-make-frame-hook)
678 (setq frame (funcall frame-creation-function (append parameters (cdr (assq w window-system-default-frame-alist))))) 678 (setq frame (funcall frame-creation-function (append parameters (cdr (assq w window-system-default-frame-alist)))))
679 (normal-erase-is-backspace-setup-frame frame)
679 (run-hook-with-args 'after-make-frame-functions frame) 680 (run-hook-with-args 'after-make-frame-functions frame)
680 frame)) 681 frame))
681 682
@@ -1450,12 +1451,22 @@ TERMINAL can be a terminal id, a frame, or nil (meaning the
1450selected frame's terminal)." 1451selected frame's terminal)."
1451 (cdr (assq (terminal-id terminal) terminal-parameter-alist))) 1452 (cdr (assq (terminal-id terminal) terminal-parameter-alist)))
1452 1453
1454(defun terminal-parameter-p (terminal parameter)
1455 "Return non-nil if PARAMETER is a terminal parameter on TERMINAL.
1456
1457The actual value returned in that case is a cell (PARAMETER . VALUE),
1458where VALUE is the current value of PARAMETER.
1459
1460TERMINAL can be a terminal id, a frame, or nil (meaning the
1461selected frame's terminal)."
1462 (assq parameter (cdr (assq (terminal-id terminal) terminal-parameter-alist))))
1463
1453(defun terminal-parameter (terminal parameter) 1464(defun terminal-parameter (terminal parameter)
1454 "Return TERMINAL's value for parameter PARAMETER. 1465 "Return TERMINAL's value for parameter PARAMETER.
1455 1466
1456TERMINAL can be a terminal id, a frame, or nil (meaning the 1467TERMINAL can be a terminal id, a frame, or nil (meaning the
1457selected frame's terminal)." 1468selected frame's terminal)."
1458 (cdr (assq parameter (cdr (assq (terminal-id terminal) terminal-parameter-alist))))) 1469 (cdr (terminal-parameter-p terminal parameter)))
1459 1470
1460(defun set-terminal-parameter (terminal parameter value) 1471(defun set-terminal-parameter (terminal parameter value)
1461 "Set TERMINAL's value for parameter PARAMETER to VALUE. 1472 "Set TERMINAL's value for parameter PARAMETER to VALUE.
diff --git a/lisp/simple.el b/lisp/simple.el
index 301b4cc996a..be5844fa794 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5237,36 +5237,33 @@ the front of the list of recently selected ones."
5237 5237
5238;;; Handling of Backspace and Delete keys. 5238;;; Handling of Backspace and Delete keys.
5239 5239
5240(defcustom normal-erase-is-backspace 5240(defcustom normal-erase-is-backspace 'maybe
5241 (and (not noninteractive) 5241 "Set the default behaviour of the Delete and Backspace keys.
5242 (or (memq system-type '(ms-dos windows-nt)) 5242
5243 (eq initial-window-system 'mac) 5243If set to t, Delete key deletes forward and Backspace key deletes
5244 (and (memq initial-window-system '(x)) 5244backward.
5245 (fboundp 'x-backspace-delete-keys-p) 5245
5246 (x-backspace-delete-keys-p)) 5246If set to nil, both Delete and Backspace keys delete backward.
5247 ;; If the terminal Emacs is running on has erase char 5247
5248 ;; set to ^H, use the Backspace key for deleting 5248If set to 'maybe (which is the default), Emacs automatically
5249 ;; backward and, and the Delete key for deleting forward. 5249selects a behaviour. On window systems, the behaviour depends on
5250 (and (null initial-window-system) 5250the keyboard used. If the keyboard has both a Backspace key and
5251 (eq tty-erase-char ?\^H)))) 5251a Delete key, and both are mapped to their usual meanings, the
5252 "If non-nil, Delete key deletes forward and Backspace key deletes backward. 5252option's default value is set to t, so that Backspace can be used
5253 5253to delete backward, and Delete can be used to delete forward.
5254On window systems, the default value of this option is chosen 5254
5255according to the keyboard used. If the keyboard has both a Backspace 5255If not running under a window system, customizing this option
5256key and a Delete key, and both are mapped to their usual meanings, the 5256accomplishes a similar effect by mapping C-h, which is usually
5257option's default value is set to t, so that Backspace can be used to 5257generated by the Backspace key, to DEL, and by mapping DEL to C-d
5258delete backward, and Delete can be used to delete forward. 5258via `keyboard-translate'. The former functionality of C-h is
5259 5259available on the F1 key. You should probably not use this
5260If not running under a window system, customizing this option accomplishes 5260setting if you don't have both Backspace, Delete and F1 keys.
5261a similar effect by mapping C-h, which is usually generated by the
5262Backspace key, to DEL, and by mapping DEL to C-d via
5263`keyboard-translate'. The former functionality of C-h is available on
5264the F1 key. You should probably not use this setting if you don't
5265have both Backspace, Delete and F1 keys.
5266 5261
5267Setting this variable with setq doesn't take effect. Programmatically, 5262Setting this variable with setq doesn't take effect. Programmatically,
5268call `normal-erase-is-backspace-mode' (which see) instead." 5263call `normal-erase-is-backspace-mode' (which see) instead."
5269 :type 'boolean 5264 :type '(choice (const :tag "Off" nil)
5265 (const :tag "Maybe" maybe)
5266 (other :tag "On" t))
5270 :group 'editing-basics 5267 :group 'editing-basics
5271 :version "21.1" 5268 :version "21.1"
5272 :set (lambda (symbol value) 5269 :set (lambda (symbol value)
@@ -5276,17 +5273,40 @@ call `normal-erase-is-backspace-mode' (which see) instead."
5276 (normal-erase-is-backspace-mode (or value 0)) 5273 (normal-erase-is-backspace-mode (or value 0))
5277 (set-default symbol value)))) 5274 (set-default symbol value))))
5278 5275
5276(defun normal-erase-is-backspace-setup-frame (&optional frame)
5277 "Set up `normal-erase-is-backspace-mode' on FRAME, if necessary."
5278 (unless frame (setq frame (selected-frame)))
5279 (with-selected-frame frame
5280 (unless (terminal-parameter-p nil 'normal-erase-is-backspace)
5281 (if (cond ((terminal-parameter-p nil 'normal-erase-is-backspace)
5282 (terminal-parameter nil 'normal-erase-is-backspace))
5283 ((eq normal-erase-is-backspace 'maybe)
5284 (and (not noninteractive)
5285 (or (memq system-type '(ms-dos windows-nt))
5286 (eq window-system 'mac)
5287 (and (memq window-system '(x))
5288 (fboundp 'x-backspace-delete-keys-p)
5289 (x-backspace-delete-keys-p))
5290 ;; If the terminal Emacs is running on has erase char
5291 ;; set to ^H, use the Backspace key for deleting
5292 ;; backward and, and the Delete key for deleting forward.
5293 (and (null window-system)
5294 (eq tty-erase-char ?\^H)))))
5295 (t
5296 normal-erase-is-backspace))
5297 (normal-erase-is-backspace-mode 1)
5298 (normal-erase-is-backspace-mode 0)))))
5279 5299
5280(defun normal-erase-is-backspace-mode (&optional arg) 5300(defun normal-erase-is-backspace-mode (&optional arg)
5281 "Toggle the Erase and Delete mode of the Backspace and Delete keys. 5301 "Toggle the Erase and Delete mode of the Backspace and Delete keys.
5282 5302
5283With numeric arg, turn the mode on if and only if ARG is positive. 5303With numeric arg, turn the mode on if and only if ARG is positive.
5284 5304
5285On window systems, when this mode is on, Delete is mapped to C-d and 5305On window systems, when this mode is on, Delete is mapped to C-d
5286Backspace is mapped to DEL; when this mode is off, both Delete and 5306and Backspace is mapped to DEL; when this mode is off, both
5287Backspace are mapped to DEL. (The remapping goes via 5307Delete and Backspace are mapped to DEL. (The remapping goes via
5288`function-key-map', so binding Delete or Backspace in the global or 5308`local-function-key-map', so binding Delete or Backspace in the
5289local keymap will override that.) 5309global or local keymap will override that.)
5290 5310
5291In addition, on window systems, the bindings of C-Delete, M-Delete, 5311In addition, on window systems, the bindings of C-Delete, M-Delete,
5292C-M-Delete, C-Backspace, M-Backspace, and C-M-Backspace are changed in 5312C-M-Delete, C-Backspace, M-Backspace, and C-M-Backspace are changed in
@@ -5308,33 +5328,34 @@ have both Backspace, Delete and F1 keys.
5308 5328
5309See also `normal-erase-is-backspace'." 5329See also `normal-erase-is-backspace'."
5310 (interactive "P") 5330 (interactive "P")
5311 (setq normal-erase-is-backspace 5331 (set-terminal-parameter
5312 (if arg 5332 nil 'normal-erase-is-backspace
5313 (> (prefix-numeric-value arg) 0) 5333 (if arg
5314 (not normal-erase-is-backspace))) 5334 (> (prefix-numeric-value arg) 0)
5335 (not (terminal-parameter nil 'normal-erase-is-backspace))))
5315 5336
5316 (cond ((or (memq window-system '(x w32 mac pc)) 5337 (cond ((or (memq window-system '(x w32 mac pc))
5317 (memq system-type '(ms-dos windows-nt))) 5338 (memq system-type '(ms-dos windows-nt)))
5318 (let ((bindings 5339 (let* ((lfkm (terminal-local-value 'local-function-key-map nil))
5319 `(([C-delete] [C-backspace]) 5340 (bindings
5320 ([M-delete] [M-backspace]) 5341 `(([C-delete] [C-backspace])
5321 ([C-M-delete] [C-M-backspace]) 5342 ([M-delete] [M-backspace])
5322 (,esc-map 5343 ([C-M-delete] [C-M-backspace])
5323 [C-delete] [C-backspace]))) 5344 (,esc-map
5324 (old-state (lookup-key function-key-map [delete]))) 5345 [C-delete] [C-backspace])))
5325 5346 (old-state (lookup-key lfkm [delete])))
5326 (if normal-erase-is-backspace 5347
5348 (if (terminal-parameter nil 'normal-erase-is-backspace)
5327 (progn 5349 (progn
5328 ;; XXX Perhaps this mode should be terminal-local, not global -- lorentey 5350 (define-key lfkm [delete] [?\C-d])
5329 (define-key function-key-map [delete] [?\C-d]) 5351 (define-key lfkm [kp-delete] [?\C-d])
5330 (define-key function-key-map [kp-delete] [?\C-d]) 5352 (define-key lfkm [backspace] [?\C-?]))
5331 (define-key function-key-map [backspace] [?\C-?])) 5353 (define-key lfkm [delete] [?\C-?])
5332 (define-key function-key-map [delete] [?\C-?]) 5354 (define-key lfkm [kp-delete] [?\C-?])
5333 (define-key function-key-map [kp-delete] [?\C-?]) 5355 (define-key lfkm [backspace] [?\C-?]))
5334 (define-key function-key-map [backspace] [?\C-?]))
5335 5356
5336 ;; Maybe swap bindings of C-delete and C-backspace, etc. 5357 ;; Maybe swap bindings of C-delete and C-backspace, etc.
5337 (unless (equal old-state (lookup-key function-key-map [delete])) 5358 (unless (equal old-state (lookup-key lfkm [delete]))
5338 (dolist (binding bindings) 5359 (dolist (binding bindings)
5339 (let ((map global-map)) 5360 (let ((map global-map))
5340 (when (keymapp (car binding)) 5361 (when (keymapp (car binding))
@@ -5346,8 +5367,9 @@ See also `normal-erase-is-backspace'."
5346 (define-key map key1 binding2) 5367 (define-key map key1 binding2)
5347 (define-key map key2 binding1))))))) 5368 (define-key map key2 binding1)))))))
5348 (t 5369 (t
5349 (if normal-erase-is-backspace 5370 (if (terminal-parameter nil 'normal-erase-is-backspace)
5350 (progn 5371 (progn
5372 ;; XXX This should be terminal-local -- lorentey
5351 (keyboard-translate ?\C-h ?\C-?) 5373 (keyboard-translate ?\C-h ?\C-?)
5352 (keyboard-translate ?\C-? ?\C-d)) 5374 (keyboard-translate ?\C-? ?\C-d))
5353 (keyboard-translate ?\C-h ?\C-h) 5375 (keyboard-translate ?\C-h ?\C-h)
diff --git a/lisp/startup.el b/lisp/startup.el
index f5b01809512..c7bd6b323e9 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -756,9 +756,10 @@ opening the first frame (e.g. open a connection to an X server).")
756 ;; Can't do this init in defcustom because the relevant variables 756 ;; Can't do this init in defcustom because the relevant variables
757 ;; are not set. 757 ;; are not set.
758 (custom-reevaluate-setting 'blink-cursor-mode) 758 (custom-reevaluate-setting 'blink-cursor-mode)
759 (custom-reevaluate-setting 'normal-erase-is-backspace)
760 (custom-reevaluate-setting 'tooltip-mode) 759 (custom-reevaluate-setting 'tooltip-mode)
761 760
761 (normal-erase-is-backspace-setup-frame)
762
762 ;; Register default TTY colors for the case the terminal hasn't a 763 ;; Register default TTY colors for the case the terminal hasn't a
763 ;; terminal init file. 764 ;; terminal init file.
764 ;; We do this regardles of whether the terminal supports colors 765 ;; We do this regardles of whether the terminal supports colors