(msgnum): Remove declaration.
[bpt/emacs.git] / lisp / simple.el
index a854e1d..cb2459a 100644 (file)
@@ -1,7 +1,7 @@
 ;;; simple.el --- basic editing commands for Emacs
 
 ;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 
 ;;; Code:
 
+;; This is for lexical-let in apply-partially.
+(eval-when-compile (require 'cl))
+
 (declare-function widget-convert "wid-edit" (type &rest args))
 (declare-function shell-mode "shell" ())
 
 (defvar compilation-current-error)
 
 (defcustom idle-update-delay 0.5
-  "*Idle time delay before updating various things on the screen.
+  "Idle time delay before updating various things on the screen.
 Various Emacs features that update auxiliary information when point moves
 wait this many seconds after Emacs becomes idle before doing an update."
   :type 'number
@@ -75,19 +78,22 @@ If BUFFER is non-nil, ignore occurrences of that buffer in LIST."
     (car list)))
 
 (defun last-buffer (&optional buffer visible-ok frame)
-  "Return the last non-hidden displayable buffer in the buffer list.
-If BUFFER is non-nil, last-buffer will ignore that buffer.
+  "Return the last buffer in FRAME's buffer list.
+If BUFFER is the last buffer, return the preceding buffer instead.
 Buffers not visible in windows are preferred to visible buffers,
 unless optional argument VISIBLE-OK is non-nil.
-If the optional third argument FRAME is non-nil, use that frame's
-buffer list instead of the selected frame's buffer list.
-If no other buffer exists, the buffer `*scratch*' is returned."
+Optional third argument FRAME nil or omitted means use the
+selected frame's buffer list.
+If no such buffer exists, return the buffer `*scratch*', creating
+it if necessary."
   (setq frame (or frame (selected-frame)))
   (or (get-next-valid-buffer (nreverse (buffer-list frame))
                             buffer visible-ok frame)
-      (progn
-       (set-buffer-major-mode (get-buffer-create "*scratch*"))
-       (get-buffer "*scratch*"))))
+      (get-buffer "*scratch*")
+      (let ((scratch (get-buffer-create "*scratch*")))
+       (set-buffer-major-mode scratch)
+       scratch)))
+
 (defun next-buffer ()
   "Switch to the next buffer in cyclic order."
   (interactive)
@@ -115,7 +121,7 @@ If no other buffer exists, the buffer `*scratch*' is returned."
   :version "22.1")
 
 (defcustom next-error-highlight 0.5
-  "*Highlighting of locations in selected source buffers.
+  "Highlighting of locations in selected source buffers.
 If a number, highlight the locus in `next-error' face for the given time
 in seconds, or until the next command is executed.
 If t, highlight the locus until the next command is executed, or until
@@ -130,7 +136,7 @@ If `fringe-arrow', indicate the locus by the fringe arrow."
   :version "22.1")
 
 (defcustom next-error-highlight-no-select 0.5
-  "*Highlighting of locations in `next-error-no-select'.
+  "Highlighting of locations in `next-error-no-select'.
 If number, highlight the locus in `next-error' face for given time in seconds.
 If t, highlight the locus indefinitely until some other locus replaces it.
 If nil, don't highlight the locus in the source buffer.
@@ -143,7 +149,7 @@ If `fringe-arrow', indicate the locus by the fringe arrow."
   :version "22.1")
 
 (defcustom next-error-recenter nil
-  "*Display the line in the visited source file recentered as specified.
+  "Display the line in the visited source file recentered as specified.
 If non-nil, the value is passed directly to `recenter'."
   :type '(choice (integer :tag "Line to recenter to")
                  (const :tag "Center of window" (4))
@@ -152,7 +158,7 @@ If non-nil, the value is passed directly to `recenter'."
   :version "23.1")
 
 (defcustom next-error-hook nil
-  "*List of hook functions run by `next-error' after visiting source file."
+  "List of hook functions run by `next-error' after visiting source file."
   :type 'hook
   :group 'next-error)
 
@@ -404,7 +410,7 @@ Other major modes are defined by comparison with this one."
     (define-key map "<" 'beginning-of-buffer)
     (define-key map "g" 'revert-buffer)
     map))
-   
+
 (put 'special-mode 'mode-class 'special)
 (define-derived-mode special-mode nil "Special"
   "Parent major mode from which special major modes should inherit."
@@ -457,8 +463,8 @@ than the value of `fill-column' and ARG is nil."
        (beforepos (point)))
     (if flag (backward-char 1))
     ;; Call self-insert so that auto-fill, abbrev expansion etc. happens.
-    ;; Set last-command-char to tell self-insert what to insert.
-    (let ((last-command-char ?\n)
+    ;; Set last-command-event to tell self-insert what to insert.
+    (let ((last-command-event ?\n)
          ;; Don't auto-fill if we have a numeric argument.
          ;; Also not if flag is true (it would fill wrong line);
          ;; there is no need to since we're at BOL.
@@ -665,6 +671,7 @@ column specified by the function `current-left-margin'."
 (defun quoted-insert (arg)
   "Read next input character and insert it.
 This is useful for inserting control characters.
+With argument, insert ARG copies of the character.
 
 If the first character you type after this command is an octal digit,
 you should type a sequence of octal digits which specify a character code.
@@ -687,13 +694,14 @@ useful for editing binary files."
                         (eq overwrite-mode 'overwrite-mode-binary))
                     (read-quoted-char)
                   (read-char)))))
-    ;; Assume character codes 0240 - 0377 stand for characters in some
-    ;; single-byte character set, and convert them to Emacs
-    ;; characters.
-    (if (and enable-multibyte-characters
-            (>= char ?\240)
-            (<= char ?\377))
-       (setq char (unibyte-char-to-multibyte char)))
+    ;; This used to assume character codes 0240 - 0377 stand for
+    ;; characters in some single-byte character set, and converted them
+    ;; to Emacs characters.  But in 23.1 this feature is deprecated
+    ;; in favor of inserting the corresponding Unicode characters.
+    ;; (if (and enable-multibyte-characters
+    ;;          (>= char ?\240)
+    ;;          (<= char ?\377))
+    ;;     (setq char (unibyte-char-to-multibyte char)))
     (if (> arg 0)
        (if (eq overwrite-mode 'overwrite-mode-binary)
            (delete-char arg)))
@@ -832,15 +840,16 @@ that uses or sets the mark."
 
 ;; Counting lines, one way or another.
 
-(defun goto-line (arg &optional buffer)
-  "Goto line ARG, counting from line 1 at beginning of buffer.
-Normally, move point in the current buffer, and leave mark at previous
-position.  With just \\[universal-argument] as argument, move point
-in the most recently displayed other buffer, and switch to it.
-When called from Lisp code, the optional argument BUFFER specifies
-a buffer to switch to.
+(defun goto-line (line &optional buffer)
+  "Goto LINE, counting from line 1 at beginning of buffer.
+Normally, move point in the current buffer, and leave mark at the
+previous position.  With just \\[universal-argument] as argument,
+move point in the most recently selected other buffer, and switch
+to it.  When called from Lisp code, the optional argument BUFFER
+specifies a buffer to switch to.
 
-If there's a number in the buffer at point, it is the default for ARG."
+If there's a number in the buffer at point, it is the default for
+LINE."
   (interactive
    (if (and current-prefix-arg (not (consp current-prefix-arg)))
        (list (prefix-numeric-value current-prefix-arg))
@@ -882,8 +891,8 @@ If there's a number in the buffer at point, it is the default for ARG."
     (widen)
     (goto-char 1)
     (if (eq selective-display t)
-       (re-search-forward "[\n\C-m]" nil 'end (1- arg))
-      (forward-line (1- arg)))))
+       (re-search-forward "[\n\C-m]" nil 'end (1- line))
+      (forward-line (1- line)))))
 
 (defun count-lines-region (start end)
   "Print number of lines and characters in the region."
@@ -1038,6 +1047,11 @@ in *Help* buffer.  See also the command `describe-char'."
 (defvar minibuffer-completing-symbol nil
   "Non-nil means completing a Lisp symbol in the minibuffer.")
 
+(defvar minibuffer-default nil
+  "The current default value or list of default values in the minibuffer.
+The functions `read-from-minibuffer' and `completing-read' bind
+this variable locally.")
+
 (defcustom eval-expression-print-level 4
   "Value for `print-level' while printing value in `eval-expression'.
 A value of nil means no limit."
@@ -1147,9 +1161,10 @@ the minibuffer, then read and evaluate the result."
 A complex command is one which used the minibuffer.
 The command is placed in the minibuffer as a Lisp form for editing.
 The result is executed, repeating the command as changed.
-If the command has been changed or is not the most recent previous command
-it is added to the front of the command history.
-You can use the minibuffer history commands \\<minibuffer-local-map>\\[next-history-element] and \\[previous-history-element]
+If the command has been changed or is not the most recent previous
+command it is added to the front of the command history.
+You can use the minibuffer history commands \
+\\<minibuffer-local-map>\\[next-history-element] and \\[previous-history-element]
 to get different commands to edit and resubmit."
   (interactive "p")
   (let ((elt (nth (1- arg) command-history))
@@ -1212,7 +1227,7 @@ in this use of the minibuffer.")
   (constrain-to-field nil (point-max)))
 
 (defcustom minibuffer-history-case-insensitive-variables nil
-  "*Minibuffer history variables for which matching should ignore case.
+  "Minibuffer history variables for which matching should ignore case.
 If a history variable is a member of this list, then the
 \\[previous-matching-history-element] and \\[next-matching-history-element]\
  commands ignore case when searching it, regardless of `case-fold-search'."
@@ -1319,8 +1334,8 @@ makes the search case-sensitive."
 (defvar minibuffer-temporary-goal-position nil)
 
 (defvar minibuffer-default-add-function 'minibuffer-default-add-completions
-  "Function run by `goto-history-element' before consuming `minibuffer-default'.
-This is useful to dynamically add more elements to the list `minibuffer-default'
+  "Function run by `goto-history-element' before consuming default values.
+This is useful to dynamically add more elements to the list of default values
 when `goto-history-element' reaches the end of this list.
 Before calling this function `goto-history-element' sets the variable
 `minibuffer-default-add-done' to t, so it will call this function only
@@ -1555,7 +1570,7 @@ Otherwise, it displays the standard isearch message returned from
     (message "")))
 
 (defun minibuffer-history-isearch-wrap ()
-  "Wrap the minibuffer history search when search is failed.
+  "Wrap the minibuffer history search when search fails.
 Move point to the first history element for a forward search,
 or to the last history element for a backward search."
   (unless isearch-word
@@ -1577,7 +1592,7 @@ in the search status stack."
 
 (defun minibuffer-history-isearch-pop-state (cmd hist-pos)
   "Restore the minibuffer history search state.
-Go to the history element by the absolute history position `hist-pos'."
+Go to the history element by the absolute history position HIST-POS."
   (goto-history-element hist-pos))
 
 \f
@@ -1602,7 +1617,7 @@ If t, we undid all the way to the end of it.")
 (defun undo (&optional arg)
   "Undo some previous changes.
 Repeat this command to undo more changes.
-A numeric argument serves as a repeat count.
+A numeric ARG serves as a repeat count.
 
 In Transient Mark mode when the mark is active, only undo changes within
 the current region.  Similarly, when not in Transient Mark mode, just \\[universal-argument]
@@ -1704,7 +1719,7 @@ No argument or nil as argument means do this for the current buffer."
 (defun undo-only (&optional arg)
   "Undo some previous changes.
 Repeat this command to undo more changes.
-A numeric argument serves as a repeat count.
+A numeric ARG serves as a repeat count.
 Contrary to `undo', this will not redo a previous undo."
   (interactive "*p")
   (let ((undo-no-redo t)) (undo arg)))
@@ -1721,6 +1736,9 @@ then call `undo-more' one or more times to undo them."
       (error (concat "No further undo information"
                     (and undo-in-region " for region"))))
   (let ((undo-in-progress t))
+    ;; Note: The following, while pulling elements off
+    ;; `pending-undo-list' will call primitive change functions which
+    ;; will push more elements onto `buffer-undo-list'.
     (setq pending-undo-list (primitive-undo n pending-undo-list))
     (if (null pending-undo-list)
        (setq pending-undo-list t))))
@@ -1977,8 +1995,8 @@ stdout will be intermixed in the output stream.")
 (declare-function mailcap-file-default-commands "mailcap" (files))
 
 (defun minibuffer-default-add-shell-commands ()
-  "Return a list of all commands associted with the current file.
-This function is used to add all related commands retieved by `mailcap'
+  "Return a list of all commands associated with the current file.
+This function is used to add all related commands retrieved by `mailcap'
 to the end of the list of defaults just after the default value."
   (interactive)
   (let* ((filename (if (listp minibuffer-default)
@@ -1993,29 +2011,40 @@ to the end of the list of defaults just after the default value."
        (append minibuffer-default commands)
       (cons minibuffer-default commands))))
 
+(defvar shell-delimiter-argument-list)
+(defvar shell-file-name-chars)
+(defvar shell-file-name-quote-list)
+
 (defun minibuffer-complete-shell-command ()
   "Dynamically complete shell command at point."
   (interactive)
   (require 'shell)
-  (run-hook-with-args-until-success 'shell-dynamic-complete-functions))
+  (let ((comint-delimiter-argument-list shell-delimiter-argument-list)
+       (comint-file-name-chars shell-file-name-chars)
+       (comint-file-name-quote-list shell-file-name-quote-list))
+    (run-hook-with-args-until-success 'shell-dynamic-complete-functions)))
 
 (defvar minibuffer-local-shell-command-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map minibuffer-local-map)
     (define-key map "\t" 'minibuffer-complete-shell-command)
     map)
-  "Keymap used for completiing shell commands in minibufffer.")
+  "Keymap used for completing shell commands in minibuffer.")
 
 (defun read-shell-command (prompt &optional initial-contents hist &rest args)
   "Read a shell command from the minibuffer.
 The arguments are the same as the ones of `read-from-minibuffer',
 except READ and KEYMAP are missing and HIST defaults
 to `shell-command-history'."
-  (apply 'read-from-minibuffer prompt initial-contents
-         minibuffer-local-shell-command-map
-         nil
-         (or hist 'shell-command-history)
-         args))
+  (minibuffer-with-setup-hook
+      (lambda ()
+       (set (make-local-variable 'minibuffer-default-add-function)
+            'minibuffer-default-add-shell-commands))
+    (apply 'read-from-minibuffer prompt initial-contents
+          minibuffer-local-shell-command-map
+          nil
+          (or hist 'shell-command-history)
+          args)))
 
 (defun shell-command (command &optional output-buffer error-buffer)
   "Execute string COMMAND in inferior shell; display output, if any.
@@ -2033,7 +2062,7 @@ there, but it is nonetheless available in buffer `*Shell Command
 Output*' even though that buffer is not automatically displayed.
 
 To specify a coding system for converting non-ASCII characters
-in the shell command output, use \\[universal-coding-system-argument]
+in the shell command output, use \\[universal-coding-system-argument] \
 before this command.
 
 Noninteractive callers can specify coding systems by binding
@@ -2051,8 +2080,8 @@ and you did not specify \"insert it in the current buffer\",
 the output can be displayed in the echo area or in its buffer.
 If the output is short enough to display in the echo area
 \(determined by the variable `max-mini-window-height' if
-`resize-mini-windows' is non-nil), it is shown there.  Otherwise,
-the buffer containing the output is displayed.
+`resize-mini-windows' is non-nil), it is shown there.
+Otherwise,the buffer containing the output is displayed.
 
 If there is output and an error, and you did not specify \"insert it
 in the current buffer\", a message about the error goes at the end
@@ -2069,13 +2098,9 @@ specifies the value of ERROR-BUFFER."
 
   (interactive
    (list
-    (minibuffer-with-setup-hook
-       (lambda ()
-         (set (make-local-variable 'minibuffer-default-add-function)
-              'minibuffer-default-add-shell-commands))
-      (read-shell-command "Shell command: " nil nil
-                         (and buffer-file-name
-                              (file-relative-name buffer-file-name))))
+    (read-shell-command "Shell command: " nil nil
+                       (and buffer-file-name
+                            (file-relative-name buffer-file-name)))
     current-prefix-arg
     shell-command-default-error-buffer))
   ;; Look for a handler in case default-directory is a remote file name.
@@ -2470,7 +2495,6 @@ objects of file handler invocation."
     (if fh (apply fh 'start-file-process name buffer program program-args)
       (apply 'start-process name buffer program program-args))))
 
-
 \f
 (defvar universal-argument-map
   (let ((map (make-sparse-keymap)))
@@ -2572,9 +2596,9 @@ These commands include \\[set-mark-command] and \\[start-kbd-macro]."
   "Part of the numeric argument for the next command.
 \\[universal-argument] following digits or minus sign ends the argument."
   (interactive "P")
-  (let* ((char (if (integerp last-command-char)
-                  last-command-char
-                (get last-command-char 'ascii-character)))
+  (let* ((char (if (integerp last-command-event)
+                  last-command-event
+                (get last-command-event 'ascii-character)))
         (digit (- (logand char ?\177) ?0)))
     (cond ((integerp arg)
           (setq prefix-arg (+ (* arg 10)
@@ -2691,7 +2715,7 @@ string, then the caller of the function \(usually `current-kill')
 should put this string in the kill ring as the latest kill.
 
 This function may also return a list of strings if the window
-system supports multiple selections. The first string will be
+system supports multiple selections.  The first string will be
 used as the pasted text, but the other will be placed in the
 kill ring for easy access via `yank-pop'.
 
@@ -2717,7 +2741,7 @@ interaction; you may want to use them instead of manipulating the kill
 ring directly.")
 
 (defcustom kill-ring-max 60
-  "*Maximum length of kill ring before oldest elements are thrown away."
+  "Maximum length of kill ring before oldest elements are thrown away."
   :type 'integer
   :group 'killing)
 
@@ -2782,10 +2806,10 @@ If `interprogram-cut-function' is set, pass the resulting kill to it."
 
 (defun current-kill (n &optional do-not-move)
   "Rotate the yanking point by N places, and then return that kill.
-If N is zero, `interprogram-paste-function' is set, and calling it returns a
-string or list of strings, then that string (or list) is added to the front
-of the kill ring and the string (or first string in the list) is returned as
-the latest kill.
+If N is zero, `interprogram-paste-function' is set, and calling
+it returns a string or list of strings, then that string (or
+list) is added to the front of the kill ring and the string (or
+first string in the list) is returned as the latest kill.
 
 If N is not zero, and if `yank-pop-change-selection' is
 non-nil, use `interprogram-cut-function' to transfer the
@@ -2825,7 +2849,7 @@ move the yanking point; just return the Nth kill forward."
 ;;;; Commands for manipulating the kill ring.
 
 (defcustom kill-read-only-ok nil
-  "*Non-nil means don't signal an error for killing read-only text."
+  "Non-nil means don't signal an error for killing read-only text."
   :type 'boolean
   :group 'killing)
 
@@ -3060,7 +3084,7 @@ See also the command `yank-pop' (\\[yank-pop])."
 
 (defun rotate-yank-pointer (arg)
   "Rotate the yanking point in the kill ring.
-With argument, rotate that many kills forward (or backward, if negative)."
+With ARG, rotate that many kills forward (or backward, if negative)."
   (interactive "p")
   (current-kill arg))
 \f
@@ -3079,7 +3103,7 @@ With argument, rotate that many kills forward (or backward, if negative)."
   (kill-region (point) (forward-point (- arg))))
 
 (defcustom backward-delete-char-untabify-method 'untabify
-  "*The method for untabifying when deleting backward.
+  "The method for untabifying when deleting backward.
 Can be `untabify' -- turn a tab to many spaces, then delete one space;
        `hungry' -- delete all whitespace, both tabs and spaces;
        `all' -- delete all whitespace, including tabs, spaces and newlines;
@@ -3119,7 +3143,7 @@ and KILLP is t if a prefix arg was specified."
    killp))
 
 (defun zap-to-char (arg char)
-  "Kill up to and including ARG'th occurrence of CHAR.
+  "Kill up to and including ARGth occurrence of CHAR.
 Case is ignored if `case-fold-search' is non-nil in the current buffer.
 Goes backward if ARG is negative; error if CHAR not found."
   (interactive "p\ncZap to char: ")
@@ -3133,13 +3157,13 @@ Goes backward if ARG is negative; error if CHAR not found."
 ;; kill-line and its subroutines.
 
 (defcustom kill-whole-line nil
-  "*If non-nil, `kill-line' with no arg at beg of line kills the whole line."
+  "If non-nil, `kill-line' with no arg at beg of line kills the whole line."
   :type 'boolean
   :group 'killing)
 
 (defun kill-line (&optional arg)
   "Kill the rest of the current line; if no nonblanks there, kill thru newline.
-With prefix argument, kill that many lines from point.
+With prefix argument ARG, kill that many lines from point.
 Negative arguments kill lines backward.
 With zero argument, kills the text before point on the current line.
 
@@ -3190,11 +3214,12 @@ even beep.)"
 
 (defun kill-whole-line (&optional arg)
   "Kill current line.
-With prefix arg, kill that many lines starting from the current line.
-If arg is negative, kill backward.  Also kill the preceding newline.
+With prefix ARG, kill that many lines starting from the current line.
+If ARG is negative, kill backward.  Also kill the preceding newline.
 \(This is meant to make \\[repeat] work well with negative arguments.\)
-If arg is zero, kill current line but exclude the trailing newline."
+If ARG is zero, kill current line but exclude the trailing newline."
   (interactive "p")
+  (or arg (setq arg 1))
   (if (and (> arg 0) (eobp) (save-excursion (forward-visible-line 0) (eobp)))
       (signal 'end-of-buffer nil))
   (if (and (< arg 0) (bobp) (save-excursion (end-of-visible-line) (bobp)))
@@ -3482,32 +3507,38 @@ store it in a Lisp variable.  Example:
     (set-marker (mark-marker) nil)))
 
 (defcustom use-empty-active-region nil
-  "If non-nil, an active region takes control even if empty.
-This applies to certain commands which, in Transient Mark mode,
-apply to the active region if there is one.  If the setting is t,
-these commands apply to an empty active region if there is one.
-If the setting is nil, these commands treat an empty active
-region as if it were not active."
+  "Whether \"region-aware\" commands should act on empty regions.
+If nil, region-aware commands treat empty regions as inactive.
+If non-nil, region-aware commands treat the region as active as
+long as the mark is active, even if the region is empty.
+
+Region-aware commands are those that act on the region if it is
+active and Transient Mark mode is enabled, and on the text near
+point otherwise."
   :type 'boolean
   :version "23.1"
   :group 'editing-basics)
 
 (defun use-region-p ()
-  "Return t if certain commands should apply to the region.
-Certain commands normally apply to text near point,
-but in Transient Mark mode when the mark is active they apply
-to the region instead.  Such commands should use this subroutine to
-test whether to do that.
-
-This function also obeys `use-empty-active-region'."
+  "Return t if the region is active and it is appropriate to act on it.
+This is used by commands that act specially on the region under
+Transient Mark mode.  It returns t if and only if Transient Mark
+mode is enabled, the mark is active, and the region is non-empty.
+If `use-empty-active-region' is non-nil, it returns t even if the
+region is empty.
+
+For some commands, it may be appropriate to disregard the value
+of `use-empty-active-region'; in that case, use `region-active-p'."
   (and (region-active-p)
        (or use-empty-active-region (> (region-end) (region-beginning)))))
 
 (defun region-active-p ()
   "Return t if Transient Mark mode is enabled and the mark is active.
-This is NOT the best function to use to test whether a command should
-operate on the region instead of the usual behavior -- for that,
-use `use-region-p'."
+
+Most commands that act on the region if it is active and
+Transient Mark mode is enabled, and on the text near point
+otherwise, should use `use-region-p' instead.  That function
+checks the value of `use-empty-active-region' as well."
   (and transient-mark-mode mark-active))
 
 (defvar mark-ring nil
@@ -3516,7 +3547,7 @@ use `use-region-p'."
 (put 'mark-ring 'permanent-local t)
 
 (defcustom mark-ring-max 16
-  "*Maximum size of mark ring.  Start discarding off end if gets this big."
+  "Maximum size of mark ring.  Start discarding off end if gets this big."
   :type 'integer
   :group 'editing-basics)
 
@@ -3524,14 +3555,14 @@ use `use-region-p'."
   "The list of saved global marks, most recent first.")
 
 (defcustom global-mark-ring-max 16
-  "*Maximum size of global mark ring.  \
+  "Maximum size of global mark ring.  \
 Start discarding off end if gets this big."
   :type 'integer
   :group 'editing-basics)
 
 (defun pop-to-mark-command ()
-  "Jump to mark, and pop a new position for mark off the ring
-\(does not affect global mark ring\)."
+  "Jump to mark, and pop a new position for mark off the ring.
+\(Does not affect global mark ring\)."
   (interactive)
   (if (null (mark t))
       (error "No mark set in this buffer")
@@ -3542,7 +3573,7 @@ Start discarding off end if gets this big."
 
 (defun push-mark-command (arg &optional nomsg)
   "Set mark at where point is.
-If no prefix arg and mark is already set there, just activate it.
+If no prefix ARG and mark is already set there, just activate it.
 Display `Mark set' unless the optional second arg NOMSG is non-nil."
   (interactive "P")
   (let ((mark (marker-position (mark-marker))))
@@ -3554,7 +3585,7 @@ Display `Mark set' unless the optional second arg NOMSG is non-nil."
        (message "Mark activated")))))
 
 (defcustom set-mark-command-repeat-pop nil
-  "*Non-nil means repeating \\[set-mark-command] after popping mark pops it again.
+  "Non-nil means repeating \\[set-mark-command] after popping mark pops it again.
 That means that C-u \\[set-mark-command] \\[set-mark-command]
 will pop the mark twice, and
 C-u \\[set-mark-command] \\[set-mark-command] \\[set-mark-command]
@@ -3565,6 +3596,11 @@ after C-u \\[set-mark-command]."
   :type 'boolean
   :group 'editing-basics)
 
+(defcustom set-mark-default-inactive nil
+  "If non-nil, setting the mark does not activate it.
+This causes \\[set-mark-command] and \\[exchange-point-and-mark] to
+behave the same whether or not `transient-mark-mode' is enabled.")
+
 (defun set-mark-command (arg)
   "Set the mark where point is, or jump to the mark.
 Setting the mark also alters the region, which is the text
@@ -3626,7 +3662,8 @@ purposes.  See the documentation of `set-mark' for more information."
       (activate-mark)
       (message "Mark activated")))
    (t
-    (push-mark-command nil))))
+    (push-mark-command nil)
+    (if set-mark-default-inactive (deactivate-mark)))))
 
 (defun push-mark (&optional location nomsg activate)
   "Set mark at LOCATION (point, by default) and push old mark on mark ring.
@@ -3677,9 +3714,9 @@ Does not set point.  Does nothing if mark ring is empty."
 This command works even when the mark is not active,
 and it reactivates the mark.
 
-If Transient Mark mode is on, a prefix arg deactivates the mark
+If Transient Mark mode is on, a prefix ARG deactivates the mark
 if it is active, and otherwise avoids reactivating it.  If
-Transient Mark mode is off, a prefix arg enables Transient Mark
+Transient Mark mode is off, a prefix ARG enables Transient Mark
 mode temporarily."
   (interactive "P")
   (let ((omark (mark t))
@@ -3689,6 +3726,7 @@ mode temporarily."
     (deactivate-mark)
     (set-mark (point))
     (goto-char omark)
+    (if set-mark-default-inactive (deactivate-mark))
     (cond (temp-highlight
           (setq transient-mark-mode (cons 'only transient-mark-mode)))
          ((or (and arg (region-active-p)) ; (xor arg (not (region-active-p)))
@@ -3725,7 +3763,7 @@ With optional arg DEACTIVATE, only perform region deactivation."
 
 (define-minor-mode transient-mark-mode
   "Toggle Transient Mark mode.
-With arg, turn Transient Mark mode on if arg is positive, off otherwise.
+With ARG, turn Transient Mark mode on if ARG is positive, off otherwise.
 
 In Transient Mark mode, when the mark is active, the region is highlighted.
 Changing the buffer \"deactivates\" the mark.
@@ -3758,10 +3796,9 @@ Non-nil also enables highlighting of the region whenever the mark is active.
 The variable `highlight-nonselected-windows' controls whether to highlight
 all windows or just the selected window.
 
-If the value is `lambda', that enables Transient Mark mode
-temporarily.  After any subsequent action that would normally
-deactivate the mark (such as buffer modification), Transient Mark mode
-is turned off.
+If the value is `lambda', that enables Transient Mark mode temporarily.
+After any subsequent action that would normally deactivate the mark
+\(such as buffer modification), Transient Mark mode is turned off.
 
 If the value is (only . OLDVAL), that enables Transient Mark mode
 temporarily.  After any subsequent point motion command that is not
@@ -3800,7 +3837,7 @@ as a fallback, and won't change the buffer bounds.")
     (switch-to-buffer buffer)))
 \f
 (defcustom next-line-add-newlines nil
-  "*If non-nil, `next-line' inserts newline to avoid `end of buffer' error."
+  "If non-nil, `next-line' inserts newline to avoid `end of buffer' error."
   :type 'boolean
   :version "21.1"
   :group 'editing-basics)
@@ -3877,7 +3914,7 @@ to use and more reliable (no dependence on goal column, etc.)."
   nil)
 
 (defcustom track-eol nil
-  "*Non-nil means vertical motion starting at end of line keeps to ends of lines.
+  "Non-nil means vertical motion starting at end of line keeps to ends of lines.
 This means moving to the end of each line moved onto.
 The beginning of a blank line does not count as the end of a line.
 This has no effect when `line-move-visual' is non-nil."
@@ -3885,7 +3922,7 @@ This has no effect when `line-move-visual' is non-nil."
   :group 'editing-basics)
 
 (defcustom goal-column nil
-  "*Semipermanent goal column for vertical motion, as set by \\[set-goal-column], or nil."
+  "Semipermanent goal column for vertical motion, as set by \\[set-goal-column], or nil."
   :type '(choice integer
                 (const :tag "None" nil))
   :group 'editing-basics)
@@ -3901,7 +3938,7 @@ the `track-eol' feature is doing its job, the value is
 `most-positive-fixnum'.")
 
 (defcustom line-move-ignore-invisible t
-  "*Non-nil means \\[next-line] and \\[previous-line] ignore invisible lines.
+  "Non-nil means \\[next-line] and \\[previous-line] ignore invisible lines.
 Outline mode sets this."
   :type 'boolean
   :group 'editing-basics)
@@ -3998,9 +4035,12 @@ into account variable-width characters and line continuation."
               (or (memq last-command '(next-line previous-line))
                   ;; In case we're called from some other command.
                   (eq last-command this-command)))
-    (let ((x (car (nth 2 (posn-at-point)))))
-      (when x
-       (setq temporary-goal-column (/ (float x) (frame-char-width))))))
+    (let ((posn (posn-at-point))
+         x)
+      (cond ((eq (nth 1 posn) 'right-fringe) ; overflow-newline-into-fringe
+            (setq temporary-goal-column (- (window-width) 1)))
+           ((setq x (car (nth 2 posn)))
+            (setq temporary-goal-column (/ (float x) (frame-char-width)))))))
   (or (= (vertical-motion
          (cons (or goal-column (truncate temporary-goal-column)) arg))
         arg)
@@ -4262,12 +4302,14 @@ and `current-column' to be able to ignore invisible text."
 
 (defun move-end-of-line (arg)
   "Move point to end of current line as displayed.
-\(If there's an image in the line, this disregards newlines
-which are part of the text that the image rests on.)
-
 With argument ARG not nil or 1, move forward ARG - 1 lines first.
 If point reaches the beginning or end of buffer, it stops there.
-To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
+
+To ignore the effects of the `intangible' text or overlay
+property, bind `inhibit-point-motion-hooks' to t.
+If there is an image in the current line, this function
+disregards newlines that are part of the text on which the image
+rests."
   (interactive "^p")
   (or arg (setq arg 1))
   (let (done)
@@ -4346,7 +4388,7 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
   "Set the current horizontal position as a goal for \\[next-line] and \\[previous-line].
 Those commands will move to this position in the line moved to
 rather than trying to keep the same horizontal position.
-With a non-nil argument, clears out the goal column
+With a non-nil argument ARG, clears out the goal column
 so that \\[next-line] and \\[previous-line] resume vertical motion.
 The goal column is stored in the variable `goal-column'."
   (interactive "P")
@@ -4400,7 +4442,7 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
 If there are only whitespace characters there, kill through the
 newline as well.
 
-With prefix argument, kill that many lines from point.
+With prefix argument ARG, kill that many lines from point.
 Negative arguments kill lines backward.
 With zero argument, kill the text before point on the current line.
 
@@ -4448,7 +4490,7 @@ even beep.)"
 
 (defun next-logical-line (&optional arg try-vscroll)
   "Move cursor vertically down ARG lines.
-This is identical to `previous-line', except that it always moves
+This is identical to `next-line', except that it always moves
 by logical lines instead of visual lines, ignoring the value of
 the variable `line-move-visual'."
   (interactive "^p\np")
@@ -4476,8 +4518,10 @@ the variable `line-move-visual'."
     (define-key map [remap kill-line] 'kill-visual-line)
     (define-key map [remap move-beginning-of-line] 'beginning-of-visual-line)
     (define-key map [remap move-end-of-line]  'end-of-visual-line)
-    (define-key map "\M-[" 'previous-logical-line)
-    (define-key map "\M-]" 'next-logical-line)
+    ;; These keybindings interfere with xterm function keys.  Are
+    ;; there any other suitable bindings?
+    ;; (define-key map "\M-[" 'previous-logical-line)
+    ;; (define-key map "\M-]" 'next-logical-line)
     map))
 
 (defcustom visual-line-fringe-indicators '(nil nil)
@@ -4507,20 +4551,40 @@ other purposes."
                            (copy-tree fringe-indicator-alist)))))))
         (set-default symbol value)))
 
+(defvar visual-line--saved-state nil)
+
 (define-minor-mode visual-line-mode
-  "Redefine simple editing commands to act on visual lines, not logical lines."
+  "Redefine simple editing commands to act on visual lines, not logical lines.
+This also turns on `word-wrap' in the buffer."
   :keymap visual-line-mode-map
   :group 'visual-line
+  :lighter " wrap"
   (if visual-line-mode
       (progn
+       (set (make-local-variable 'visual-line--saved-state) nil)
+       ;; Save the local values of some variables, to be restored if
+       ;; visual-line-mode is turned off.
+       (dolist (var '(line-move-visual truncate-lines
+                      truncate-partial-width-windows
+                      word-wrap fringe-indicator-alist))
+         (if (local-variable-p var)
+             (push (cons var (symbol-value var))
+                   visual-line--saved-state)))
        (set (make-local-variable 'line-move-visual) t)
-       (setq word-wrap t)
-       (setq fringe-indicator-alist
+       (set (make-local-variable 'truncate-partial-width-windows) nil)
+       (setq truncate-lines nil
+             word-wrap t
+             fringe-indicator-alist
              (cons (cons 'continuation visual-line-fringe-indicators)
                    fringe-indicator-alist)))
     (kill-local-variable 'line-move-visual)
     (kill-local-variable 'word-wrap)
-    (kill-local-variable 'fringe-indicator-alist)))
+    (kill-local-variable 'truncate-lines)
+    (kill-local-variable 'truncate-partial-width-windows)
+    (kill-local-variable 'fringe-indicator-alist)
+    (dolist (saved visual-line--saved-state)
+      (set (make-local-variable (car saved)) (cdr saved)))
+    (kill-local-variable 'visual-line--saved-state)))
 
 (defun turn-on-visual-line-mode ()
   (visual-line-mode 1))
@@ -4692,7 +4756,7 @@ With argument 0, interchanges line point is in with line mark is in."
 \f
 (defun backward-word (&optional arg)
   "Move backward until encountering the beginning of a word.
-With argument, do this that many times."
+With argument ARG, do this that many times."
   (interactive "^p")
   (forward-word (- (or arg 1))))
 
@@ -4723,13 +4787,13 @@ it marks the next ARG words after the ones already marked."
 
 (defun kill-word (arg)
   "Kill characters forward until encountering the end of a word.
-With argument, do this that many times."
+With argument ARG, do this that many times."
   (interactive "p")
   (kill-region (point) (progn (forward-word arg) (point))))
 
 (defun backward-kill-word (arg)
   "Kill characters backward until encountering the beginning of a word.
-With argument, do this that many times."
+With argument ARG, do this that many times."
   (interactive "p")
   (kill-word (- arg)))
 
@@ -4773,7 +4837,7 @@ If optional arg REALLY-WORD is non-nil, it finds just a word."
        (buffer-substring-no-properties start end)))))
 \f
 (defcustom fill-prefix nil
-  "*String for filling to insert at front of new line, or nil for none."
+  "String for filling to insert at front of new line, or nil for none."
   :type '(choice (const :tag "None" nil)
                 string)
   :group 'fill)
@@ -4781,7 +4845,7 @@ If optional arg REALLY-WORD is non-nil, it finds just a word."
 (put 'fill-prefix 'safe-local-variable 'string-or-null-p)
 
 (defcustom auto-fill-inhibit-regexp nil
-  "*Regexp to match lines which should not be auto-filled."
+  "Regexp to match lines which should not be auto-filled."
   :type '(choice (const :tag "None" nil)
                 regexp)
   :group 'fill)
@@ -4923,7 +4987,7 @@ Some major modes set this.")
 ;; Add a global minor mode version of it.
 (defun auto-fill-mode (&optional arg)
   "Toggle Auto Fill mode.
-With arg, turn Auto Fill mode on if and only if arg is positive.
+With ARG, turn Auto Fill mode on if and only if ARG is positive.
 In Auto Fill mode, inserting a space at a column beyond `current-fill-column'
 automatically breaks the line at a previous space.
 
@@ -4997,8 +5061,8 @@ The variable `selective-display' has a separate value for each buffer."
 (defun toggle-truncate-lines (&optional arg)
   "Toggle whether to fold or truncate long lines for the current buffer.
 With prefix argument ARG, truncate long lines if ARG is positive,
-otherwise don't truncate them.  Note that in side-by-side
-windows, this command has no effect if `truncate-partial-width-windows'
+otherwise don't truncate them.  Note that in side-by-side windows,
+this command has no effect if `truncate-partial-width-windows'
 is non-nil."
   (interactive "P")
   (setq truncate-lines
@@ -5015,6 +5079,21 @@ is non-nil."
   (message "Truncate long lines %s"
           (if truncate-lines "enabled" "disabled")))
 
+(defun toggle-word-wrap (&optional arg)
+  "Toggle whether to use word-wrapping for continuation lines.
+With prefix argument ARG, wrap continuation lines at word boundaries
+if ARG is positive, otherwise wrap them at the right screen edge.
+This command toggles the value of `word-wrap'.  It has no effect
+if long lines are truncated."
+  (interactive "P")
+  (setq word-wrap
+       (if (null arg)
+           (not word-wrap)
+         (> (prefix-numeric-value arg) 0)))
+  (force-mode-line-update)
+  (message "Word wrapping %s"
+          (if word-wrap "enabled" "disabled")))
+
 (defvar overwrite-mode-textual " Ovwrt"
   "The string displayed in the mode line when in overwrite mode.")
 (defvar overwrite-mode-binary " Bin Ovwrt"
@@ -5059,7 +5138,7 @@ specialization of overwrite mode, entered by setting the
 
 (define-minor-mode line-number-mode
   "Toggle Line Number mode.
-With arg, turn Line Number mode on if arg is positive, otherwise
+With ARG, turn Line Number mode on if ARG is positive, otherwise
 turn it off.  When Line Number mode is enabled, the line number
 appears in the mode line.
 
@@ -5070,14 +5149,14 @@ and `line-number-display-limit-width'."
 
 (define-minor-mode column-number-mode
   "Toggle Column Number mode.
-With arg, turn Column Number mode on if arg is positive,
+With ARG, turn Column Number mode on if ARG is positive,
 otherwise turn it off.  When Column Number mode is enabled, the
 column number appears in the mode line."
   :global t :group 'mode-line)
 
 (define-minor-mode size-indication-mode
   "Toggle Size Indication mode.
-With arg, turn Size Indication mode on if arg is positive,
+With ARG, turn Size Indication mode on if ARG is positive,
 otherwise turn it off.  When Size Indication mode is enabled, the
 size of the accessible part of the buffer appears in the mode line."
   :global t :group 'mode-line)
@@ -5088,12 +5167,12 @@ size of the accessible part of the buffer appears in the mode line."
   :group 'paren-matching)
 
 (defcustom blink-matching-paren t
-  "*Non-nil means show matching open-paren when close-paren is inserted."
+  "Non-nil means show matching open-paren when close-paren is inserted."
   :type 'boolean
   :group 'paren-blinking)
 
 (defcustom blink-matching-paren-on-screen t
-  "*Non-nil means show matching open-paren when it is on screen.
+  "Non-nil means show matching open-paren when it is on screen.
 If nil, don't show it (but the open-paren can still be shown
 when it is off screen).
 
@@ -5104,18 +5183,18 @@ It is also ignored if `show-paren-mode' is enabled."
   :group 'paren-blinking)
 
 (defcustom blink-matching-paren-distance (* 25 1024)
-  "*If non-nil, maximum distance to search backwards for matching open-paren.
+  "If non-nil, maximum distance to search backwards for matching open-paren.
 If nil, search stops at the beginning of the accessible portion of the buffer."
   :type '(choice (const nil) integer)
   :group 'paren-blinking)
 
 (defcustom blink-matching-delay 1
-  "*Time in seconds to delay after showing a matching paren."
+  "Time in seconds to delay after showing a matching paren."
   :type 'number
   :group 'paren-blinking)
 
 (defcustom blink-matching-paren-dont-ignore-comments nil
-  "*If nil, `blink-matching-paren' ignores comments.
+  "If nil, `blink-matching-paren' ignores comments.
 More precisely, when looking for the matching parenthesis,
 it skips the contents of comments that end before point."
   :type 'boolean
@@ -5169,13 +5248,17 @@ it skips the contents of comments that end before point."
                  ;; a matching-char info, in which case the two CDRs
                  ;; should match.
                  (eq matching-paren (cdr (syntax-after (1- oldpos))))))
-        (message "Mismatched parentheses"))
+       (if (minibufferp)
+           (minibuffer-message " [Mismatched parentheses]")
+         (message "Mismatched parentheses")))
        ((not blinkpos)
         (or blink-matching-paren-distance
             ;; Don't complain when `$' with no blinkpos, because it
             ;; could just be the first one typed in the buffer.
             atdollar
-            (message "Unmatched parenthesis")))
+            (if (minibufferp)
+               (minibuffer-message " [Unmatched parenthesis]")
+             (message "Unmatched parenthesis"))))
        ((pos-visible-in-window-p blinkpos)
         ;; Matching open within window, temporarily move to blinkpos but only
         ;; if `blink-matching-paren-on-screen' is non-nil.
@@ -5218,7 +5301,6 @@ it skips the contents of comments that end before point."
             (message "Matches %s"
                      (substring-no-properties open-paren-line-string)))))))))
 
-;; Turned off because it makes dbx bomb out.
 (setq blink-paren-function 'blink-matching-open)
 \f
 ;; This executes C-g typed while Emacs is waiting for a command.
@@ -5279,7 +5361,7 @@ specification for `play-sound'."
 
 \f
 (defcustom read-mail-command 'rmail
-  "*Your preference for a mail reading package.
+  "Your preference for a mail reading package.
 This is used by some keybindings which support reading mail.
 See also `mail-user-agent' concerning sending mail."
   :type '(choice (function-item rmail)
@@ -5290,7 +5372,7 @@ See also `mail-user-agent' concerning sending mail."
   :group 'mail)
 
 (defcustom mail-user-agent 'sendmail-user-agent
-  "*Your preference for a mail composition package.
+  "Your preference for a mail composition package.
 Various Emacs Lisp packages (e.g. Reporter) require you to compose an
 outgoing email message.  This variable lets you specify which
 mail-sending package you prefer.
@@ -5520,11 +5602,15 @@ This also applies to other functions such as `choose-completion'
 and `mouse-choose-completion'.")
 
 (defvar completion-base-size nil
-  "Number of chars at beginning of minibuffer not involved in completion.
-This is a local variable in the completion list buffer
-but it talks about the buffer in `completion-reference-buffer'.
-If this is nil, it means to compare text to determine which part
-of the tail end of the buffer's text is involved in completion.")
+  "Number of chars before point not involved in completion.
+This is a local variable in the completion list buffer.
+It refers to the chars in the minibuffer if completing in the
+minibuffer, or in `completion-reference-buffer' otherwise.
+Only characters in the field at point are included.
+
+If nil, Emacs determines which part of the tail end of the
+buffer's text is involved in completion by comparing the text
+directly.")
 
 (defun delete-completion-window ()
   "Delete the completion list window.
@@ -5587,12 +5673,15 @@ With prefix argument N, move N items (negative N means move backward)."
     (setq completion (buffer-substring-no-properties beg end))
     (let ((owindow (selected-window)))
       (if (and (one-window-p t 'selected-frame)
-              (window-dedicated-p (selected-window)))
+              (window-dedicated-p owindow))
          ;; This is a special buffer's frame
          (iconify-frame (selected-frame))
        (or (window-dedicated-p (selected-window))
            (bury-buffer)))
-      (select-window owindow))
+      (select-window
+       (or (and (buffer-live-p buffer)
+               (get-buffer-window buffer))
+          owindow)))
     (choose-completion-string completion buffer base-size)))
 
 ;; Delete the longest partial match for STRING
@@ -5740,8 +5829,8 @@ Called from `temp-buffer-show-hook'."
         (set (make-local-variable 'completion-base-size) base-size))
       (set (make-local-variable 'completion-reference-buffer) mainbuf)
       (unless completion-base-size
-        ;; This may be needed for old completion packages which don't use
-        ;; completion-all-completions-with-base-size yet.
+        ;; This shouldn't be needed any more, but further analysis is needed
+        ;; to make sure it's the case.
         (setq completion-base-size
               (cond
                (minibuffer-completing-file-name
@@ -6009,7 +6098,9 @@ Give the indirect buffer name NEWNAME.  Interactively, read NEWNAME
 from the minibuffer when invoked with a prefix arg.  If NEWNAME is nil
 or if not called with a prefix arg, NEWNAME defaults to the current
 buffer's name.  The name is modified by adding a `<N>' suffix to it
-or by incrementing the N in an existing suffix.
+or by incrementing the N in an existing suffix.  Trying to clone a
+buffer whose major mode symbol has a non-nil `no-clone-indirect'
+property results in an error.
 
 DISPLAY-FLAG non-nil means show the new buffer with `pop-to-buffer'.
 This is always done when called interactively.
@@ -6097,7 +6188,6 @@ call `normal-erase-is-backspace-mode' (which see) instead."
        (if (if (eq normal-erase-is-backspace 'maybe)
                (and (not noninteractive)
                     (or (memq system-type '(ms-dos windows-nt))
-                        (eq window-system 'mac)
                         (and (memq window-system '(x))
                              (fboundp 'x-backspace-delete-keys-p)
                              (x-backspace-delete-keys-p))
@@ -6112,7 +6202,7 @@ call `normal-erase-is-backspace-mode' (which see) instead."
 (defun normal-erase-is-backspace-mode (&optional arg)
   "Toggle the Erase and Delete mode of the Backspace and Delete keys.
 
-With numeric arg, turn the mode on if and only if ARG is positive.
+With numeric ARG, turn the mode on if and only if ARG is positive.
 
 On window systems, when this mode is on, Delete is mapped to C-d
 and Backspace is mapped to DEL; when this mode is off, both
@@ -6147,11 +6237,10 @@ See also `normal-erase-is-backspace'."
     (set-terminal-parameter nil 'normal-erase-is-backspace
                            (if enabled 1 0))
 
-    (cond ((or (memq window-system '(x w32 mac ns pc))
+    (cond ((or (memq window-system '(x w32 ns pc))
               (memq system-type '(ms-dos windows-nt)))
           (let* ((bindings
-                  `(([C-delete] [C-backspace])
-                    ([M-delete] [M-backspace])
+                  `(([M-delete] [M-backspace])
                     ([C-M-delete] [C-M-backspace])
                     (,esc-map
                      [C-delete] [C-backspace])))
@@ -6201,8 +6290,8 @@ With argument ARG turn Visible mode on if ARG is positive, otherwise
 turn it off.
 
 Enabling Visible mode makes all invisible text temporarily visible.
-Disabling Visible mode turns off that effect.  Visible mode
-works by saving the value of `buffer-invisibility-spec' and setting it to nil."
+Disabling Visible mode turns off that effect.  Visible mode works by
+saving the value of `buffer-invisibility-spec' and setting it to nil."
   :lighter " Vis"
   :group 'editing-basics
   (when (local-variable-p 'vis-mode-saved-buffer-invisibility-spec)
@@ -6213,6 +6302,16 @@ works by saving the value of `buffer-invisibility-spec' and setting it to nil."
         buffer-invisibility-spec)
     (setq buffer-invisibility-spec nil)))
 \f
+;; Partial application of functions (similar to "currying").
+(defun apply-partially (fun &rest args)
+  "Return a function that is a partial application of FUN to ARGS.
+ARGS is a list of the first N arguments to pass to FUN.
+The result is a new function which does the same as FUN, except that
+the first N arguments are fixed at the values with which this function
+was called."
+  (lexical-let ((fun fun) (args1 args))
+    (lambda (&rest args2) (apply fun (append args1 args2)))))
+\f
 ;; Minibuffer prompt stuff.
 
 ;(defun minibuffer-prompt-modification (start end)
@@ -6277,8 +6376,8 @@ warning using STRING as the message.")
              (boundp symbol)
              (or (eq symbol t)
                  (and (stringp (setq symbol (eval symbol)))
-                      (string-match (nth 2 list) symbol)))
-             (display-warning :warning (nth 3 list))))
+                      (string-match-p (nth 2 list) symbol)))
+             (display-warning package (nth 3 list) :warning)))
     (error nil)))
 
 (mapc (lambda (elem)