;;; 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
+;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
;; Free Software Foundation, Inc.
;; Maintainer: FSF
;;; 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)
(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
(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)
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.
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.
;; 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)
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
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))))
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.
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."
(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.
Type \\<completion-list-mode-map>\\[choose-completion] in the completion list\
to select the completion near point.
Use \\<completion-list-mode-map>\\[mouse-choose-completion] to select one\
- with the mouse."
+ with the mouse.
+
+\\{completion-list-mode-map}"
+
(interactive)
(kill-all-local-variables)
(use-local-map completion-list-mode-map)
(defvar clone-buffer-hook nil
"Normal hook to run in the new buffer at the end of `clone-buffer'.")
+(defvar clone-indirect-buffer-hook nil
+ "Normal hook to run in the new buffer at the end of `clone-indirect-buffer'.")
+
(defun clone-process (process &optional newname)
"Create a twin copy of PROCESS.
If NEWNAME is nil, it defaults to PROCESS' name;
(setq newname (substring newname 0 (match-beginning 0))))
(let* ((name (generate-new-buffer-name newname))
(buffer (make-indirect-buffer (current-buffer) name t)))
+ (with-current-buffer buffer
+ (run-hooks 'clone-indirect-buffer-hook))
(when display-flag
(pop-to-buffer buffer norecord))
buffer))