;;; 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 Free Software Foundation, Inc.
+;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+;; Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: internal
(newline)
(save-excursion
(goto-char pos)
- (indent-according-to-mode)
+ ;; Usually indent-according-to-mode should "preserve" point, but it is
+ ;; not guaranteed; e.g. indent-to-left-margin doesn't.
+ (save-excursion (indent-according-to-mode))
(delete-horizontal-space t))
(indent-according-to-mode)))
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
+used as the pasted text, but the other will be placed in the
+kill ring for easy access via `yank-pop'.
+
Note that the function should return a string only if a program other
than Emacs has provided a string for pasting; if Emacs provided the
most recent string, the function should return nil. If it is
(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, then that string is added to the front of the
-kill ring and returned as the latest kill.
-If optional arg DO-NOT-MOVE is non-nil, then don't actually move the
-yanking point; just return the Nth kill forward."
+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 optional arg DO-NOT-MOVE is non-nil, then don't
+actually move the yanking point; just return the Nth kill forward."
(let ((interprogram-paste (and (= n 0)
interprogram-paste-function
(funcall interprogram-paste-function))))
;; text to the kill ring, so Emacs doesn't try to own the
;; selection, with identical text.
(let ((interprogram-cut-function nil))
- (kill-new interprogram-paste))
- interprogram-paste)
+ (if (listp interprogram-paste)
+ (mapc 'kill-new (nreverse interprogram-paste))
+ (kill-new interprogram-paste)))
+ (car kill-ring))
(or kill-ring (error "Kill ring is empty"))
(let ((ARGth-kill-element
(nthcdr (mod (- n (length kill-ring-yank-pointer))
(point))))))
(let* ((oldpos (point))
(message-log-max nil) ; Don't log messages about paren matching.
+ (atdollar (eq (syntax-class (syntax-after (1- oldpos))) 8))
+ (isdollar)
(blinkpos
(save-excursion
(save-restriction
(matching-paren
(and blinkpos
;; Not syntax '$'.
- (not (eq (syntax-class (syntax-after blinkpos)) 8))
+ (not (setq isdollar
+ (eq (syntax-class (syntax-after blinkpos)) 8)))
(let ((syntax (syntax-after blinkpos)))
(and (consp syntax)
(eq (syntax-class syntax) 4)
(cdr syntax))))))
(cond
- ((not (or (eq matching-paren (char-before oldpos))
+ ;; isdollar is for:
+ ;; http://lists.gnu.org/archive/html/emacs-devel/2007-10/msg00871.html
+ ((not (or (and isdollar blinkpos)
+ (and atdollar (not blinkpos)) ; see below
+ (eq matching-paren (char-before oldpos))
;; The cdr might hold a new paren-class info rather than
;; a matching-char info, in which case the two CDRs
;; should match.
(eq matching-paren (cdr (syntax-after (1- oldpos))))))
(message "Mismatched parentheses"))
((not blinkpos)
- (if (not blink-matching-paren-distance)
+ (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")))
((pos-visible-in-window-p blinkpos)
;; Matching open within window, temporarily move to blinkpos but only