]> code.delx.au - gnu-emacs/blobdiff - lisp/emulation/pc-select.el
Merged in changes from CVS trunk.
[gnu-emacs] / lisp / emulation / pc-select.el
index 90865f2bdee39ebb872d81888dfcf63718cb77a4..188e335687cfab39654b306d7dfd46b8308ab0e4 100644 (file)
@@ -61,7 +61,7 @@
 ;; Eli Barzilay (eli@cs.bgu.ac.il) suggested the sexps functions and
 ;; keybindings.
 ;;
-;; Ok, some details about the idea of pc-selection-mode:
+;; Ok, some details about the idea of PC Selection mode:
 ;;
 ;;  o The standard keys for moving around (right, left, up, down, home, end,
 ;;    prior, next, called "move-keys" from now on) will always de-activate
@@ -114,23 +114,23 @@ This gives mostly Emacs-like behaviour with only the selection keys enabled."
   :group 'pc-select)
 
 (defvar pc-select-saved-settings-alist nil
-  "The values of the variables before `pc-selection-mode' was toggled on.
-When `pc-selection-mode' is toggled on, it sets quite a few variables
+  "The values of the variables before PC Selection mode was toggled on.
+When PC Selection mode is toggled on, it sets quite a few variables
 for its own purposes.  This alist holds the original values of the
-variables `pc-selection-mode' had set, so that these variables can be
-restored to their original values when `pc-selection-mode' is toggled off.")
+variables PC Selection mode had set, so that these variables can be
+restored to their original values when PC Selection mode is toggled off.")
 
 (defvar pc-select-map nil
-  "The keymap used as the global map when `pc-selection-mode' is on." )
+  "The keymap used as the global map when PC Selection mode is on." )
 
 (defvar pc-select-saved-global-map nil
-  "The global map that was in effect when `pc-selection-mode' was toggled on.")
+  "The global map that was in effect when PC Selection mode was toggled on.")
 
 (defvar pc-select-key-bindings-alist nil
-  "This alist holds all the key bindings `pc-selection-mode' sets.")
+  "This alist holds all the key bindings PC Selection mode sets.")
 
 (defvar pc-select-default-key-bindings nil
-  "These key bindings always get set by `pc-selection-mode'.")
+  "These key bindings always get set by PC Selection mode.")
 
 (unless pc-select-default-key-bindings
   (let ((lst
@@ -185,7 +185,7 @@ restored to their original values when `pc-selection-mode' is toggled off.")
           ([C-up]      . backward-paragraph-nomark) ; KPrevPara     cUp
           ([S-C-down]  . forward-paragraph-mark)
           ([S-C-up]    . backward-paragraph-mark))))
-    
+
     (setq pc-select-default-key-bindings lst)))
 
 (defvar pc-select-extra-key-bindings nil
@@ -219,7 +219,7 @@ restored to their original values when `pc-selection-mode' is toggled off.")
           ([C-M-delete]  . kill-sexp)
           ;; Next line proposed by Eli Barzilay
           ([C-escape]    . electric-buffer-list))))
-    
+
     (setq pc-select-extra-key-bindings lst)))
 
 (defvar pc-select-meta-moves-sexps-key-bindings
@@ -250,7 +250,7 @@ These key bindings get installed when running in a tty, but only if
 (defvar pc-select-old-M-delete-binding nil
   "Holds the old mapping of [M-delete] in the `function-key-map'.
 This variable holds the value associated with [M-delete] in the
-`function-key-map' before `pc-selection-mode' had changed that
+`function-key-map' before PC Selection mode had changed that
 association.")
 
 ;;;;
@@ -773,7 +773,7 @@ restore the previous value of that key binding from SAVED-MAP."
 (defmacro pc-select-add-to-alist (alist var val)
   "Ensure that ALIST contains the cons cell (VAR . VAL).
 If a cons cell whose car is VAR is already on the ALIST, update the
-cdr of that cell with VAL.  Otherwise, make a new cons cell 
+cdr of that cell with VAL.  Otherwise, make a new cons cell
 \(VAR . VAL), and prepend it onto ALIST."
   (let ((elt (make-symbol "elt")))
     `(let ((,elt (assq ',var ,alist)))
@@ -785,8 +785,8 @@ cdr of that cell with VAL.  Otherwise, make a new cons cell
   "Set VAR to NEWVAL; save the old value.
 The old value is saved on the `pc-select-saved-settings-alist'."
   `(when (boundp ',var)
-       (pc-select-add-to-alist pc-select-saved-settings-alist ,var ,var)
-       (setq ,var ,newval)))
+     (pc-select-add-to-alist pc-select-saved-settings-alist ,var ,var)
+     (setq ,var ,newval)))
 
 (defmacro pc-select-save-and-set-mode (mode &optional arg mode-var)
   "Call the function MODE; save the old value of the variable MODE.
@@ -796,15 +796,14 @@ Then, if ARG is specified, call MODE with ARG, otherwise call it with
 nil as an argument.  If MODE-VAR is specified, save the value of the
 variable MODE-VAR (instead of the value of the variable MODE) on
 `pc-select-saved-settings-alist'."
-    `(when (fboundp ',mode)
-       (pc-select-add-to-alist pc-select-saved-settings-alist
-                               ,mode
-                               (or (and (boundp ',mode) ,mode)
-                                   ,mode-var))
-       (,mode ,arg)))
+  (unless mode-var (setq mode-var mode))
+  `(when (fboundp ',mode)
+     (pc-select-add-to-alist pc-select-saved-settings-alist
+                            ,mode-var ,mode-var)
+     (,mode ,arg)))
 
 (defmacro pc-select-restore-var (var)
-  "Restore the previous value of the variable VAR. 
+  "Restore the previous value of the variable VAR.
 Look up VAR's previous value in `pc-select-saved-settings-alist', and,
 if the value is found, set VAR to that value."
   (let ((elt (make-symbol "elt")))
@@ -821,7 +820,7 @@ If the value is non-nil, call the function MODE with an argument of
     `(when (fboundp ',mode)
        (let ((,elt (assq ',mode pc-select-saved-settings-alist)))
         (unless (null ,elt)
-        (,mode (if (cdr ,elt) 1 -1)))))))
+          (,mode (if (cdr ,elt) 1 -1)))))))
 
 
 ;;;###autoload
@@ -843,7 +842,7 @@ M-LEFT and M-RIGHT move back or forward one word or sexp, disabling the mark.
 S-M-LEFT and S-M-RIGHT move back or forward one word or sexp, leaving the mark
 behind.  To control whether these keys move word-wise or sexp-wise set the
 variable `pc-select-meta-moves-sexps' after loading pc-select.el but before
-turning `pc-selection-mode' on.
+turning PC Selection mode on.
 
 C-DOWN and C-UP move back or forward a paragraph, disabling the mark.
 S-C-DOWN and S-C-UP move back or forward a paragraph, leaving the mark behind.
@@ -865,7 +864,7 @@ C-INSERT copies the region into the kill ring (`copy-region-as-kill').
 
 In addition, certain other PC bindings are imitated (to avoid this, set
 the variable `pc-select-selection-keys-only' to t after loading pc-select.el
-but before calling `pc-selection-mode'):
+but before calling PC Selection mode):
 
   F6           other-window
   DELETE       delete-char
@@ -883,9 +882,7 @@ but before calling `pc-selection-mode'):
   (if pc-selection-mode
       (if (null pc-select-key-bindings-alist)
          (progn
-           (setq pc-select-map (copy-keymap (current-global-map))
-                 pc-select-saved-global-map (copy-keymap (current-global-map)))
-             
+           (setq pc-select-saved-global-map (copy-keymap (current-global-map)))
            (setq pc-select-key-bindings-alist
                  (append pc-select-default-key-bindings
                          (if pc-select-selection-keys-only
@@ -900,14 +897,14 @@ but before calling `pc-selection-mode'):
                              nil
                            pc-select-tty-key-bindings)))
 
-           (pc-select-define-keys pc-select-key-bindings-alist pc-select-map)
-           (use-global-map pc-select-map)
+           (pc-select-define-keys pc-select-key-bindings-alist
+                                  (current-global-map))
 
            (unless  (or pc-select-selection-keys-only
                         (eq window-system 'x)
                         (memq system-name '(ms-dos windows-nt)))
              ;; it is not clear that we need the following line
-       ;; I hope it doesn't do too much harm to leave it in, though...
+             ;; I hope it doesn't do too much harm to leave it in, though...
              (setq pc-select-old-M-delete-binding
                    (lookup-key function-key-map [M-delete]))
              (define-key function-key-map  [M-delete] [?\M-d]))
@@ -921,8 +918,8 @@ but before calling `pc-selection-mode'):
            ;; the original author also had this above:
            ;; (setq-default normal-erase-is-backspace t)
            ;; However, the documentation for the variable says that
-         ;; "setting it with setq has no effect", so I'm removing it.
-      
+           ;; "setting it with setq has no effect", so I'm removing it.
+
            (pc-select-save-and-set-var highlight-nonselected-windows nil)
            (pc-select-save-and-set-var transient-mark-mode t)
            (pc-select-save-and-set-var mark-even-if-inactive t)
@@ -932,14 +929,13 @@ but before calling `pc-selection-mode'):
        ;; do not clobber the values of the variables that were
        ;; saved from before pc-selection mode was activated --
        ;; just make sure the values are the way we like them.
-       (setq pc-select-map (copy-keymap (current-global-map)))
-       (pc-select-define-keys pc-select-key-bindings-alist pc-select-map)
-       (use-global-map pc-select-map)
+       (pc-select-define-keys pc-select-key-bindings-alist
+                              (current-global-map))
        (unless  (or pc-select-selection-keys-only
                     (eq window-system 'x)
                     (memq system-name '(ms-dos windows-nt)))
          ;; it is not clear that we need the following line
-       ;; I hope it doesn't do too much harm to leave it in, though...
+         ;; I hope it doesn't do too much harm to leave it in, though...
          (define-key function-key-map  [M-delete] [?\M-d]))
        (when (and (not pc-select-selection-keys-only)
                   (or (eq window-system 'x)
@@ -957,10 +953,9 @@ but before calling `pc-selection-mode'):
                     (memq system-name '(ms-dos windows-nt))))
        (pc-select-restore-mode normal-erase-is-backspace-mode))
 
-      (setq pc-select-map (copy-keymap (current-global-map)))
       (pc-select-restore-keys
-       pc-select-key-bindings-alist pc-select-map pc-select-saved-global-map)
-      (use-global-map pc-select-map)
+       pc-select-key-bindings-alist (current-global-map)
+       pc-select-saved-global-map)
 
       (pc-select-restore-var highlight-nonselected-windows)
       (pc-select-restore-var transient-mark-mode)
@@ -971,7 +966,7 @@ but before calling `pc-selection-mode'):
             pc-select-old-M-delete-binding))
       (setq pc-select-key-bindings-alist nil
            pc-select-saved-settings-alist nil))))
-  
+
 
 ;;;###autoload
 (defcustom pc-selection-mode nil
@@ -979,7 +974,8 @@ but before calling `pc-selection-mode'):
 Change mark behaviour to emulate Motif, MAC or MS-Windows cut and paste style,
 and cursor movement commands.
 This mode enables Delete Selection mode and Transient Mark mode.
-You must modify via \\[customize] for this variable to have an effect."
+Setting this variable directly does not take effect;
+you must modify it using \\[customize] or \\[pc-selection-mode]."
   :set (lambda (symbol value)
         (pc-selection-mode (if value 1 -1)))
   :initialize 'custom-initialize-default
@@ -987,4 +983,5 @@ You must modify via \\[customize] for this variable to have an effect."
   :group 'pc-select
   :require 'pc-select)
 
+;;; arch-tag: 10697b70-ae07-4f3e-ad23-7814a3f418c2
 ;;; pc-select.el ends here