]> code.delx.au - gnu-emacs/blobdiff - lisp/subr.el
(calc-mode): Add font-lock-defontify to change-major-mode-hook.
[gnu-emacs] / lisp / subr.el
index 6532f2da8a0c02457645c5ba5c1f8a1bd67e1050..dc16ed3dbce42ac11caee6e9930d5fe27d67fe0a 100644 (file)
@@ -279,7 +279,7 @@ Non-strings in LIST are ignored."
   "Make MAP override all normally self-inserting keys to be undefined.
 Normally, as an exception, digits and minus-sign are set to make prefix args,
 but optional second arg NODIGITS non-nil treats them like other chars."
-  (substitute-key-definition 'self-insert-command 'undefined map global-map)
+  (define-key map [remap self-insert-command] 'undefined)
   (or nodigits
       (let (loop)
        (define-key map "-" 'negative-argument)
@@ -699,7 +699,16 @@ as returned by the `event-start' and `event-end' functions."
 
 (defalias 'sref 'aref)
 (make-obsolete 'sref 'aref "20.4")
-(make-obsolete 'char-bytes "Now this function always returns 1" "20.4")
+(make-obsolete 'char-bytes "now always returns 1 (maintained for backward compatibility)." "20.4")
+(make-obsolete 'chars-in-region "use (abs (- BEG END))." "20.3")
+(make-obsolete 'dot 'point             "before 19.15")
+(make-obsolete 'dot-max 'point-max     "before 19.15")
+(make-obsolete 'dot-min 'point-min     "before 19.15")
+(make-obsolete 'dot-marker 'point-marker "before 19.15")
+(make-obsolete 'buffer-flush-undo 'buffer-disable-undo "before 19.15")
+(make-obsolete 'baud-rate "use the baud-rate variable instead." "before 19.15")
+(make-obsolete 'compiled-function-p 'byte-code-function-p "before 19.15")
+(make-obsolete 'define-function 'defalias "20.1")
 
 (defun insert-string (&rest args)
   "Mocklisp-compatibility insert function.
@@ -707,17 +716,32 @@ Like the function `insert' except that any argument that is a number
 is converted into a string by expressing it in decimal."
   (dolist (el args)
     (insert (if (integerp el) (number-to-string el) el))))
-
-(make-obsolete 'insert-string 'insert "21.3")
+(make-obsolete 'insert-string 'insert "21.4")
+(defun makehash (&optional test) (make-hash-table :test (or test 'eql)))
+(make-obsolete 'makehash 'make-hash-table "21.4")
 
 ;; Some programs still use this as a function.
 (defun baud-rate ()
-  "Obsolete function returning the value of the `baud-rate' variable.
-Please convert your programs to use the variable `baud-rate' directly."
+  "Return the value of the `baud-rate' variable."
   baud-rate)
 
 (defalias 'focus-frame 'ignore)
 (defalias 'unfocus-frame 'ignore)
+
+\f
+;;;; Obsolescence declarations for variables.
+
+(make-obsolete-variable 'directory-sep-char "do not use it." "21.1")
+(make-obsolete-variable 'mode-line-inverse-video "use the appropriate faces instead." "21.1")
+(make-obsolete-variable 'unread-command-char
+  "use `unread-command-events' instead.  That variable is a list of events to reread, so it now uses nil to mean `no event', instead of -1."
+  "before 19.15")
+(make-obsolete-variable 'executing-macro 'executing-kbd-macro "before 19.34")
+(make-obsolete-variable 'post-command-idle-hook
+  "use timers instead, with `run-with-idle-timer'." "before 19.34")
+(make-obsolete-variable 'post-command-idle-delay
+  "use timers instead, with `run-with-idle-timer'." "before 19.34")
+
 \f
 ;;;; Alternate names for functions - these are not being phased out.
 
@@ -733,6 +757,7 @@ Please convert your programs to use the variable `baud-rate' directly."
 (defalias 'search-backward-regexp (symbol-function 're-search-backward))
 (defalias 'int-to-string 'number-to-string)
 (defalias 'store-match-data 'set-match-data)
+(defalias 'make-variable-frame-localizable 'make-variable-frame-local)
 ;; These are the XEmacs names:
 (defalias 'point-at-eol 'line-end-position)
 (defalias 'point-at-bol 'line-beginning-position)
@@ -772,7 +797,7 @@ Do not use `make-local-variable' to make a hook variable buffer-local."
     (make-local-variable hook)
     (set hook (list t)))
   hook)
-(make-obsolete 'make-local-hook "Not necessary any more." "21.1")
+(make-obsolete 'make-local-hook "not necessary any more." "21.1")
 
 (defun add-hook (hook function &optional append local)
   "Add to the value of HOOK the function FUNCTION.
@@ -868,25 +893,25 @@ other hooks, such as major mode hooks, can do the job."
 \f
 ;;; Load history
 
-(defvar symbol-file-load-history-loaded nil
-  "Non-nil means we have loaded the file `fns-VERSION.el' in `exec-directory'.
-That file records the part of `load-history' for preloaded files,
-which is cleared out before dumping to make Emacs smaller.")
-
-(defun load-symbol-file-load-history ()
-  "Load the file `fns-VERSION.el' in `exec-directory' if not already done.
-That file records the part of `load-history' for preloaded files,
-which is cleared out before dumping to make Emacs smaller."
-  (unless symbol-file-load-history-loaded
-    (load (expand-file-name
-          ;; fns-XX.YY.ZZ.el does not work on DOS filesystem.
-          (if (eq system-type 'ms-dos)
-              "fns.el"
-            (format "fns-%s.el" emacs-version))
-          exec-directory)
-         ;; The file name fns-%s.el already has a .el extension.
-         nil nil t)
-    (setq symbol-file-load-history-loaded t)))
+;;; (defvar symbol-file-load-history-loaded nil
+;;;   "Non-nil means we have loaded the file `fns-VERSION.el' in `exec-directory'.
+;;; That file records the part of `load-history' for preloaded files,
+;;; which is cleared out before dumping to make Emacs smaller.")
+
+;;; (defun load-symbol-file-load-history ()
+;;;   "Load the file `fns-VERSION.el' in `exec-directory' if not already done.
+;;; That file records the part of `load-history' for preloaded files,
+;;; which is cleared out before dumping to make Emacs smaller."
+;;;   (unless symbol-file-load-history-loaded
+;;;     (load (expand-file-name
+;;;       ;; fns-XX.YY.ZZ.el does not work on DOS filesystem.
+;;;       (if (eq system-type 'ms-dos)
+;;;           "fns.el"
+;;;         (format "fns-%s.el" emacs-version))
+;;;       exec-directory)
+;;;      ;; The file name fns-%s.el already has a .el extension.
+;;;      nil nil t)
+;;;     (setq symbol-file-load-history-loaded t)))
 
 (defun symbol-file (function)
   "Return the input source from which FUNCTION was loaded.
@@ -894,14 +919,16 @@ The value is normally a string that was passed to `load':
 either an absolute file name, or a library name
 \(with no directory name and no `.el' or `.elc' at the end).
 It can also be nil, if the definition is not associated with any file."
-  (load-symbol-file-load-history)
-  (let ((files load-history)
-       file functions)
-    (while files
-      (if (memq function (cdr (car files)))
-         (setq file (car (car files)) files nil))
-      (setq files (cdr files)))
-    file))
+  (if (and (symbolp function) (fboundp function)
+          (eq 'autoload (car-safe (symbol-function function))))
+      (nth 1 (symbol-function function))
+    (let ((files load-history)
+         file functions)
+      (while files
+       (if (memq function (cdr (car files)))
+           (setq file (car (car files)) files nil))
+       (setq files (cdr files)))
+      file)))
 
 \f
 ;;;; Specifying things to do after certain files are loaded.
@@ -927,7 +954,7 @@ evaluated whenever that feature is `provide'd."
              (featurep file)
            ;; Make sure `load-history' contains the files dumped with
            ;; Emacs for the case that FILE is one of them.
-           (load-symbol-file-load-history)
+           ;; (load-symbol-file-load-history)
            (assoc file load-history))
          (eval form))))
   form)
@@ -1067,7 +1094,7 @@ any other non-digit terminates the character code and is then used as input."))
        (if inhibit-quit (setq quit-flag nil)))
       (cond ((null char))
            ((not (integerp char))
-            (setq unread-command-events (this-single-command-raw-keys)
+            (setq unread-command-events (listify-key-sequence (this-single-command-raw-keys))
                   done t))
            ((/= (logand char ?\M-\^@) 0)
             ;; Turn a meta-character into a character with the 0200 bit set.
@@ -1084,7 +1111,7 @@ any other non-digit terminates the character code and is then used as input."))
            ((and (not first) (eq char ?\C-m))
             (setq done t))
            ((not first)
-            (setq unread-command-events (this-single-command-raw-keys)
+            (setq unread-command-events (listify-key-sequence (this-single-command-raw-keys))
                   done t))
            (t (setq code char
                     done t)))
@@ -1144,7 +1171,7 @@ Optional DEFAULT is a default password to use instead of empty input."
   "Perform BODY as an atomic change group.
 This means that if BODY exits abnormally,
 all of its changes to the current buffer are undone.
-This works regadless of whether undo is enabled in the buffer.
+This works regardless of whether undo is enabled in the buffer.
 
 This mechanism is transparent to ordinary use of undo;
 if undo is enabled in the buffer and BODY succeeds, the
@@ -1837,6 +1864,14 @@ from `standard-syntax-table' otherwise."
     (set-char-table-parent table (or oldtable (standard-syntax-table)))
     table))
 
+(defun syntax-after (pos)
+  "Return the syntax of the char after POS."
+  (unless (or (< pos (point-min)) (>= pos (point-max)))
+    (let ((st (if parse-sexp-lookup-properties
+                 (get-char-property pos 'syntax-table))))
+      (if (consp st) st
+       (aref (or st (syntax-table)) (char-after pos))))))
+
 (defun add-to-invisibility-spec (arg)
   "Add elements to `buffer-invisibility-spec'.
 See documentation for `buffer-invisibility-spec' for the kind of elements
@@ -2154,7 +2189,7 @@ clone should be incorporated in the clone."
     ;;(overlay-put ol2 'face 'underline)
     (overlay-put ol2 'evaporate t)
     (overlay-put ol2 'text-clones dups)))
-\f
+
 (defun play-sound (sound)
   "SOUND is a list of the form `(sound KEYWORD VALUE...)'.
 The following keywords are recognized:
@@ -2176,4 +2211,39 @@ a system-dependent default device name is used."
     (error "This Emacs binary lacks sound support"))
   (play-sound-internal sound))
 
+(defun define-mail-user-agent (symbol composefunc sendfunc
+                                     &optional abortfunc hookvar)
+  "Define a symbol to identify a mail-sending package for `mail-user-agent'.
+
+SYMBOL can be any Lisp symbol.  Its function definition and/or
+value as a variable do not matter for this usage; we use only certain
+properties on its property list, to encode the rest of the arguments.
+
+COMPOSEFUNC is program callable function that composes an outgoing
+mail message buffer.  This function should set up the basics of the
+buffer without requiring user interaction.  It should populate the
+standard mail headers, leaving the `to:' and `subject:' headers blank
+by default.
+
+COMPOSEFUNC should accept several optional arguments--the same
+arguments that `compose-mail' takes.  See that function's documentation.
+
+SENDFUNC is the command a user would run to send the message.
+
+Optional ABORTFUNC is the command a user would run to abort the
+message.  For mail packages that don't have a separate abort function,
+this can be `kill-buffer' (the equivalent of omitting this argument).
+
+Optional HOOKVAR is a hook variable that gets run before the message
+is actually sent.  Callers that use the `mail-user-agent' may
+install a hook function temporarily on this hook variable.
+If HOOKVAR is nil, `mail-send-hook' is used.
+
+The properties used on SYMBOL are `composefunc', `sendfunc',
+`abortfunc', and `hookvar'."
+  (put symbol 'composefunc composefunc)
+  (put symbol 'sendfunc sendfunc)
+  (put symbol 'abortfunc (or abortfunc 'kill-buffer))
+  (put symbol 'hookvar (or hookvar 'mail-send-hook)))
+
 ;;; subr.el ends here