(easy-menu-create-keymaps):
[bpt/emacs.git] / lisp / subr.el
index 42105a4..471d49a 100644 (file)
@@ -1,6 +1,6 @@
 ;;; subr.el --- basic lisp subroutines for Emacs
 
-;;; Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
+;;; Copyright (C) 1985, 1986, 1992, 1994 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -53,15 +53,21 @@ BODY should be a list of lisp expressions."
 \f
 ;;;; Window tree functions.
 
-(defun one-window-p (&optional nomini)
+(defun one-window-p (&optional nomini all-frames)
   "Returns non-nil if there is only one window.
 Optional arg NOMINI non-nil means don't count the minibuffer
-even if it is active."
+even if it is active.
+
+The optional arg ALL-FRAMES t means count windows on all frames.
+If it is `visible', count windows on all visible frames.
+ALL-FRAMES nil or omitted means count only the selected frame, 
+plus the minibuffer it uses (which may be on another frame).
+If ALL-FRAMES is neither nil nor t, count only the selected frame."
   (let ((base-window (selected-window)))
     (if (and nomini (eq base-window (minibuffer-window)))
        (setq base-window (next-window base-window)))
     (eq base-window
-       (next-window base-window (if nomini 'arg)))))
+       (next-window base-window (if nomini 'arg) all-frames))))
 
 (defun walk-windows (proc &optional minibuf all-frames)
   "Cycle through all visible windows, calling PROC for each one.
@@ -211,8 +217,8 @@ This is like `define-key' except that the binding for KEY is placed
 just after the binding for the event AFTER, instead of at the beginning
 of the map.
 The order matters when the keymap is used as a menu.
-KEY must contain just one event type--it must be a string or vector
-of length 1."
+KEY must contain just one event type--that is to say, it must be
+a string or vector of length 1."
   (or (keymapp keymap)
       (signal 'wrong-type-argument (list 'keymapp keymap)))
   (if (> (length key) 1)
@@ -406,7 +412,7 @@ as returned by the `event-start' and `event-end' functions."
   (nth 2 position))
 
 (defsubst posn-col-row (position)
-  "Return the row and column in POSITION, measured in characters.
+  "Return the column and row in POSITION, measured in characters.
 POSITION should be a list of the form
    (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP)
 as returned by the `event-start' and `event-end' functions."
@@ -463,6 +469,7 @@ Please convert your programs to use the variable `baud-rate' directly."
 (defalias 'search-forward-regexp (symbol-function 're-search-forward))
 (defalias 'search-backward-regexp (symbol-function 're-search-backward))
 (defalias 'int-to-string 'number-to-string)
+(defalias 'set-match-data 'store-match-data)
 
 ;;; Should this be an obsolete name?  If you decide it should, you get
 ;;; to go through all the sources and change them.
@@ -484,10 +491,31 @@ If it is a list, the elements are called, in order, with no arguments."
           (symbol-value sym)
           (let ((value (symbol-value sym)))
             (if (and (listp value) (not (eq (car value) 'lambda)))
-                (mapcar 'funcall value)
+                (let ((functions value))
+                  (while value
+                    (funcall (car value))
+                    (setq value (cdr value))))
               (funcall value)))))
     (setq hooklist (cdr hooklist))))
 
+(defun run-hook-with-args (hook &rest args)
+  "Run HOOK with the specified arguments ARGS.
+HOOK should be a symbol, a hook variable.  If HOOK has a non-nil
+value, that value may be a function or a list of functions to be
+called to run the hook.  If the value is a function, it is called with
+the given arguments and its return value is returned.  If it is a list
+of functions, those functions are called, in order,
+with the given arguments ARGS.
+It is best not to depend on the value return by `run-hook-with-args',
+as that may change."
+  (and (boundp hook)
+       (symbol-value hook)
+       (let ((value (symbol-value hook)))
+        (if (and (listp value) (not (eq (car value) 'lambda)))
+            (mapcar '(lambda (foo) (apply foo args))
+                    value)
+          (apply value args)))))
+
 ;; Tell C code how to call this function.
 (defconst run-hooks 'run-hooks
   "Variable by which C primitives find the function `run-hooks'.
@@ -576,11 +604,13 @@ Optional argument PROMPT specifies a string to use to prompt the user."
            ((> count 0)
             (setq unread-command-events (list char) count 259))
            (t (setq code char count 259))))
-    (logand 255 code)))
+    ;; Turn a meta-character into a character with the 0200 bit set.
+    (logior (if (/= (logand code (lsh 1 23)) 0) 128 0)
+           (logand 255 code))))
 
 (defun force-mode-line-update (&optional all)
   "Force the mode-line of the current buffer to be redisplayed.
-With optional non-nil ALL then force then force redisplay of all mode-lines."
+With optional non-nil ALL, force redisplay of all mode-lines."
   (if all (save-excursion (set-buffer (other-buffer))))
   (set-buffer-modified-p (buffer-modified-p)))
 
@@ -593,6 +623,8 @@ Display MESSAGE (optional fourth arg) in the echo area.
 If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there."
   (or exit-char (setq exit-char ?\ ))
   (let ((buffer-read-only nil)
+       ;; Don't modify the undo list at all.
+       (buffer-undo-list t)
        (modified (buffer-modified-p))
        (name buffer-file-name)
        insert-end)
@@ -629,6 +661,7 @@ If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there."
 ;;;; Miscellanea.
 
 (defun ignore (&rest ignore) 
+  (interactive)
   "Do nothing.
 Accept any number of arguments, but ignore them."
   nil)