]> code.delx.au - gnu-emacs/blobdiff - lisp/simple.el
(read-shell-command): Typo.
[gnu-emacs] / lisp / simple.el
index e838731c1bef149ea22b215e55d35b2a267dfb67..901f9f7400e33fa2d6f90eca4a0cbbfdafb84526 100644 (file)
@@ -31,9 +31,8 @@
 
 ;;; Code:
 
-(eval-when-compile
-  (autoload 'widget-convert "wid-edit")
-  (autoload 'shell-mode "shell"))
+(declare-function widget-convert "wid-edit" (type &rest args))
+(declare-function shell-mode "shell" ())
 
 (defvar compilation-current-error)
 
@@ -820,10 +819,11 @@ that uses or sets the mark."
 
 (defun goto-line (arg &optional buffer)
   "Goto line ARG, counting from line 1 at beginning of buffer.
-Normally, move point in the current buffer.
-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.
+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.
 
 If there's a number in the buffer at point, it is the default for ARG."
   (interactive
@@ -860,6 +860,9 @@ If there's a number in the buffer at point, it is the default for ARG."
       (let ((window (get-buffer-window buffer)))
        (if window (select-window window)
          (switch-to-buffer-other-window buffer))))
+  ;; Leave mark at previous position
+  (or (and transient-mark-mode mark-active)
+      (push-mark))
   ;; Move to the specified line number in that buffer.
   (save-restriction
     (widen)
@@ -1918,6 +1921,30 @@ This buffer is used when `shell-command' or `shell-command-on-region'
 is run interactively.  A value of nil means that output to stderr and
 stdout will be intermixed in the output stream.")
 
+(defun minibuffer-complete-shell-command ()
+  "Dynamically complete shell command at point."
+  (interactive)
+  (require 'shell)
+  (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.")
+
+(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
+         (or keymap 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.
 With prefix argument, insert the COMMAND's output at point.
@@ -1968,8 +1995,7 @@ If it is nil, error output is mingled with regular output.
 In an interactive call, the variable `shell-command-default-error-buffer'
 specifies the value of ERROR-BUFFER."
 
-  (interactive (list (read-from-minibuffer "Shell command: "
-                                          nil nil nil 'shell-command-history)
+  (interactive (list (read-shell-command "Shell command: ")
                     current-prefix-arg
                     shell-command-default-error-buffer))
   ;; Look for a handler in case default-directory is a remote file name.
@@ -2187,9 +2213,7 @@ specifies the value of ERROR-BUFFER."
                 ;; Do this before calling region-beginning
                 ;; and region-end, in case subprocess output
                 ;; relocates them while we are in the minibuffer.
-                (setq string (read-from-minibuffer "Shell command on region: "
-                                                   nil nil nil
-                                                   'shell-command-history))
+                (setq string (read-shell-command "Shell command on region: "))
                 ;; call-interactively recognizes region-beginning and
                 ;; region-end specially, leaving them in the history.
                 (list (region-beginning) (region-end)
@@ -3455,7 +3479,8 @@ With no prefix argument, set the mark at point, and push the
 old mark position on local mark ring.  Also push the old mark on
 global mark ring, if the previous mark was set in another buffer.
 
-Immediately repeating this command activates `transient-mark-mode' temporarily.
+When Transient Mark Mode is off, immediately repeating this
+command activates `transient-mark-mode' temporarily.
 
 With prefix argument \(e.g., \\[universal-argument] \\[set-mark-command]\), \
 jump to the mark, and set the mark from
@@ -3499,6 +3524,9 @@ purposes.  See the documentation of `set-mark' for more information."
         mark-active (null transient-mark-mode))
     (setq transient-mark-mode 'lambda)
     (message "Transient-mark-mode temporarily enabled"))
+   ((and (eq last-command 'set-mark-command)
+         transient-mark-mode)
+    (deactivate-mark))
    (t
     (push-mark-command nil))))
 
@@ -3586,7 +3614,9 @@ default part of the buffer's text.  Examples of such commands include
 Invoke \\[apropos-documentation] and type \"transient\" or
 \"mark.*active\" at the prompt, to see the documentation of
 commands which are sensitive to the Transient Mark mode."
-  :global t :group 'editing-basics)
+  :global t
+;;;  :init-value (not noninteractive)
+  :group 'editing-basics)
 
 (defvar widen-automatically t
   "Non-nil means it is ok for commands to call `widen' when they want to.
@@ -4386,7 +4416,7 @@ If optional arg REALLY-WORD is non-nil, it finds just a word."
                 string)
   :group 'fill)
 (make-variable-buffer-local 'fill-prefix)
-;;;###autoload(put 'fill-prefix 'safe-local-variable 'string-or-null-p)
+(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."
@@ -4596,7 +4626,6 @@ The variable `selective-display' has a separate value for each buffer."
   (princ "." t))
 
 (defvaralias 'indicate-unused-lines 'indicate-empty-lines)
-(defvaralias 'default-indicate-unused-lines 'default-indicate-empty-lines)
 
 (defun toggle-truncate-lines (&optional arg)
   "Toggle whether to fold or truncate long lines for the current buffer.