emacs-devel
[Top][All Lists]
Advanced

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

yank-pop error unnecessary and annoying


From: Geoff Gole
Subject: yank-pop error unnecessary and annoying
Date: Tue, 15 Jun 2010 00:00:22 +0800

If called without a previous yank, yank-pop will produce an error
message and do nothing useful. Why doesn't it just fall back on yank
instead?

diff -c -L /usr/local/share/emacs/23.1.50/lisp/simple.el.gz -L
/tmp/buffer-content-5442SIK /tmp/jka-com5442fSQ
/tmp/buffer-content-5442SIK
*** /usr/local/share/emacs/23.1.50/lisp/simple.el.gz
--- /tmp/buffer-content-5442SIK
***************
*** 3034,3043 ****

  (defun yank-pop (&optional arg)
    "Replace just-yanked stretch of killed text with a different stretch.
! This command is allowed only immediately after a `yank' or a `yank-pop'.
! At such a time, the region contains a stretch of reinserted
! previously-killed text.  `yank-pop' deletes that text and inserts in its
! place a different stretch of killed text.

  With no argument, the previous kill is inserted.
  With argument N, insert the Nth previous kill.
--- 3034,3040 ----

  (defun yank-pop (&optional arg)
    "Replace just-yanked stretch of killed text with a different stretch.
! If there is no such killed text, simply yank.

  With no argument, the previous kill is inserted.
  With argument N, insert the Nth previous kill.
***************
*** 3050,3077 ****
  `yank-excluded-properties' and `yank-handler' as described in the
  doc string for `insert-for-yank-1', which see."
    (interactive "*p")
-   (if (not (eq last-command 'yank))
-       (error "Previous command was not a yank"))
    (setq this-command 'yank)
!   (unless arg (setq arg 1))
!   (let ((inhibit-read-only t)
!       (before (< (point) (mark t))))
!     (if before
!       (funcall (or yank-undo-function 'delete-region) (point) (mark t))
!       (funcall (or yank-undo-function 'delete-region) (mark t) (point)))
!     (setq yank-undo-function nil)
!     (set-marker (mark-marker) (point) (current-buffer))
!     (insert-for-yank (current-kill arg))
!     ;; Set the window start back where it was in the yank command,
!     ;; if possible.
!     (set-window-start (selected-window) yank-window-start t)
!     (if before
!       ;; This is like exchange-point-and-mark, but doesn't activate the mark.
!       ;; It is cleaner to avoid activation, even though the command
!       ;; loop would deactivate the mark because we inserted text.
!       (goto-char (prog1 (mark t)
!                    (set-marker (mark-marker) (point) (current-buffer))))))
!   nil)

  (defun yank (&optional arg)
    "Reinsert (\"paste\") the last stretch of killed text.
--- 3047,3074 ----
  `yank-excluded-properties' and `yank-handler' as described in the
  doc string for `insert-for-yank-1', which see."
    (interactive "*p")
    (setq this-command 'yank)
!   (if (not (eq last-command 'yank))
!       (yank arg)
!     (unless arg (setq arg 1))
!     (let ((inhibit-read-only t)
!         (before (< (point) (mark t))))
!       (if before
!         (funcall (or yank-undo-function 'delete-region) (point) (mark t))
!       (funcall (or yank-undo-function 'delete-region) (mark t) (point)))
!       (setq yank-undo-function nil)
!       (set-marker (mark-marker) (point) (current-buffer))
!       (insert-for-yank (current-kill arg))
!       ;; Set the window start back where it was in the yank command,
!       ;; if possible.
!       (set-window-start (selected-window) yank-window-start t)
!       (if before
!         ;; This is like exchange-point-and-mark, but doesn't activate the 
mark.
!         ;; It is cleaner to avoid activation, even though the command
!         ;; loop would deactivate the mark because we inserted text.
!         (goto-char (prog1 (mark t)
!                      (set-marker (mark-marker) (point) (current-buffer))))))
!     nil))

  (defun yank (&optional arg)
    "Reinsert (\"paste\") the last stretch of killed text.

Attachment: yank-pop-yank-not-error.patch
Description: Text Data


reply via email to

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