]> code.delx.au - gnu-emacs/blobdiff - lisp/subr.el
Merge from emacs--devo--0
[gnu-emacs] / lisp / subr.el
index 45decd639249cfc23d56d55d3be8b378ac378fbb..1cb5eb7ff309dd193100988146cdcec1e496a25a 100644 (file)
@@ -694,7 +694,7 @@ The normal global definition of the character C-x indirects to this keymap.")
           ;; Filter out integers too large to be events.
           ;; M is the biggest modifier.
           (zerop (logand obj (lognot (1- (lsh ?\M-\^@ 1)))))
-          (char-valid-p (event-basic-type obj)))
+          (characterp (event-basic-type obj)))
       (and (symbolp obj)
           (get obj 'event-symbol-elements))
       (and (consp obj)
@@ -877,7 +877,7 @@ and `event-end' functions."
 
 (defsubst posn-image (position)
   "Return the image object of POSITION.
-Value is an list (image ...), or nil if not an image.
+Value is a list (image ...), or nil if not an image.
 POSITION should be a list of the form returned by the `event-start'
 and `event-end' functions."
   (nth 7 position))
@@ -943,7 +943,8 @@ is converted into a string by expressing it in decimal."
 (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."
+  "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")
 
 ;; Lisp manual only updated in 22.1.
@@ -1100,13 +1101,19 @@ until a certain package is loaded, you should put the call to `add-to-list'
 into a hook function that will be run only after loading the package.
 `eval-after-load' provides one way to do this.  In some cases
 other hooks, such as major mode hooks, can do the job."
-  (if (if compare-fn
-         (let (present)
-           (dolist (elt (symbol-value list-var))
-             (if (funcall compare-fn element elt)
-                 (setq present t)))
-           present)
+  (if (cond
+       ((null compare-fn)
        (member element (symbol-value list-var)))
+       ((eq compare-fn 'eq)
+       (memq element (symbol-value list-var)))
+       ((eq compare-fn 'eql)
+       (memql element (symbol-value list-var)))
+       (t
+       (let ((lst (symbol-value list-var)))
+         (while (and lst
+                     (not (funcall compare-fn element (car lst))))
+           (setq lst (cdr lst)))
+          lst)))
       (symbol-value list-var)
     (set list-var
         (if append
@@ -1752,8 +1759,14 @@ floating point support.
     (or nodisp (redisplay))
     (let ((read (read-event nil nil seconds)))
       (or (null read)
-         (progn (push read unread-command-events)
-                nil))))))
+         (progn
+           ;; If last command was a prefix arg, e.g. C-u, push this event onto
+           ;; unread-command-events as (t . EVENT) so it will be added to
+           ;; this-command-keys by read-key-sequence.
+           (if (eq overriding-terminal-local-map universal-argument-map)
+               (setq read (cons t read)))
+           (push read unread-command-events)
+           nil))))))
 \f
 ;;; Atomic change groups.
 
@@ -1880,7 +1893,7 @@ EXIT-CHAR it is swallowed; otherwise it is then available as
 input (as a command if nothing else).
 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 ?\ ))
+  (or exit-char (setq exit-char ?\s))
   (let ((inhibit-read-only t)
        ;; Don't modify the undo list at all.
        (buffer-undo-list t)
@@ -1948,8 +1961,10 @@ If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there."
   "Clear BEG and END of overlays whose property NAME has value VAL.
 Overlays might be moved and/or split.
 BEG and END default respectively to the beginning and end of buffer."
+  ;; This speeds up the loops over overlays.
   (unless beg (setq beg (point-min)))
   (unless end (setq end (point-max)))
+  (overlay-recenter end)
   (if (< end beg)
       (setq beg (prog1 end (setq end beg))))
   (save-excursion
@@ -2167,13 +2182,40 @@ If UNDO is present and non-nil, it is a function that will be called
   (let* ((handler (and (stringp string)
                       (get-text-property 0 'yank-handler string)))
         (param (or (nth 1 handler) string))
-        (opoint (point)))
+        (opoint (point))
+        end)
+
     (setq yank-undo-function t)
     (if (nth 0 handler) ;; FUNCTION
        (funcall (car handler) param)
       (insert param))
+    (setq end (point))
+
+    ;; What should we do with `font-lock-face' properties?
+    (if font-lock-defaults
+       ;; No, just wipe them.
+       (remove-list-of-text-properties opoint end '(font-lock-face))
+      ;; Convert them to `face'.
+      (save-excursion
+       (goto-char opoint)
+       (while (< (point) end)
+         (let ((face (get-text-property (point) 'font-lock-face))
+               run-end)
+           (setq run-end
+                 (next-single-property-change (point) 'font-lock-face nil end))
+           (when face
+             (remove-text-properties (point) run-end '(font-lock-face nil))
+             (put-text-property (point) run-end 'face face))
+           (goto-char run-end)))))
+
     (unless (nth 2 handler) ;; NOEXCLUDE
       (remove-yank-excluded-properties opoint (point)))
+
+    ;; If last inserted char has properties, mark them as rear-nonsticky.
+    (if (and (> end opoint)
+            (text-properties-at (1- end)))
+       (put-text-property (1- end) end 'rear-nonsticky t))
+
     (if (eq yank-undo-function t)  ;; not set by FUNCTION
        (setq yank-undo-function (nth 3 handler))) ;; UNDO
     (if (nth 4 handler) ;; COMMAND
@@ -2214,7 +2256,9 @@ BUFFER is the buffer (or buffer name) to associate with the process.
  BUFFER may be also nil, meaning that this process is not associated
  with any buffer
 COMMAND is the name of a shell command.
-Remaining arguments are the arguments for the command.
+Remaining arguments are the arguments for the command; they are all
+spliced together with blanks separating between each two of them, before
+passing the command to the shell.
 Wildcards and redirection are handled as usual in the shell.
 
 \(fn NAME BUFFER COMMAND &rest COMMAND-ARGS)"