[Top][All Lists]

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

Re: Enhance word-based commands?

From: Kim F. Storm
Subject: Re: Enhance word-based commands?
Date: 19 Jan 2003 03:18:16 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

address@hidden (Kim F. Storm) writes:

> The fun thing about my "yank-function" functionality is that using
> dynaword-kill-word can (silently) arrange for C-y to insert the killed
> word(s) in a certain "non-trivial" way.

I renamed it to "yank-handler" (see NEWS), but here is a replacement
to kill-rectangle which allows you to insert the rectangle using C-y
(from the kill-ring), and even use M-y to cycle the kill-ring with
rectangles on the ring:

(defun kill-rectangle (start end &optional fill)
  (interactive "*r\nP")
  (when buffer-read-only
    (setq killed-rectangle (extract-rectangle start end))
  (setq killed-rectangle (delete-extract-rectangle start end fill))
  (kill-new "=" nil 
            (list 'insert-rectangle killed-rectangle t
                  (lambda (s e)
                    (delete-rectangle s e)
                    (goto-char s)))))

It is not perfect though.  If inserting the rectangle changes tabs to
spaces, M-y may not completely restore the buffer to the state before
the rectangle was inserted, before inserting the next element from the
kill-ring.  But it's close, so I hope you can see the potential in the
new functionality.

Now, this should allow a new intelligent i-kill-word function to
install a yank-handler which will correctly insert the killed words
with appropriate spaces according to context [i.e. don't insert a
space before punctuation or at beginning/end of line].

Kim F. Storm <address@hidden> http://www.cua.dk

reply via email to

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