(setq done (+ 40 done)))
(while (re-search-forward "[\n\C-m]" nil t 1)
(setq done (+ 1 done)))
- done)
+ (goto-char (point-max))
+ (if (and (/= start end)
+ (not (bolp)))
+ (1+ done)
+ done))
(- (buffer-size) (forward-line (buffer-size))))))))
(defun what-cursor-position ()
(interactive)
(kill-all-local-variables))
-(defvar read-expression-map (copy-keymap minibuffer-local-map)
+(defvar read-expression-map (cons 'keymap minibuffer-local-map)
"Minibuffer keymap used for reading Lisp expressions.")
(define-key read-expression-map "\M-\t" 'lisp-complete-symbol)
(put 'eval-expression 'disabled t)
-;; We define this, rather than making eval interactive,
+(defvar read-expression-history nil)
+
+;; We define this, rather than making `eval' interactive,
;; for the sake of completion of names like eval-region, eval-current-buffer.
(defun eval-expression (expression)
"Evaluate EXPRESSION and print value in minibuffer.
Value is also consed on to front of the variable `values'."
- (interactive (list (read-from-minibuffer "Eval: "
- nil read-expression-map t)))
+ (interactive
+ (list (read-from-minibuffer "Eval: "
+ nil read-expression-map t
+ 'read-expression-history)))
(setq values (cons (eval expression) values))
(prin1 (car values) t))
the minibuffer, then read and evaluate the result."
(let ((command (read-from-minibuffer prompt
(prin1-to-string command)
- read-expression-map t)))
- ;; Add edited command to command history, unless redundant.
- (or (equal command (car command-history))
- (setq command-history (cons command command-history)))
+ read-expression-map t
+ '(command-history . 1))))
(eval command)))
(defun repeat-complex-command (arg)
newcmd)
(if elt
(progn
- (setq newcmd (read-from-minibuffer "Redo: "
- (prin1-to-string elt)
- read-expression-map
- t
- (cons 'command-history
- arg)))
+ (setq newcmd
+ (read-from-minibuffer
+ "Redo: " (prin1-to-string elt) read-expression-map t
+ (cons 'command-history arg)))
+
;; If command was added to command-history as a string,
;; get rid of that. We want only evallable expressions there.
(if (stringp (car command-history))
(setq command-history (cdr command-history)))
+
;; If command to be redone does not match front of history,
;; add it to the history.
(or (equal newcmd (car command-history))
(error "No further undo information"))
(setq pending-undo-list (primitive-undo count pending-undo-list)))
-(defvar last-shell-command "")
-(defvar last-shell-command-on-region "")
+(defvar shell-command-history nil
+ "History list for some commands that read shell commands.")
(defun shell-command (command &optional flag)
"Execute string COMMAND in inferior shell; display output, if any.
Optional second arg non-nil (prefix arg, if interactive)
means insert output in current buffer after point (leave mark after it).
This cannot be done asynchronously."
- (interactive (list (read-string "Shell command: " last-shell-command)
+ (interactive (list (read-from-minibuffer "Shell command: "
+ nil nil nil 'shell-command-history)
current-prefix-arg))
(if flag
(progn (barf-if-buffer-read-only)
or output is inserted in the current buffer then `*Shell Command Output*' is
deleted."
(interactive (list (region-beginning) (region-end)
- (read-string "Shell command on region: "
- last-shell-command-on-region)
+ (read-from-minibuffer "Shell command on region: "
+ nil nil nil 'shell-command-history)
current-prefix-arg
(prefix-numeric-value current-prefix-arg)))
(if flag
(kill-new interprogram-paste))
interprogram-paste)
(or kill-ring (error "Kill ring is empty"))
- (let* ((length (length kill-ring))
- (ARGth-kill-element
- (nthcdr (% (+ n (- length (length kill-ring-yank-pointer)))
- length)
- kill-ring)))
+ (let ((ARGth-kill-element
+ (nthcdr (mod (- n (length kill-ring-yank-pointer))
+ (length kill-ring))
+ kill-ring)))
(or do-not-move
(setq kill-ring-yank-pointer ARGth-kill-element))
(car ARGth-kill-element)))))
;; ring to share the same string object. This code does that.
((not (or (eq buffer-undo-list t)
(eq last-command 'kill-region)
- (eq beg end)))
+ (equal beg end)))
;; Don't let the undo list be truncated before we can even access it.
(let ((undo-strong-limit (+ (- (max beg end) (min beg end)) 100))
(old-list buffer-undo-list)
;; If user quit, deactivate the mark
;; as C-g would as a command.
(and quit-flag mark-active
- (progn
- (message "foo") ;XXX what is this here for? --roland
- (deactivate-mark))))
+ (deactivate-mark)))
(let* ((killed-text (current-kill 0))
(message-len (min (length killed-text) 40)))
(if (= (point) beg)
;; run deactivate-mark-hook. This shorthand should simplify.
(defsubst deactivate-mark ()
"Deactivate the mark by setting `mark-active' to nil.
+\(That makes a difference only in Transient Mark mode.)
Also runs the hook `deactivate-mark-hook'."
(setq mark-active nil)
(run-hooks 'deactivate-mark-hook))
(let ((beg (point))) (forward-line 1) (delete-region beg (point)))."
- (setq mark-active t)
- (run-hooks 'activate-mark-hook)
- (set-marker (mark-marker) pos (current-buffer)))
+ (if pos
+ (progn
+ (setq mark-active t)
+ (run-hooks 'activate-mark-hook)
+ (set-marker (mark-marker) pos (current-buffer)))
+ (deactivate-mark)
+ (set-marker (mark-marker) pos (current-buffer))))
(defvar mark-ring nil
"The list of saved former marks of the current buffer,
(if (save-excursion
(goto-char fill-point)
(not (bolp)))
- ;; If point is at the fill-point, do not `save-excursion'.
- ;; Otherwise, if a comment prefix or fill-prefix is inserted,
- ;; point will end up before it rather than after it.
- (if (save-excursion
- (skip-chars-backward " \t")
- (= (point) fill-point))
- (indent-new-comment-line)
- (save-excursion
- (goto-char fill-point)
- (indent-new-comment-line)))
+ (let ((prev-column (current-column)))
+ ;; If point is at the fill-point, do not `save-excursion'.
+ ;; Otherwise, if a comment prefix or fill-prefix is inserted,
+ ;; point will end up before it rather than after it.
+ (if (save-excursion
+ (skip-chars-backward " \t")
+ (= (point) fill-point))
+ (indent-new-comment-line)
+ (save-excursion
+ (goto-char fill-point)
+ (indent-new-comment-line)))
+ ;; If making the new line didn't reduce the hpos of
+ ;; the end of the line, then give up now;
+ ;; trying again will not help.
+ (if (>= (current-column) prev-column)
+ (setq give-up t)))
;; No place to break => stop trying.
(setq give-up t)))))))
"Move cursor momentarily to the beginning of the sexp before point."
(interactive)
(and (> (point) (1+ (point-min)))
- (/= (char-syntax (char-after (- (point) 2))) ?\\ )
+ (not (memq (char-syntax (char-after (- (point) 2))) '(?/ ?\\ )))
blink-matching-paren
(let* ((oldpos (point))
(blinkpos)
\f
;; Define the major mode for lists of completions.
-(defvar completion-mode-map nil)
-(or completion-mode-map
+(defvar completion-list-mode-map nil)
+(or completion-list-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [mouse-2] 'mouse-choose-completion)
- (setq completion-mode-map map)))
+ (setq completion-list-mode-map map)))
;; Completion mode is suitable only for specially formatted data.
-(put 'completion-mode 'mode-class 'special)
+(put 'completion-list-mode 'mode-class 'special)
-(defun completion-mode ()
+(defun completion-list-mode ()
"Major mode for buffers showing lists of possible completions.
-Type \\<completion-mode-map>\\[mouse-choose-completion] to select
+Type \\<completion-list-mode-map>\\[mouse-choose-completion] to select
a completion with the mouse."
(interactive)
(kill-all-local-variables)
- (use-local-map completion-mode-map)
- (setq mode-name "Completion")
- (setq major-mode 'completion-mode)
- (run-hooks 'completion-mode-hook))
+ (use-local-map completion-list-mode-map)
+ (setq mode-name "Completion List")
+ (setq major-mode 'completion-list-mode)
+ (run-hooks 'completion-list-mode-hook))
(defun completion-setup-function ()
(save-excursion
- (completion-mode)
+ (completion-list-mode)
(goto-char (point-min))
(if window-system
(insert (substitute-command-keys