X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/fec2107c58835163dc3b08c0a833a5072aa1fca9..d024fb4ec9dd59c0364e01768514ef67e2d17457:/lisp/simple.el diff --git a/lisp/simple.el b/lisp/simple.el index 76269c9ef9..fe46e36fda 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -52,60 +52,6 @@ wait this many seconds after Emacs becomes idle before doing an update." (defgroup paren-matching nil "Highlight (un)matching of parens and expressions." :group 'matching) - -(defun get-next-valid-buffer (list &optional buffer visible-ok frame) - "Search LIST for a valid buffer to display in FRAME. -Return nil when all buffers in LIST are undesirable for display, -otherwise return the first suitable buffer in LIST. - -Buffers not visible in windows are preferred to visible buffers, -unless VISIBLE-OK is non-nil. -If the optional argument FRAME is nil, it defaults to the selected frame. -If BUFFER is non-nil, ignore occurrences of that buffer in LIST." - ;; This logic is more or less copied from other-buffer. - (setq frame (or frame (selected-frame))) - (let ((pred (frame-parameter frame 'buffer-predicate)) - found buf) - (while (and (not found) list) - (setq buf (car list)) - (if (and (not (eq buffer buf)) - (buffer-live-p buf) - (or (null pred) (funcall pred buf)) - (not (eq (aref (buffer-name buf) 0) ?\s)) - (or visible-ok (null (get-buffer-window buf 'visible)))) - (setq found buf) - (setq list (cdr list)))) - (car list))) - -(defun last-buffer (&optional buffer visible-ok frame) - "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. -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) - (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) - (let ((buffer (current-buffer))) - (switch-to-buffer (other-buffer buffer t)) - (bury-buffer buffer))) - -(defun previous-buffer () - "Switch to the previous buffer in cyclic order." - (interactive) - (switch-to-buffer (last-buffer (current-buffer) t))) - ;;; next-error support framework @@ -954,10 +900,11 @@ rather than line counts." (save-excursion (skip-chars-backward "0-9") (if (looking-at "[0-9]") - (buffer-substring-no-properties - (point) - (progn (skip-chars-forward "0-9") - (point)))))) + (string-to-number + (buffer-substring-no-properties + (point) + (progn (skip-chars-forward "0-9") + (point))))))) ;; Decide if we're switching buffers. (buffer (if (consp current-prefix-arg) @@ -1206,6 +1153,8 @@ display the result of expression evaluation." (defun eval-expression (eval-expression-arg &optional eval-expression-insert-value) "Evaluate EVAL-EXPRESSION-ARG and print value in the echo area. +When called interactively, read an Emacs Lisp expression and +evaluate it. Value is also consed on to front of the variable `values'. Optional argument EVAL-EXPRESSION-INSERT-VALUE non-nil (interactively, with prefix argument) means insert the result into the current buffer @@ -2585,7 +2534,11 @@ specifies the value of ERROR-BUFFER." (let ((output (if (and error-file (< 0 (nth 7 (file-attributes error-file)))) - "some error output" + (format "some error output%s" + (if shell-command-default-error-buffer + (format " to the \"%s\" buffer" + shell-command-default-error-buffer) + "")) "no output"))) (cond ((null exit-status) (message "(Shell command failed with error)")) @@ -3104,10 +3057,11 @@ 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 and `interprogram-paste-function' is set to a +function that returns a string or a list of strings, and if that +function doesn't return nil, 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 @@ -5284,14 +5238,16 @@ Some major modes set this.") ;; auto-fill-function to nil in a file-local setting is safe and ;; can be useful to prevent auto-filling. (put 'auto-fill-function 'safe-local-variable 'null) -;; FIXME: turn into a proper minor mode. -;; Add a global minor mode version of it. + (define-minor-mode auto-fill-mode "Toggle Auto Fill mode. 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. +When `auto-fill-mode' is on, the `auto-fill-function' variable is +non-`nil'. + The value of `normal-auto-fill-function' specifies the function to use for `auto-fill-function' when turning Auto Fill mode on." :variable (eq auto-fill-function normal-auto-fill-function)) @@ -5353,11 +5309,12 @@ The variable `selective-display' has a separate value for each buffer." (defvaralias 'indicate-unused-lines 'indicate-empty-lines) (defun toggle-truncate-lines (&optional arg) - "Toggle whether to fold or truncate long lines for the current buffer. + "Toggle truncating of long lines for the current buffer. +When truncating is off, long lines are folded. 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' -is non-nil." +otherwise fold 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 (if (null arg) @@ -5570,8 +5527,8 @@ The function should return non-nil if the two tokens do not match.") (minibuffer-message "Mismatched parentheses") (message "Mismatched parentheses")) (if (minibufferp) - (minibuffer-message "Unmatched parenthesis") - (message "Unmatched parenthesis")))) + (minibuffer-message "No matching parenthesis found") + (message "No matching parenthesis found")))) ((not blinkpos) nil) ((pos-visible-in-window-p blinkpos) ;; Matching open within window, temporarily move to blinkpos but only