[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Various simple.el patches

From: Stefan Monnier
Subject: Various simple.el patches
Date: Tue, 13 May 2003 16:31:51 -0400

1 - When killing the same thing over and over again, don't fill
    the kill-ring unnecessarily.

@@ -1810,6 +1859,7 @@
 argument is not used by `insert-for-yank'.  However, since Lisp code
 may access and use elements from the kill-ring directly, the STRING
 argument should still be a \"useful\" string for such uses."
+  (when (equal string (car kill-ring)) (setq replace t))
   (if (> (length string) 0)
       (if yank-handler
          (put-text-property 0 1 'yank-handler yank-handler string)

2a - When yanking with an active region, do `delete-selection'.
2b - And if the yanked text is the same as the current region,
     then yank the previous text.  This way you can mouse-select
     one piece of text (which pushes it on the kill-ring),
     then mouse-select another, then `yank' which replaces the
     second piece of text with the first one.

@@ -2067,7 +2117,11 @@
   ;; If we don't get all the way thru, make last-command indicate that
   ;; for the following command.
   (setq this-command t)
-  (push-mark (point))
+  (if (and transient-mark-mode mark-active)
+      (let ((old (delete-and-extract-region (region-beginning) (region-end))))
+       (if (and (listp arg) (string= old (current-kill 0)))
+           (rotate-yank-pointer 1)))
+    (push-mark (point)))
   (insert-for-yank (current-kill (cond
                                  ((listp arg) 0)
                                  ((eq arg '-) -1)

3 - Make C-k at EOB kill the last line.
    This is mostly useful for the minibuffer and maybe it should
    only do so in the minibuffer.

@@ -2196,7 +2250,13 @@
                 (if arg
                     (forward-visible-line (prefix-numeric-value arg))
                   (if (eobp)
-                      (signal 'end-of-buffer nil))
+                      ;; Make C-k at end of minibuf do C-a C-k.
+                      (if (eq last-command this-command)
+                          ;; Don't do it repeatedly: the user might
+                          ;; stupidly be pressing C-k to delete-to-eob (he
+                          ;; should do M-> C-w instead, of course).
+                          (signal 'end-of-buffer nil)
+                        (beginning-of-line)))
                   (let ((end
                            (end-of-visible-line) (point))))

-- Stefan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]